Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Class methods hydrator skips getters with optional parameters #4496

Conversation

Ocramius
Copy link
Member

Currently, Zend\Stdlib\Hydrator\ClassMethods skips getters like getFoo($bar = null) as they have >0 parameters.

This hotfix allows to call those methods as long as all parameters are optional.

@Ocramius
Copy link
Member Author

Travis failed because of some filesystem tests

*/
public function filter($property)
{
try {
Copy link
Member Author

Choose a reason for hiding this comment

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

In theory, this result could be cached in a private static property since the result depends only on reflection.

Copy link
Member

Choose a reason for hiding this comment

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

So... do you want me to wait to merge until you've done that improvement as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do it tomorrow then - otherwise fine? :)

Copy link
Member

Choose a reason for hiding this comment

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

Overall, looks good! I think caching the value makes sense, though, and would like to see that in.

@@ -30,6 +30,11 @@ class ClassMethods extends AbstractHydrator implements HydratorOptionsInterface
protected $underscoreSeparatedKeys = true;

/**
* @var \Zend\Stdlib\Hydrator\Filter\FilterInterface
*/
private $callableMethodFilter;
Copy link
Member

Choose a reason for hiding this comment

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

Why private?

@ghost ghost assigned weierophinney May 24, 2013
@weierophinney weierophinney merged commit 41f4b98 into zendframework:master May 24, 2013
weierophinney added a commit that referenced this pull request May 24, 2013
…optional-parameters

Class methods hydrator skips getters with optional parameters
weierophinney added a commit that referenced this pull request May 24, 2013
weierophinney added a commit that referenced this pull request May 24, 2013
weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015
…fix/class-methods-hydrator-optional-parameters

Class methods hydrator skips getters with optional parameters
weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants