Skip to content

Commit

Permalink
Optimised tight cycle in `PHPUnit\Util\Test#parseTestMethodAnnotation…
Browse files Browse the repository at this point in the history
…s()`

This method is used very often (10k+ times in a small test suite), so it
needs to be quite efficient, if possible.
  • Loading branch information
Ocramius authored and sebastianbergmann committed Sep 7, 2019
1 parent fe308f3 commit 878e34e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Util/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,14 @@ public static function getProvidedData(string $className, string $methodName): ?

public static function parseTestMethodAnnotations(string $className, ?string $methodName = ''): array
{
$registry = Registry::singleton();

if ($methodName !== null) {
try {
return [
'class' => Registry::singleton()
->forClassName($className)
'method' => $registry->forMethod($className, $methodName)
->symbolAnnotations(),
'method' => Registry::singleton()
->forMethod($className, $methodName)
'class' => $registry->forClassName($className)
->symbolAnnotations(),
];
} catch (Exception $methodNotFound) {
Expand All @@ -322,10 +322,9 @@ public static function parseTestMethodAnnotations(string $className, ?string $me
}

return [
'class' => Registry::singleton()
->forClassName($className)
->symbolAnnotations(),
'method' => null,
'class' => $registry->forClassName($className)
->symbolAnnotations(),
];
}

Expand Down

0 comments on commit 878e34e

Please sign in to comment.