Bug #71909 [Ver]: wrong error for SplFixedArray
Edit report at https://bugs.php.net/bug.php?id=71909&edit=1
ID: 71909
Updated by: nikic@php.net
Reported by: public at grik dot net
Summary: wrong error for SplFixedArray
Status: Verified
Type: Bug
Package: SPL related
Operating System: MacOS
PHP Version: 7.0.4
Block user comment: N
Private report: N
New Comment:
This should get fixed in PHP 8, as soon as stubs for SplFixedArray are added.
Previous Comments:
------------------------------------------------------------------------
[2018-06-16 17:34:19] nikic@php.net
@cmb: I believe since PHP 7.2 we can add type hints, as they may now be dropped in child classes.
However we should not start doing this across the board until such a time as types are no longer
checked for internal functions. Otherwise we'll be duplicating type-checks that zpp already
performs.
------------------------------------------------------------------------
[2018-06-16 17:13:25] cmb@php.net
This is not really a documentation issue, since
SplFixedArray::fromArray() indeed expects an array as first
argument[1]. The actual problem is that the arginfo is not yet
specific enough to reflect this[2]. As of PHP 7.0.0 a more
elaborate API is available[3], but it has been missed to apply it,
and for BC reasons we can't fix this for *methods* in a minor
release, so it'll have to wait for PHP 8. In my opinion, it would
be okay to improve the arginfo for *functions* for PHP 7.3,
though.
> Another problem with internal functions, is default values for
> arguments.
It seems to me that we should be able to add this information to
the arginfo.
[1] <https://github.com/php/php-src/blob/f2b4ec4bdc595773fb49b7d6ae8942c61f436288/ext/spl/spl_fixedarray.c#L675>
[2] <https://github.com/php/php-src/blob/f2b4ec4bdc595773fb49b7d6ae8942c61f436288/ext/spl/spl_fixedarray.c#L1045>
[3] <https://github.com/php/php-src/blob/PHP-7.0.0/Zend/zend_API.h#L104-L108>
------------------------------------------------------------------------
[2016-03-29 13:07:01] krakjoe@php.net
Another problem with internal functions, is default values for arguments.
I don't know how to fix it ...
------------------------------------------------------------------------
[2016-03-29 12:59:01] krakjoe@php.net
Agree, it's a general problem with internal functions, and their documentation.
I don't see that it can be solved by changing the arginfo though, that would surely break too
much code, wouldn't it ?
The only thing we can do in this, and similar cases, is update the documentation to reflect the
truth about the prototype, I think.
------------------------------------------------------------------------
[2016-03-29 11:08:33] dmitry@php.net
I'm not sure if this is a documentation problem for this function.
It's an inconsistent documentation for most internal functions.
Especially in this case, we expect "array" as first argument, but we don't have
"array" type hint.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=71909
--
Edit this bug report at https://bugs.php.net/bug.php?id=71909&edit=1
Thread (6 messages)