@@ -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,9 +3,7 @@ |
||
| 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 | 9 | |
@@ -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 | { |
@@ -3,7 +3,6 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | namespace TheCodingMachine\PHPStan\Rules\TypeHints; |
| 5 | 5 | |
| 6 | -use phpDocumentor\Reflection\DocBlockFactory; |
|
| 7 | 6 | use phpDocumentor\Reflection\Type; |
| 8 | 7 | use phpDocumentor\Reflection\Types\Array_; |
| 9 | 8 | use phpDocumentor\Reflection\Types\Boolean; |
@@ -26,8 +25,6 @@ discard block |
||
| 26 | 25 | use Roave\BetterReflection\Reflection\ReflectionMethod; |
| 27 | 26 | use Roave\BetterReflection\Reflection\ReflectionParameter; |
| 28 | 27 | use Roave\BetterReflection\Reflector\Exception\IdentifierNotFound; |
| 29 | -use Roave\BetterReflection\TypesFinder\PhpDocumentor\NamespaceNodeToReflectionTypeContext; |
|
| 30 | -use Roave\BetterReflection\TypesFinder\ResolveTypes; |
|
| 31 | 28 | |
| 32 | 29 | abstract class AbstractMissingTypeHintRule implements Rule |
| 33 | 30 | { |
@@ -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 | |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | foreach ($docblockWithoutNullable as $docblockTypehint) { |
| 191 | 191 | if (!$this->isTypeIterable($docblockTypehint)) { |
| 192 | 192 | if ($context instanceof ReflectionParameter) { |
| 193 | - 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); |
|
| 193 | + 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); |
|
| 194 | 194 | } else { |
| 195 | - 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); |
|
| 195 | + 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); |
|
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | |
@@ -301,11 +301,11 @@ discard block |
||
| 301 | 301 | $type = $types[0]; |
| 302 | 302 | |
| 303 | 303 | if ($this->isNativeType($type)) { |
| 304 | - return ($isNullable?'?':'').((string)$type); |
|
| 304 | + return ($isNullable ? '?' : '').((string) $type); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | if ($type instanceof Array_) { |
| 308 | - return ($isNullable?'?':'').'array'; |
|
| 308 | + return ($isNullable ? '?' : '').'array'; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // TODO: more definitions to add here |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | // Manage array of things => (cast to array) |
| 314 | 314 | |
| 315 | 315 | if ($type instanceof Object_) { |
| 316 | - return ($isNullable?'?':'').((string)$type); |
|
| 316 | + return ($isNullable ? '?' : '').((string) $type); |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | return null; |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 357 | private function typesWithoutNullable(array $docBlockTypeHints): array |
| 358 | 358 | { |
| 359 | - return array_values(array_filter($docBlockTypeHints, function ($item) { |
|
| 359 | + return array_values(array_filter($docBlockTypeHints, function($item) { |
|
| 360 | 360 | return !$item instanceof Null_; |
| 361 | 361 | })); |
| 362 | 362 | } |