Просмотр исходного кода

minor #4785 Improve static analysis (enumag)

This PR was merged into the 2.15 branch.

Discussion
----------

Improve static analysis

In my project I implemented a custom fixer. When scanning the project with the latest phpstan I'm getting errors like this:

```
Method App\Module\Core\PhpCsFixer\MyCustomFixer::isCandidate() has parameter $tokens with no value type specified in iterable type PhpCsFixer\Tokenizer\Tokens.
```

The correct fix for this is to make phpstan aware that the `Tokens` class only contains `Token` instances using this annotation.

Commits
-------

00d90cfe Improve static analysis
SpacePossum 5 лет назад
Родитель
Сommit
a0591ecef2
1 измененных файлов с 2 добавлено и 0 удалено
  1. 2 0
      src/Tokenizer/Tokens.php

+ 2 - 0
src/Tokenizer/Tokens.php

@@ -24,6 +24,8 @@ use PhpCsFixer\Utils;
  *
  * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  *
+ * @extends \SplFixedArray<Token>
+ *
  * @method Token current()
  * @method Token offsetGet($index)
  */