magento / magento/magento-coding-standard
Enforce import of global functions or using FQN calls
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 375
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
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:
1. Without import

2. with import

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-
```
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository files or tests are named. Start by locating the coding-standard rule configuration and checking the referenced Slevomat Namespaces rule; done means global functions are required to be imported or called by fully qualified name, with the repository's checks passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100