laminas / laminas-stdlib

SPL extensions, array utilities, error handlers, and more
https://docs.laminas.dev/laminas-stdlib/
BSD 3-Clause "New" or "Revised" License
190 stars 40 forks source link

Stricter typehints matching doc block hints #32

Open carnage opened 3 years ago

carnage commented 3 years ago
Q A
Documentation no
Bugfix yes
BC Break no
New Feature no
RFC no
QA no

Description

Similar PR to: https://github.com/laminas/laminas-escaper/pull/23/files I started with the string wrapper namespace as an issue was raised against it.

Progressively adding more classes to this PR as time permits I've added typehints to every class where it seems sensible to do so, there are some which inherit/implement built-ins which don't declare the type hint and so opens up a bit of an issue to then add them, you may wish to merge some parts and not others so splitting allows for easier cherry-picking.

Only typehints which don't break bc have been added; eg ones which PHP will silently cast to when strict types = 0; notably callable type hints have not been added and some instances of iterable have been skipped where the previous behaviour was to throw an exception if it wasn't an iterable.

carnage commented 3 years ago

The test failures are indicating that some of these changes are in fact BC breaks; suggest I revert the changes that cause the tests to fail and we decide if they are wanted to go into a 4.0.x release at some point?

carnage commented 3 years ago

Have reverted the changes to the files which failed tests, rebased onto latest branch and retargeted against 3.7.x

Should be ready to go now