@@ -5,9 +5,7 @@ |
||
5 | 5 | |
6 | 6 | |
7 | 7 | use PhpParser\Node; |
8 | -use PhpParser\Node\Stmt\Catch_; |
|
9 | 8 | use PHPStan\Analyser\Scope; |
10 | -use PHPStan\Broker\Broker; |
|
11 | 9 | use PHPStan\Rules\Rule; |
12 | 10 | |
13 | 11 | /** |
@@ -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 | /** |
@@ -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 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param ReflectionParameter $parameter |
89 | 89 | * @return null|string |
90 | 90 | */ |
91 | - private function analyzeParameter(ReflectionParameter $parameter): ?string |
|
91 | + private function analyzeParameter(ReflectionParameter $parameter): ? string |
|
92 | 92 | { |
93 | 93 | $phpTypeHint = $parameter->getTypeHint(); |
94 | 94 | $docBlockTypeHints = $parameter->getDocBlockTypes(); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param ReflectionFunction|ReflectionMethod $function |
106 | 106 | * @return null|string |
107 | 107 | */ |
108 | - private function analyzeReturnType($function): ?string |
|
108 | + private function analyzeReturnType($function): ? string |
|
109 | 109 | { |
110 | 110 | $reflectionPhpTypeHint = $function->getReturnType(); |
111 | 111 | $phpTypeHint = null; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param Type[] $docBlockTypeHints |
129 | 129 | * @return null|string |
130 | 130 | */ |
131 | - private function analyzeWithTypehint($context, Type $phpTypeHint, array $docBlockTypeHints): ?string |
|
131 | + private function analyzeWithTypehint($context, Type $phpTypeHint, array $docBlockTypeHints): ? string |
|
132 | 132 | { |
133 | 133 | $docblockWithoutNullable = $this->typesWithoutNullable($docBlockTypeHints); |
134 | 134 | |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | foreach ($docblockWithoutNullable as $docblockTypehint) { |
158 | 158 | if (!$docblockTypehint instanceof Array_) { |
159 | 159 | if ($context instanceof ReflectionParameter) { |
160 | - 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); |
|
160 | + 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); |
|
161 | 161 | } else { |
162 | - 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); |
|
162 | + 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); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @param Type[] $docBlockTypeHints |
182 | 182 | * @return null|string |
183 | 183 | */ |
184 | - private function analyzeWithoutTypehint($context, array $docBlockTypeHints): ?string |
|
184 | + private function analyzeWithoutTypehint($context, array $docBlockTypeHints): ? string |
|
185 | 185 | { |
186 | 186 | if (empty($docBlockTypeHints)) { |
187 | 187 | if ($context instanceof ReflectionParameter) { |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param Type[] $docBlockTypeHints |
209 | 209 | * @return string|null |
210 | 210 | */ |
211 | - private function isNativelyTypehintable(array $docBlockTypeHints): ?string |
|
211 | + private function isNativelyTypehintable(array $docBlockTypeHints): ? string |
|
212 | 212 | { |
213 | 213 | if (count($docBlockTypeHints) > 2) { |
214 | 214 | return null; |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | $type = $types[0]; |
228 | 228 | |
229 | 229 | if ($this->isNativeType($type)) { |
230 | - return ($isNullable?'?':'').((string)$type); |
|
230 | + return ($isNullable ? '?' : '').((string) $type); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | if ($type instanceof Array_) { |
234 | - return ($isNullable?'?':'').'array'; |
|
234 | + return ($isNullable ? '?' : '').'array'; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // TODO: more definitions to add here |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | // Manage array of things => (cast to array) |
240 | 240 | |
241 | 241 | if ($type instanceof Object_) { |
242 | - return ($isNullable?'?':'').((string)$type); |
|
242 | + return ($isNullable ? '?' : '').((string) $type); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | return null; |
@@ -3,9 +3,7 @@ |
||
3 | 3 | |
4 | 4 | namespace TheCodingMachine\PHPStan\Rules\TypeHints; |
5 | 5 | |
6 | -use BetterReflection\Reflection\ReflectionFunction; |
|
7 | 6 | use BetterReflection\Reflection\ReflectionFunctionAbstract; |
8 | -use BetterReflection\Reflection\ReflectionMethod; |
|
9 | 7 | use 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 BetterReflection\Reflection\ReflectionFunction; |
|
7 | 6 | use BetterReflection\Reflection\ReflectionFunctionAbstract; |
8 | -use BetterReflection\Reflection\ReflectionMethod; |
|
9 | 7 | use BetterReflection\Reflection\ReflectionParameter; |
10 | 8 | use PhpParser\Node; |
11 | -use PHPStan\Reflection\MethodReflection; |
|
12 | 9 | |
13 | 10 | class MissingTypeHintInMethodRule extends AbstractMissingTypeHintRule |
14 | 11 | { |