@@ -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 | |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | foreach ($docblockWithoutNullable as $docblockTypehint) { |
190 | 190 | if (!$this->isTypeIterable($docblockTypehint)) { |
191 | 191 | if ($context instanceof ReflectionParameter) { |
192 | - 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); |
|
192 | + 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 | 193 | } else { |
194 | - 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); |
|
194 | + 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 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -299,11 +299,11 @@ discard block |
||
299 | 299 | $type = $types[0]; |
300 | 300 | |
301 | 301 | if ($this->isNativeType($type)) { |
302 | - return ($isNullable?'?':'').((string)$type); |
|
302 | + return ($isNullable ? '?' : '').((string) $type); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | if ($type instanceof Array_) { |
306 | - return ($isNullable?'?':'').'array'; |
|
306 | + return ($isNullable ? '?' : '').'array'; |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | // TODO: more definitions to add here |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | // Manage array of things => (cast to array) |
312 | 312 | |
313 | 313 | if ($type instanceof Object_) { |
314 | - return ($isNullable?'?':'').((string)$type); |
|
314 | + return ($isNullable ? '?' : '').((string) $type); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | return null; |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | */ |
355 | 355 | private function typesWithoutNullable(array $docBlockTypeHints): array |
356 | 356 | { |
357 | - return array_values(array_filter($docBlockTypeHints, function ($item) { |
|
357 | + return array_values(array_filter($docBlockTypeHints, function($item) { |
|
358 | 358 | return !$item instanceof Null_; |
359 | 359 | })); |
360 | 360 | } |