ObjectProperty Hydrator should only hydrate public properties (fix + new test)

According to the docs, the Zend\Stdlib\Hydrator\ObjectProperty hydrator hydrates "Any data key matching a publicly accessible property will be hydrated; any public properties will be used for extraction."

No Test was found directly for this Hydrator and the Hydrator itself would attempt to set private or protected properties resulting in a fatal error. 
To this end, I have:
1. submitted the fix to only hydrate public properties
2. have created a test for the hydrator

I hope that this meets guidelines for this.
Yep, reflection = best. but slow?
On 27 Nov 2014 00:56, "Marco Pivetta" <notifications@github.com> wrote:

> In library/Zend/Stdlib/Hydrator/ObjectProperty.php:
>
> >          foreach ($data as $name => $value) {
> >              $property = $this->hydrateName($name, $data);
> > +
> > +            $privateProperty = $privatePropertyPrefix . $property;
> > +            $protectedProperty = $protectedPropertyPrefix . $property;
> > +
> > +            if (array_key_exists($privateProperty, $propertyList) || array_key_exists($protectedProperty, $propertyList)) {
>
> Then I would keep a cached copy of private and protected property names
> (the class inheritance position is not relevant), cache it locally in an
> array and check against that (prototype at http://3v4l.org/3dIkB):
>
> $this->privateProperties[$className] = array_map(    function () { return true; },    array_flip(array_unique(array_map(        function ($propertyName) { return preg_replace('/\\0.*\\0/', '', $propertyName); },        array_keys((array) $object)    ))));
>
> The safest solution is to use reflection, obviously, as you can't know if
> some private or protected properties were unset.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/zendframework/zf2/pull/6869/files#r20973584>.
>