Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce phpstan and start fixing problems #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"require-dev": {
"phpunit/phpunit": "4.*",
"squizlabs/php_codesniffer": "^2.6",
"phpdocumentor/reflection-docblock": "2.*"
"phpdocumentor/reflection-docblock": "2.*",
"szepeviktor/phpstan-wordpress": "^0.5.0"
},
"license": "GPL-2.0+",
"authors": [
Expand Down
247 changes: 246 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
- vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
# level: max
level: 4
inferPrivatePropertyTypeFromConstructor: true
autoload_files:
- tests/phpstan/acf-stubs-5.8.0.php
paths:
- src/
ignoreErrors:
# Should be possible using Generics: https://medium.com/@ondrejmirtes/generics-in-php-using-phpdocs-14e7301953
- '#^Method StoutLogic\\AcfBuilder\\Transform\\\w+::getBuilder\(\) should return StoutLogic\\AcfBuilder\\\w+Builder but returns StoutLogic\\AcfBuilder\\Builder\.$#'
5 changes: 3 additions & 2 deletions src/FieldsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ public function addChoiceField($name, $type, array $args = [])

/**
* Initialize the FieldBuilder, add to FieldManager
* @param FieldBuilder $field
* @return FieldBuilder
* @template FB of FieldBuilder
* @param FB $field
* @return FB
*/
protected function initializeField($field)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ModifyFieldReturnTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ModifyFieldReturnTypeException extends \UnexpectedValueException
/**
* @param string $returnedType
* @param int $code
* @param \Exception|null
* @param \Exception|null $previous
*/
public function __construct($returnedType, $code = 0, $previous = null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Transform/RecursiveTransform.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function transform($config)
/**
* Based upon the value or key, determine if the transform function
* should recurse.
* @param $value
* @param mixed $value
* @param string $key
* @return bool
*/
Expand Down
7 changes: 4 additions & 3 deletions src/Transform/Transform.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@

/**
* A Transform that is applied to configuration array of a Builder
* @template B of Builder
*/
abstract class Transform
{
/**
* Used to call funtions on the builder.
* @var \StoutLogic\AcfBuilder\Builder
* @var B
*/
private $builder;

/**
* @param Builder $builder
* @param B $builder
*/
public function __construct(Builder $builder)
{
$this->builder = $builder;
}

/**
* @return Builder
* @return B
*/
public function getBuilder()
{
Expand Down
Loading