Sloppy parameter handling of some reflection methods
| From: | Christoph M. Becker | Date: | Mon, 28 Oct 2019 15:15:40 +0000 |
| Subject: | Sloppy parameter handling of some reflection methods | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-107723@lists.php.net to get a copy of this message | ||
Hi,
while working on the arginfo stubs for ext/reflection, I've noticed that
several methods do very sloppy parameter handling, if called for static
properties/methods. ReflectionMethod::getClosure(),
ReflectionProperty::getValue() and ::isInitialized() don't do any
parameter checks at all, while ReflectionProperty::setValue() accepts
arbitrary zvals as first parameter, and simply ignores the argument.
If we wanted to be extra strict, we could do zpp_none() checks for the
first three methods, and only accept a $value argument for the fourth.
For BC reasons as well as simplifying code which deals with non-static
properties/methods as well, we could also support an optional NULL, and
maybe even an (arbitrary) object of the respective type.
Thoughts?
Thanks,
Christoph