Enforce import of global functions or using FQN calls #462
Description
Rule
Reason
I used code example from here
https://tideways.com/profiler/blog/compiler-optimized-php-functions
https://veewee.github.io/blog/optimizing-php-performance-by-fq-function-calls/
If we import or use FQN call for the global function php produces more optimized code.
Also visible via profilers:
SPX:
Same effect with blackfire:
Although the optimization might not be that significant for whole codebase it also helps to specify dependency via use statement.
It also might improve performance of some loops when checks like is_array
, ltrim
, preg_match
etc. are used as PHP would no more execute extra opcode INIT_NS_FCALL_BY_NAME
Also by import or FQN core function for setup:di:compile
code we might reduce magento compilation time by a few seconds.
Implementation
Can be taken from here: https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md#slevomatcodingstandardnamespacesreferenceusednamesonly-
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowFallbackGlobalFunctions" value="0" />
<property name="allowFallbackGlobalConstants" value="0" />
</properties>
</rule>