Description
Symfony version(s) affected: 4.3.0
Description
When calling \TYPO3\CMS\Extbase\Reflection\PropertyInfo\Extractor\PhpDocExtractor::getTypes
with a class and a property name, the result of the combination of arguments is cached – which is fantastic – but when repeatedly calling getTypes
with the same class name but different property names (which is a common task), the type context is being generated from scratch for each property of the same class. Unfortunately, \phpDocumentor\Reflection\Types\ContextFactory::createForNamespace
is quite CPU intense. Not caching the generated context can and most likely will lead to a massive performance issues.
Fetching the type information more than once per class and property is unlikely however. Therefore I expect very few cache hits in \Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor::getDocBlock
.
How to reproduce
$propertyInfoExtractor = new PropertyInfoExtractor(
[],
[new PhpDocExtractor()]
);
$propertyInfoExtractor->getTypes('Foo\Bar\Baz\Class', 'foo');
$propertyInfoExtractor->getTypes('Foo\Bar\Baz\Class', 'bar');
$propertyInfoExtractor->getTypes('Foo\Bar\Baz\Class', 'baz');
...
The more property types of properties of the same class are evaluated, the more redundant type context objects are created.
Possible Solution
As mentioned before, the type contexts could be created and cached once per class.