On Sat, Apr 29, 2017 at 10:24 PM, Sara Golemon <poll...@php.net> wrote:

> Spinning off a sub-thread:  Does anyone know any particular reason why
> ZEND_ARG_TYPE_INFO is not (barring two windows specific functions in
> standard) used anywhere in core?
>
> Is it?
> 1. Nobody has done the grunt work since 7.0?
> 2. It breaks something? (should only impact reflection AIUI)
> 3. ???
>
> I'd be happy to put in the grunt work on standard, hash, and intl at
> the very least.
>
> -Sara
>

There are a number of reasons why this hasn't happened yet:

1. In weak mode, arginfo type violations throw, while zpp violations warn
and return NULL. As such, adding arginfo types to existing functions is a
BC break.
2. For methods in particular, prior to PHP 7.2, adding arginfo types was
also a BC break. This is no longer the case, as variance is now respected.
3. Arginfo types for internal functions are enforced by the runtime.
Because the types are already checked by zpp, this is an unnecessary
duplicate check. Additionally, type-checking for internal functions is on
the slow-path (to the point there it uses a different opcode). While of
course this doesn't matter for some functions, in other cases type checking
/ parameter parsing is the main overhead of a function (which is why fast
zpp was introduced in the first place). I'm sure we do not want to have
decisions on whether to add or not add arginfo for a particular function
based on whether it would have a significant performance impact.

The solution to these problems is simple: Stop checking arginfo types for
internal functions, just use them for reflection / inheritance checks, but
leave the actual type-checking to zpp. However, this doing this will also
change current behavior due to point (1.), as in weak-mode some type errors
that are currently throwing would be reduced to warn + null. Personally I
don't have a problem with that, as I'd consider this a compatible change,
and it would make type-checking for internal functions consistent.

Nikita

Reply via email to