Doc #71909 [Opn]: Incorrect Documentation for SplFixedArray::fromArray

From: Date: Tue, 29 Mar 2016 13:07:01 +0000
Subject: Doc #71909 [Opn]: Incorrect Documentation for SplFixedArray::fromArray
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13362@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71909&edit=1 ID: 71909 Updated by: krakjoe@php.net Reported by: public at grik dot net Summary: Incorrect Documentation for SplFixedArray::fromArray Status: Open Type: Documentation Problem Package: SPL related Operating System: MacOS PHP Version: 7.0.4 Block user comment: N Private report: N New Comment: Another problem with internal functions, is default values for arguments. I don't know how to fix it ... Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2016-03-29 10:28:10] krakjoe@php.net The documentation and declarations do not match. ------------------------------------------------------------------------ [2016-03-28 14:13:37] public at grik dot net Description: ------------ When extending the SplFixedArray overriding fromArray() method, PHP shows incorrect error text. The correct interface of a fromArray method is public static function fromArray($array, $save_indexes = true) without array typehint. Test script: --------------- class Collection extends \SplFixedArray { public static function fromArray(array $array, $save_indexes = true) { } } Collection::fromArray([]); Expected result: ---------------- no error Actual result: -------------- Warning: Declaration of Collection::fromArray(array $array, $save_indexes = true) should be compatible with SplFixedArray::fromArray($data, $save_indexes = NULL) in test.php on line 12 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71909&edit=1

« previous php.doc.bugs (#13362) next »