Bug #71909 [Opn->Ver]: wrong error for SplFixedArray
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: wrong error for SplFixedArray
-Status: Open
+Status: Verified
Type: Bug
Package: SPL related
Operating System: MacOS
PHP Version: 7.0.4
-Assigned To:
+Assigned To: krakjoe
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[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
Thread (6 messages)