zendframework / zend-form

Form component from Zend Framework
BSD 3-Clause "New" or "Revised" License
69 stars 87 forks source link

Allow usage with zend-hydrator v3 #224

Closed weierophinney closed 5 years ago

weierophinney commented 5 years ago

This patch provides compatibility with zend-hydrator v3, while retaining compatibility with versions 1 and 2.

The primary change that affects this package is that the default shipped hydrators were given the suffix Hydrator. The original still exist, but emit deprecation notices when used.

The Fieldset class is the only one in the source library that references a specific hydrator. That reference was changed to check if the v3 variant exists, using that when found and the v1/v2 variant otherwise. Additionally, due to the stricter typehints in zend-hydrator v3, a check was necessary within bindValues() for a populated $object property prior to attemting hydration.

The bulk of the effort was getting the tests to pass with both versions, as the deprecation notices can prevent test passage when v3 is installed. All tests were updated to vary hydrator usage based on zend-hydrator version installed. In a number of cases, test assets were duplicated when varying was impossible to perform programmatically; for these cases, I provided autoload-dev rules that perform class aliases.