Re: Deprecate ReflectionParameter::isArray() and friends
| From: | Nikita Popov | Date: | Tue, 03 Mar 2020 15:38:04 +0000 |
| Subject: | Re: Deprecate ReflectionParameter::isArray() and friends | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108830@lists.php.net to get a copy of this message | ||
On Tue, Feb 25, 2020 at 4:33 PM Nikita Popov <nikita.ppv@gmail.com> wrote:
> Hi internals,
>
> I've put up https://github.com/php/php-src/pull/5209 to
> deprecate the
> following reflection methods:
>
> * ReflectionParameter::isArray()
> * ReflectionParameter::isCallable()
> * ReflectionParameter::getClass()
>
> These APIs have been superseded by ReflectionParameter::getType() since
> PHP 7.0. Types introduced since that time are not available through the old
> APIs. The behavior of these methods becomes increasingly confusing with
> additional type system extensions. With the addition of union types in PHP
> 8:
>
> * isArray() will return true if the type is array or ?array, but not any
> other union type.
> * getClass() will return a ReflectionClass for T|int etc, as long as the
> union only contains a single type. T1|T2 will return null.
>
> There is really no reasonable behavior for these methods in the presence
> of union types; we should start phasing them out.
>
> One point I'm not sure about is whether we want to deprecate
> ReflectionParameter::allowsNull() as well. Logically this method belongs on
> ReflectionType (and does in fact exist there), but the way it is formulated
> is still compatible with union types, so leaving it alone is a possibility.
>
> Regards,
> Nikita
>
Any more feedback on this?
Nikita