diff --git a/README.md b/README.md index 582e0a6..547a89c 100644 --- a/README.md +++ b/README.md @@ -54,15 +54,21 @@ This is a PHP 7.1+ rule: We assume that [PHPStan](https://github.com/phpstan/phpstan) is already installed in your project. -Let's add this package: +To use this extension, require it in [Composer](https://getcomposer.org/): ```bash composer require --dev thecodingmachine/phpstan-strict-rules ``` -Now, edit your `phpstan.neon` file and add these rules: +If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set! + +
+ Manual installation + +If you don't want to use `phpstan/extension-installer`, include phpstan-strict-rules.neon in your project's PHPStan config: ```yml includes: - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon ``` +
diff --git a/composer.json b/composer.json index 188f1c9..cac6e1a 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": "^7.1", - "phpstan/phpstan": "^0.10|^0.11" + "phpstan/phpstan": "^0.11.7" }, "require-dev": { "phpunit/phpunit": "^7.1", @@ -37,6 +37,11 @@ "extra": { "branch-alias": { "dev-master": "0.10-dev" + }, + "phpstan": { + "includes": [ + "phpstan-strict-rules.neon" + ] } } } diff --git a/src/Rules/TypeHints/AbstractMissingTypeHintRule.php b/src/Rules/TypeHints/AbstractMissingTypeHintRule.php index 1fd3f36..1abf228 100644 --- a/src/Rules/TypeHints/AbstractMissingTypeHintRule.php +++ b/src/Rules/TypeHints/AbstractMissingTypeHintRule.php @@ -69,11 +69,13 @@ public function processNode(Node $node, Scope $scope): array $errors = []; foreach ($parametersAcceptor->getParameters() as $parameter) { - $debugContext = new ParameterDebugContext($scope, $node, $parameter); - $result = $this->analyzeParameter($debugContext, $parameter); + if ($parameter instanceof PhpParameterReflection) { + $debugContext = new ParameterDebugContext($scope, $node, $parameter); + $result = $this->analyzeParameter($debugContext, $parameter); - if ($result !== null) { - $errors[] = $result; + if ($result !== null) { + $errors[] = $result; + } } }