@@ -7,7 +7,6 @@ |
||
7 | 7 | use PhpParser\Node; |
8 | 8 | use PhpParser\Node\Stmt\Catch_; |
9 | 9 | use PHPStan\Analyser\Scope; |
10 | -use PHPStan\Broker\Broker; |
|
11 | 10 | use PHPStan\Rules\Rule; |
12 | 11 | |
13 | 12 | class EmptyExceptionRule implements Rule |
@@ -9,7 +9,6 @@ |
||
9 | 9 | use PhpParser\NodeTraverser; |
10 | 10 | use PhpParser\NodeVisitorAbstract; |
11 | 11 | use PHPStan\Analyser\Scope; |
12 | -use PHPStan\Broker\Broker; |
|
13 | 12 | use PHPStan\Rules\Rule; |
14 | 13 | |
15 | 14 | /** |
@@ -3,12 +3,9 @@ |
||
3 | 3 | |
4 | 4 | namespace TheCodingMachine\PHPStan\Rules\TypeHints; |
5 | 5 | |
6 | -use Roave\BetterReflection\Reflection\ReflectionFunction; |
|
7 | 6 | use Roave\BetterReflection\Reflection\ReflectionFunctionAbstract; |
8 | -use Roave\BetterReflection\Reflection\ReflectionMethod; |
|
9 | 7 | use Roave\BetterReflection\Reflection\ReflectionParameter; |
10 | 8 | use PhpParser\Node; |
11 | -use PHPStan\Reflection\MethodReflection; |
|
12 | 9 | |
13 | 10 | class MissingTypeHintInMethodRule extends AbstractMissingTypeHintRule |
14 | 11 | { |
@@ -4,7 +4,6 @@ discard block |
||
4 | 4 | namespace TheCodingMachine\PHPStan\Rules\TypeHints; |
5 | 5 | |
6 | 6 | |
7 | -use phpDocumentor\Reflection\DocBlockFactory; |
|
8 | 7 | use phpDocumentor\Reflection\Type; |
9 | 8 | use phpDocumentor\Reflection\Types\Array_; |
10 | 9 | use phpDocumentor\Reflection\Types\Boolean; |
@@ -25,8 +24,6 @@ discard block |
||
25 | 24 | use Roave\BetterReflection\Reflection\ReflectionFunction; |
26 | 25 | use Roave\BetterReflection\Reflection\ReflectionMethod; |
27 | 26 | use Roave\BetterReflection\Reflection\ReflectionParameter; |
28 | -use Roave\BetterReflection\TypesFinder\PhpDocumentor\NamespaceNodeToReflectionTypeContext; |
|
29 | -use Roave\BetterReflection\TypesFinder\ResolveTypes; |
|
30 | 27 | |
31 | 28 | abstract class AbstractMissingTypeHintRule implements Rule |
32 | 29 | { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | namespace TheCodingMachine\PHPStan\Rules\TypeHints; |
5 | 5 | |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | foreach ($docblockWithoutNullable as $docblockTypehint) { |
188 | 188 | if (!$docblockTypehint instanceof Array_) { |
189 | 189 | if ($context instanceof ReflectionParameter) { |
190 | - return sprintf('%s, mismatching type-hints for parameter %s. PHP type hint is "array" and docblock type hint is %s.', $this->getContext($context), $context->getName(), (string)$docblockTypehint); |
|
190 | + return sprintf('%s, mismatching type-hints for parameter %s. PHP type hint is "array" and docblock type hint is %s.', $this->getContext($context), $context->getName(), (string) $docblockTypehint); |
|
191 | 191 | } else { |
192 | - return sprintf('%s, mismatching type-hints for return type. PHP type hint is "array" and docblock declared return type is %s.', $this->getContext($context), (string)$docblockTypehint); |
|
192 | + return sprintf('%s, mismatching type-hints for return type. PHP type hint is "array" and docblock declared return type is %s.', $this->getContext($context), (string) $docblockTypehint); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | $type = $types[0]; |
277 | 277 | |
278 | 278 | if ($this->isNativeType($type)) { |
279 | - return ($isNullable?'?':'').((string)$type); |
|
279 | + return ($isNullable ? '?' : '').((string) $type); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | if ($type instanceof Array_) { |
283 | - return ($isNullable?'?':'').'array'; |
|
283 | + return ($isNullable ? '?' : '').'array'; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // TODO: more definitions to add here |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | // Manage array of things => (cast to array) |
289 | 289 | |
290 | 290 | if ($type instanceof Object_) { |
291 | - return ($isNullable?'?':'').((string)$type); |
|
291 | + return ($isNullable ? '?' : '').((string) $type); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | return null; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | private function typesWithoutNullable(array $docBlockTypeHints): array |
333 | 333 | { |
334 | - return array_values(array_filter($docBlockTypeHints, function ($item) { |
|
334 | + return array_values(array_filter($docBlockTypeHints, function($item) { |
|
335 | 335 | return !$item instanceof Null_; |
336 | 336 | })); |
337 | 337 | } |