Couldn't find any other issue mentioning it. If interested i could make a pull request. There are multiple tools to achieve this:
https://github.com/nilportugues/php-backslasher
https://github.com/Roave/FunctionFQNReplacer
https://github.com/kelunik/fqn-check
https://github.com/FriendsOfPHP/PHP-CS-Fixer (native_function_invocation )
I'm personally not convinced this is a good approach, it makes code much harder to read... I'd be +1 only if there is noticeable speedup at runtime which I doubt this would bring. 😕
@Majkl578 a better approach is to import them via use function foo; - simple and same effects.
If we want to do this, we can use SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions for CS enforcement, but it currently sees no difference between \ and use function - if we only want one (use function), we need to extend it a bit.
Also be aware that this approach could easily end up with 20+ use statements for functions (typically collapsed by IDE, but still).
Not worried by amount of imports: better than inline diffs by far, plus we
can grep it if we ever need to get rid of something bad coming from core.
On 1 Jan 2018 23:44, "Michael Moravec" notifications@github.com wrote:
If we want to do this, we can use SlevomatCodingStandard.Namespaces.
FullyQualifiedGlobalFunctions
https://github.com/slevomat/coding-standard#slevomatcodingstandardnamespacesfullyqualifiedglobalconstants
for CS enforcement, but it currently sees no difference between \ and use
function - if we only want one (use function), we need to extend it a bit.
Also be aware that this approach could easily end up with 20+ use
statements for functions (typically collapsed by IDE, but still).—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/6807#issuecomment-354682318,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakMvRqbMXJaSeZ0lWNQ1kimM1rWGmks5tGV_ggaJpZM4QPTFv
.
~Provided CS sniff extension for enforcing use function/use const in slevomat/coding-standard#235.~ (_moved to https://github.com/slevomat/coding-standard/issues/236_) I guess it now depends on IDE (PhpStorm assumed) how clever it would be when handling this. Will try later and eventually propose this for doctrine/coding-standard.
Checked PhpStorm, looks it can handle it as fine as classes.

I prepared this in https://github.com/doctrine/coding-standard/commit/15968c3495c4a5268edd2bd9bceb9264f67b1620, example of how noisy it'd be is here: https://github.com/Majkl578/doctrine2/commit/2b69bd95941308539b43fcbcaae9a272666c4233
I also tested PHP with VLD with multiple scenarios and didn't find any drawback of using use rather than \ - functions were correctly inlined and/or specialized to custom opcodes, even aliased ones. https://3v4l.org/YiCjS/vld#output
This has already been done in master. :)
Most helpful comment
@Majkl578 a better approach is to import them via
use function foo;- simple and same effects.