Closed arokettu closed 2 years ago
@arokettu would you be able to send a patch for this? 🤔
I can do it but I would like to discuss what is the real expected behavior here then. What's clear for me is that it's definitely not the current one.
My expectations came from reading the code that the wrappers that I register immediately after reset will replace the default list but now I think that the new wrapper should be added to the default ones. (in that case I will also have a feature request)
I wish I knew the original intent here: best we can do is look at any existing tests and docs for the feature
I haven't found any except for PHPDoc in the file that claims that resetRegisteredWrappers() should reset to the default list
then replacing
in_array($wrapper, static::$wrapperRegistry, true)
with
in_array($wrapper, static::getRegisteredWrappers(), true)
makes most sense to me
@marc-mabe I see that the component has been mostly designed by you: are you able to help out with some guidance?
getRegisteredWrappers should be used and the wrapperRegistry should not be used directly. The NULL value is a marker that the static class hasn't been initialized
Ok. #52
Thanks!
Bug Report
Summary
\Laminas\Stdlib\StringUtils::registerWrapper() generates a warning in PHP < 8.0, TypeError on PHP >= 8.0 if the current wrapper list is empty.
The scenario is broken since the
times immemorialintroduction of StringUtils in Zend 2.1Current behavior
in_array() expects parameter 2 to be array, null given
How to reproduce
Expected behavior
A single required wrapper is registered without warnings or exceptions