Bug #70606 [Opn]: The documented signature for SplObjectStorage methods is wrong

From: Date: Wed, 30 Sep 2015 14:21:17 +0000
Subject: Bug #70606 [Opn]: The documented signature for SplObjectStorage methods is wrong
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12792@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70606&edit=1 ID: 70606 User updated by: stof at notk dot org Reported by: stof at notk dot org Summary: The documented signature for SplObjectStorage methods is wrong Status: Open Type: Bug Package: Documentation problem Operating System: n/a PHP Version: 5.6.13 Block user comment: N Private report: N New Comment: Well, changing the source code would be a BC break, so it cannot be done in 5.x (and it would make it painful to write such code compatible with both 5.x and 7.x if it gets changed in 7.x btw). Previous Comments: ------------------------------------------------------------------------ [2015-09-30 11:51:22] salathe@php.net This is more a failing of the source code, which doesn't declare the argument type. I'd rather see this fixed there, than change the documentation. Would you be okay with changing this to a bug report for the SPL? ------------------------------------------------------------------------ [2015-09-30 10:16:07] stof at notk dot org Description: ------------ The documentation for the addAll, removeAll and removeAllExcept methods of the SplObjectStorage shows that the argument is typehinted as SplObjectStorage: http://php.net/manual/en/splobjectstorage.addall.php While this is true that they accept only SplObjectStorage instances, the methods are NOT typehinted, which cause issues when trying to overwrite them. We receive an error saying that the signature does not match, while we follow the documentation. I had to go read the C source code to understand the actual issue (and I think many people would not do it). https://github.com/php/php-src/blob/PHP-5.6/ext/spl/spl_observer.c#L972 https://github.com/php/php-src/blob/PHP-5.6/ext/spl/spl_observer.c#L940 Test script: --------------- <?php class MyObjectStorage extends SplObjectStorage { public function addAll(SplObjectStorage $object) {} } Actual result: -------------- T ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70606&edit=1

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