Re: Strict type declarations not enforced for Reflection API invocation
| From: | Christoph M. Becker | Date: | Tue, 10 Oct 2017 14:57:50 +0000 |
| Subject: | Re: Strict type declarations not enforced for Reflection API invocation | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100854@lists.php.net to get a copy of this message | ||
On 10.10.2017 at 15:41, Sebastian Bergmann wrote:
> I consider this a serious bug that leads to unexpected, confusing problems
> such as
>
> https://github.com/sebastianbergmann/phpunit/issues/2796#issuecomment-335180273.
>
> I understand Nikita's point of view (see
> https://github.com/php/php-src/pull/2837#issuecomment-335405067úëK—„TÈ“®tŒ
> ÃB) that
> changing this behavior (aka. fixing this bug) can be considered a
> "non-trivial backwards compatibility break". Therefore I would like to
> bring this issue to the attention of this list with this mail.
This is most certainly not an *implementation* bug. The RFC which
introduced strict typing[1] states:
| By default, all PHP files are in weak type-checking mode.
And later:
| This proposal takes the standpoint that it's up to the caller to
| decide how functions should be called.
| […]
| Therefore, this proposal does not allow internal developers to
| “opt-in� to strict typing.
In case of bug #75345 the caller is a method of ReflectionFunction,
which is defined in weak type-checking mode.
One may argue that this is a *design* bug, but after nearly two years of
PHP 7 there may be a lots of code relying on the current behavior, so in
my opinion changing the behavior could not really be regarded as fixing
a bug.
[1] <https://wiki.php.net/rfc/scalar_type_hints_v5>
--
Christoph M. Becker