Closed func0der closed 1 year ago
Might I suggest, that phpstan
is brought into this project also? It should have caught that mis-implementation at least in BaseInputFilter
:)
The result that I would wish for is, that the
InputFilterInterface
would type hintInputFilterInterface
andInputInterface
.
The problem was fixed with version 2.16.0:
https://github.com/laminas/laminas-inputfilter/blob/da425f72808aea54322b2fe5a23914f1763218fb/src/InputFilterInterface.php#L65-L71 https://github.com/laminas/laminas-inputfilter/blob/da425f72808aea54322b2fe5a23914f1763218fb/src/InputFilterInterface.php#L120-L128 https://github.com/laminas/laminas-inputfilter/blob/da425f72808aea54322b2fe5a23914f1763218fb/src/InputFilterInterface.php#L130-L138
And more:
closed this as not planned
Was "not planned" a miss click? :thinking: As this bug is fixed, isn't it?
That's just what the "close" button does on github nowadays 🤷
@func0der Better now? 😉
That's just what the "close" button does on github nowadays shrug
i need a facepalm reaction emoji :facepalm: :D
Bug Report
Summary
While
InputFilterInterface::add()
allowsInputInterface|InputFilterInterface|array|Traversable
to be added,InputFilterInterface::getInvalidInput()
andInputFilterInterface::getValidInput()
only returnInputInterface
to be returned.This leads to inconsistent behavior, because
InputFilterInterface
does not implementInputInterface
and would cause errors in instances where they are treated as equal (for example here: https://github.com/mvlabs/ze-content-validation/blob/master/src/Validator/ValidationResult.php#L68-L70).The included implementation of
InputFilterInterface
\Laminas\InputFilter\BaseInputFilter
does not comply to the interface itself either. It fills its propertiesBaseInputFilter::$validInputs
andBaseInputFilter::$invalidInputs
withInputInterface
andInputFilterInterface
alike and though only type hints@return InputInterface[]
onBaseInputFilter::getInvalidInputs()
andBaseInputFilter::getValidInputs()
.Current behavior
BaseInputFilter::getInvalidInputs()
andBaseInputFilter::getValidInputs()
returnInputFilterInterface
andInputFilter
alike.How to reproduce
This code is no beauty, but it shows the problem.
Expected behavior
This is not 100% clear, because I can not say, if the interface is right or the implementation.
The result that I would wish for is, that the
InputFilterInterface
would type hintInputFilterInterface
andInputInterface
.There are two ways of this problem at this point in time.
Either the output of
BaseInputFilter::getInvalidInputs()
andBaseInputFilter::getValidInputs()
is filtered before it is returned. This would result in a bugfix release with minimal impact on version numbers and people who follow interfaces.Since we are using PHP and PHP is just growing into following interfaces properly, there would probably be a lot of backlash from just filtering out the
InputFilterInterfaces
from the above mentioned results.If the interface was changed, there would need to be a new major release. This would be the cleanest way to deal with this problem.