From 631b1339ad603776675a86d8824a18f8697b7bf8 Mon Sep 17 00:00:00 2001 From: Patrik Foldes Date: Tue, 21 May 2019 15:17:18 +0300 Subject: [PATCH 1/3] Added support for phpstan-extension-installer --- README.md | 12 +++++++++--- composer.json | 7 ++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 582e0a6..bb3b927 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 +composer require --dev phpstan/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" + ] } } } From 2cd6074f351bc9a746bba402ab3addd698c8108e Mon Sep 17 00:00:00 2001 From: Patrik Foldes Date: Tue, 21 May 2019 15:23:09 +0300 Subject: [PATCH 2/3] Fixed typo in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb3b927..547a89c 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ We assume that [PHPStan](https://github.com/phpstan/phpstan) is already installe To use this extension, require it in [Composer](https://getcomposer.org/): ```bash -composer require --dev phpstan/phpstan-strict-rules +composer require --dev thecodingmachine/phpstan-strict-rules ``` If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set! From 1869c25e4752b3812cfb364fc2bce04da96c9d7d Mon Sep 17 00:00:00 2001 From: Patrik Foldes Date: Mon, 27 May 2019 18:24:40 +0300 Subject: [PATCH 3/3] Fixed phpstan error --- src/Rules/TypeHints/AbstractMissingTypeHintRule.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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; + } } }