8000 [PropertyInfo] Creation of `PhpDocNode` extracted to separate method. · symfony/symfony@96030d0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 96030d0

Browse files
committed
[PropertyInfo] Creation of PhpDocNode extracted to separate method.
1 parent 43a1fa1 commit 96030d0

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ private function getDocBlockFromConstructor(string $class, string $property): ?P
183183
return null;
184184
}
185185

186-
$tokens = new TokenIterator($this->lexer->tokenize($rawDocNode));
187-
$phpDocNode = $this->phpDocParser->parse($tokens);
188-
$tokens->consumeTokenType(Lexer::TOKEN_END);
186+
$phpDocNode = $this->getPhpDocNode($rawDocNode);
189187

190188
return $this->filterDocBlockParams($phpDocNode, $property);
191189
}
@@ -253,9 +251,7 @@ private function getDocBlockFromProperty(string $class, string $property): ?arra
253251
return null;
254252
}
255253

256-
$tokens = new TokenIterator($this->lexer->tokenize($rawDocNode));
257-
$phpDocNode = $this->phpDocParser->parse($tokens);
258-
$tokens->consumeTokenType(Lexer::TOKEN_END);
254+
$phpDocNode = $this->getPhpDocNode($rawDocNode);
259255

260256
return [$phpDocNode, $source, $reflectionProperty->class];
261257
}
@@ -296,10 +292,17 @@ private function getDocBlockFromMethod(string $class, string $ucFirstProperty, i
296292
return null;
297293
}
298294

299-
$tokens = new TokenIterator($this->lexer->tokenize($rawDocNode));
295+
$phpDocNode = $this->getPhpDocNode($rawDocNode);
296+
297+
return [$phpDocNode, $prefix, $reflectionMethod->class];
298+
}
299+
300+
private function getPhpDocNode(string $rawDocNode): PhpDocNode
301+
{
302+
$tokens = new TokenIterator($this->lexer->tokenize($rawDocNode));
300303
$phpDocNode = $this->phpDocParser->parse($tokens);
301304
$tokens->consumeTokenType(Lexer::TOKEN_END);
302305

303-
return [$phpDocNode, $prefix, $reflectionMethod->class];
306+
return $phpDocNode;
304307
}
305308
}

0 commit comments

Comments
 (0)
0