10000 Fix file_exists warning when resolving with long strings by sbesselsen · Pull Request #130 · reactphp/promise · GitHub
[go: up one dir, main page]

Skip to content

Fix file_exists warning when resolving with long strings #130

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

Merged
merged 2 commits into from
Jan 7, 2019

Conversation

sbesselsen
Copy link

When resolving a promise with a long string, the following may happen:

  • method_exists is called
  • This triggers the class autoloader to check for a class by that name
  • The class autoloader will use file_exists to check for a file by that name
  • file_exists emits a warning: Warning: file_exists(): File name is longer than the maximum allowed path length on this platform ([...])

The method_exists() check only makes sense for objects, since further down the call $promiseOrValue->then(...) is made. Static then methods aren't supported anyway.

Copy link
Member
@clue clue left a comment

Choose a reason for hiding this comment

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

@sbesselsen Good catch, that's a nasty one! 🥇

Does it make sense to add a test for this? 👍

@WyriHaximus
Copy link
Member

@clue I think it makes sense to add a test. Not sure how we'd test this yet to be honest. But if @sbesselsen has an idea how to test this that would be great 👍

@jsor
Copy link
Member
jsor commented Dec 27, 2018

I'm also not sure how to test this. For me the patch is good as is. My only suggestion is to add a comment for the reasoning behind the is_object() check.

@sbesselsen
Copy link
Author

Hi all, thanks for the feedback. I've added a comment as requested.

I've also thought about a good way to test it; the one thing I could think of was to create a test setup where we have a class with a method "then", and run resolve() with that class name. We would expect that promise to then resolve with the class name, whereas before we would get a PHP error "Call to a member function then() on string". Does that sound like a good test? I'm unsure because it would require us to define a class in the test script just for that purpose, which seems... strange?

Copy link
Member
@WyriHaximus WyriHaximus left a comment

Choose a reason for hiding this comment

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

LGTM 👍 . And while I really like to have a test for this I see no reason to block this, we can do the test in a follow up PR and put this out there in the mean time.

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.

4 participants
0