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

Allow accessing fields with a method of the same name #263

Open
wants to merge 1 commit into
base: 2.0.x
Choose a base branch
from

Conversation

tszymanek
Copy link

Running a matching over a criteria lead me to an error that I cannot access the field. I then discovered the run lacks checking the object for methods with the same name as the field has. I find it a common practice to ommit the get keyword in getter methods. Thus this PR

@malarzm
Copy link
Member

malarzm commented Jan 8, 2021

Just for the record: this has been previously proposed in #135 and #149

@@ -41,6 +41,10 @@ public static function getObjectFieldValue($object, string $field)
return $object[$field];
}

if (method_exists($object, $field)) {
Copy link
Member

Choose a reason for hiding this comment

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

method_exists also returns true if the method is not public.
https://3v4l.org/LAgYk

Copy link
Author

Choose a reason for hiding this comment

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

Exactly the same as it works without my changes

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