ArrayAccess arg type in BaseInputFilter::validateInputs()

BaseInputFilter::$data property has null|array in DocBlock. Also in BaseInputFilter::setData() it makes sure that we initialize property with an array. But for some reason BaseInputFilter::validateInputs() in DocBlock we have array|ArrayAccess union for $data argument.
BaseInputFilter::validateInputs() is used internally in BaseInputFilter::isValid() and there we pass BaseInputFilter::$data as an argument that should be null|array.

The risk here is in case of child classes that pass ArrayAccess into BaseInputFilter::validateInputs(), then this piece of code will fail

            // If input is optional (not required), and value is not set, then ignore.
            if (! array_key_exists($name, $data)
                && ! $input->isRequired()
            ) {

Silently with wrong result of array_key_exists() if PHP’s error_reporting is turned off, otherwise app will throw deprecated warning. “PHP Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead”

Hello and welcome to our forums! :smiley:

Please create a unit test to illustrate the problem and send it as pull request to the repository if laminas-inputfilter. The test runs on GitHub with different PHP versions and can show the problem.

Thanks in advance! :+1:t3:

Done. ArrayAccess arg type in BaseInputFilter::validateInputs() by darckking · Pull Request #40 · laminas/laminas-inputfilter · GitHub