8000 Fix php notice by enumag · Pull Request #6330 · composer/composer · GitHub
[go: up one dir, main page]

Skip to content

Fix php notice #6330

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

Closed
wants to merge 1 commit into from
Closed

Fix php notice #6330

wants to merge 1 commit into from

Conversation

enumag
Copy link
Contributor
@enumag enumag commented Apr 6, 2017

Of course autoloading of an empty string should not actually happen (fixed that in twigphp/Twig#2438) but if it does happen it should not throw a php notice.

Notice: Uninitialized string offset 0

The notice is thrown few lines below beacause of $first = $class[0];.

@@ -369,6 +369,10 @@ public function findFile($class)

private function findFileWithExtension($class, $ext)
{
if (! $class) {
Copy link
Contributor
@curry684 curry684 Apr 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use typesafe comparisons, this may or may not (depending on PHP config) also reject class names "0" and "false". Also PSR mandates that the '!' operator has no space behind it. You should use "" === $class in this case.

See https://eval.in/769297 for examples of PHP's randomness in this.

@Seldaek
Copy link
Member
Seldaek commented Apr 6, 2017

IMO it's fine as is, as it's clearly only caused by bug in the calling code. This is no valid use case, and it adds a check that is otherwise not needed, to all autoload calls for all users of composer, forever. That's a lot of wasted cpu cycles :)

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

Successfully merging this pull request may close these issues.

3 participants
0