Skip to content

Commit

Permalink
Merge pull request #49 from sspat/support-phpstan-extension-installer
Browse files Browse the repository at this point in the history
Add support for phpstan-extension-installer
  • Loading branch information
moufmouf authored May 27, 2019
2 parents 663fad8 + 1869c25 commit 57fb5d8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

<details>
<summary>Manual installation</summary>

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
```
</details>
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -37,6 +37,11 @@
"extra": {
"branch-alias": {
"dev-master": "0.10-dev"
},
"phpstan": {
"includes": [
"phpstan-strict-rules.neon"
]
}
}
}
10 changes: 6 additions & 4 deletions src/Rules/TypeHints/AbstractMissingTypeHintRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit 57fb5d8

Please sign in to comment.