1111use PhpParser \Node \Expr \MethodCall ;
1212use PhpParser \Node \Expr \Variable ;
1313use PhpParser \Node \Name \FullyQualified ;
14+ use PhpParser \Node \Stmt ;
1415use PhpParser \Node \Stmt \ClassMethod ;
1516use PhpParser \Node \Stmt \Expression ;
1617use PhpParser \Node \Stmt \Foreach_ ;
1718use PHPStan \Type \ObjectType ;
1819use PHPStan \Type \Type ;
1920use PHPStan \Type \TypeCombinator ;
21+ use PHPStan \Type \UnionType ;
2022use Rector \PHPUnit \CodeQuality \ValueObject \VariableNameToType ;
2123use Rector \PHPUnit \NodeAnalyzer \TestsNodeAnalyzer ;
2224use Rector \Rector \AbstractRector ;
@@ -159,7 +161,7 @@ public function refactor(Node $node): ?Node
159161
160162 private function isNullableType (Type $ type ): bool
161163 {
162- if (! $ type instanceof \ PHPStan \ Type \ UnionType) {
164+ if (! $ type instanceof UnionType) {
163165 return false ;
164166 }
165167
@@ -217,12 +219,12 @@ private function matchNullableVariableNameToType(
217219 ): ?VariableNameToType {
218220 $ variableName = $ this ->getName ($ variable );
219221
220- foreach ($ nullableVariableNamesToTypes as $ nullableVariableNamesToType ) {
221- if ($ nullableVariableNamesToType ->getVariableName () !== $ variableName ) {
222+ foreach ($ nullableVariableNamesToTypes as $ nullableVariableNameToType ) {
223+ if ($ nullableVariableNameToType ->getVariableName () !== $ variableName ) {
222224 continue ;
223225 }
224226
225- return $ nullableVariableNamesToType ;
227+ return $ nullableVariableNameToType ;
226228 }
227229
228230 return null ;
@@ -232,15 +234,15 @@ private function matchNullableVariableNameToType(
232234 * @param VariableNameToType[] $variableNamesToTypes
233235 */
234236 private function matchedNullableVariableNameToType (
235- Node \ Stmt $ stmt ,
237+ Stmt $ stmt ,
236238 array $ variableNamesToTypes
237239 ): ?VariableNameToType {
238240 $ matchedNullableVariableNameToType = null ;
239241
240242 $ this ->traverseNodesWithCallable ($ stmt , function (Node $ node ) use (
241243 $ variableNamesToTypes ,
242244 &$ matchedNullableVariableNameToType
243- ) {
245+ ): null {
244246 if (! $ node instanceof MethodCall) {
245247 return null ;
246248 }
0 commit comments