Using fully qualified function calls for PHP core functions can result in small performance gain (nanoseconds per call).
echo strlen('Hello World'); var_dump(null); var_dump(false); echo DIRECTORY_SEPARATOR; return true; // becomes: echo \strlen('Hello World'); \var_dump(\null); \var_dump(\false); echo \DIRECTORY_SEPARATOR; return \true;
Alternatively you can declare all PHP build in function used in the file like:
use function is_array;
For more details see:
I haven’t done a proper benchmark on TYPO3 project, but just to give a an estimation - we’re talking about gains around 0.1ms = 17k (PHP function calls on introduction package page rendering) * 0,006us gain.
Whole core should be migrated to new syntax. When backporting code to older branches slashes should be stripped.
- little performance gain
- makes code harder to read
- Symfony decided against introducing it
- existing benchmarks are very low level (testing function calls) no TYPO3 benchmarks were done, so the gain for real use case is unknown
- there is a workaround available - a composer plugin which automatically changes code in vendor, and other tools which converts the code automaticaly
- it might break some testing code (where namespaces were used for mocking global functions)
- don’t care (if somebody prepare a patch with FQN’s it will be merged as is, we will get mixed styling in the core)
- do not introduce FQN’s
- introduce FQN’s with additional
- introudce FQN’s by prepending every call with slash
Topic Initiator: Tymoteusz Motylewski
Topic Mentor: Tymoteusz Motylewski