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

Fix patchConstant when the user does not specify $class_method #251

Merged
merged 1 commit into from
May 26, 2018

Conversation

e98cuenc
Copy link
Contributor

@e98cuenc e98cuenc commented May 8, 2018

When a user calls patchConstant without the argument $class_method the docs explain the constant will changed everywhere.

However, the code will store in $patches_to_apply[$constant] the result of strtolower($class_name) ==> strtolower(null) ==> "". When we check if we have to return the patched value we will always return false, as we check with isset the variable $patches_to_apply[$constant] (this will always be true) and when we proceed to check the value of $patches_to_apply[$constant] (the empty string) with the current class it always fails the test.

The end result is that a call to patchConstant('FOO', 1); never changes the constant FOO.

When a user calls patchConstant without the argument $class_method the docs explain the constant will changed everywhere.

However, the code will store in $patches_to_apply[$constant] the result of strtolower($class_name) ==> strtolower(null) ==> "". When we check if we have to return the patched value we will always return false, as we check with `isset` the variable $patches_to_apply[$constant] (this will always be true) and when we proceed to check the value of $patches_to_apply[$constant] (the empty string) with the current class it always fails the test.

The end result is that a call to patchConstant('FOO', 1); never changes the constant FOO.
@kenjis kenjis merged commit c88543c into kenjis:master May 26, 2018
@kenjis
Copy link
Owner

kenjis commented May 26, 2018

@e98cuenc Thank you for your PR!

@e98cuenc e98cuenc deleted the fix-patch-constant branch May 26, 2018 12:30
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.

None yet

2 participants