Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently use (or don't use) FQCN functions #11985

Closed
kkmuffme opened this issue May 16, 2024 · 3 comments
Closed

Consistently use (or don't use) FQCN functions #11985

kkmuffme opened this issue May 16, 2024 · 3 comments

Comments

@kkmuffme
Copy link

Composer version 2.7.6 2024-05-04 23:03:15
PHP version 7.4.33 (/usr/bin/php)

(same with newer PHP versions)

e.g. composer/InstalledVersions.php uses FQCN for some but not all functions

\count(
\call_user_func_array(

but

$packages[] = array_keys(
return array_keys(array_flip(

There are a couple more.

@Seldaek
Copy link
Member

Seldaek commented May 21, 2024

Yes, that's because we only prefix those that get optimized by the PHP compiler using https://cs.symfony.com/doc/rules/function_notation/native_function_invocation.html 's compiler_optimized option.

The rest is useless visual noise IMO

@Seldaek Seldaek closed this as completed May 21, 2024
@kkmuffme
Copy link
Author

Nope, since the functions can just be overwritten without use statements:

namespace Composer;

function array_keys($arg) {};

This isn't very likely, but it's possible and leads to weird results if some of the overwritten functions are used while others are not.

@Seldaek
Copy link
Member

Seldaek commented May 22, 2024

Sure, if you can do that then you can also just run whatever code you want. I am not interested in protecting against people shooting themselves in the foot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants