zf1s / zf1

Monorepo of a fork of Zend Framework 1, with all components split into individual composer packages. PHP 5.3-8.3 compatible.
BSD 3-Clause "New" or "Revised" License
57 stars 22 forks source link

[zend-form] fix instantiating filters with options via `addFilter()` in php 8.0+ #194

Closed marcing closed 4 months ago

marcing commented 4 months ago

PHP 8.0+ changes behaviour of ReflectionClass::newInstanceArgs, which now assumes that an associative array is an array of named parameters, trying to match array keys to names of arguments in the constructor. This leads to errors in Zend_Form_Element::_loadFilter.

$this->addFilter('Boolean', array('type' => Zend_Filter_Boolean::PHP + Zend_Filter_Boolean::FALSE_STRING));
zend-form\library\Zend\Form\Element.php:2117
Error: Unknown named parameter $type

Zend_Form_Element::_loadFilter has to be altered in the same manner as _loadValidator to call newInstanceArgs only or numerical arrays and call newInstance on associative arrays.