Bug #71851 [Com]: SplObjectStorage incorrectly aliases offsetSet

From: Date: Fri, 18 Mar 2016 21:08:29 +0000
Subject: Bug #71851 [Com]: SplObjectStorage incorrectly aliases offsetSet
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199933@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71851&edit=1 ID: 71851 Comment by: jachimcoudenys at gmail dot com Reported by: tom at theanalogguy dot be Summary: SplObjectStorage incorrectly aliases offsetSet Status: Open Type: Bug Package: SPL related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: I've started to write a test case: https://github.com/coudenysj/php-src/commit/22c6e1daf516dead9f70dea0722f7e3aec69df0d Previous Comments: ------------------------------------------------------------------------ [2016-03-18 07:35:13] tom at theanalogguy dot be Description: ------------ When extending SplObjectObserver for a custom implementation of ::attach(), any calls to ::offsetSet() are forwarded to the SplObjectObserver::attach() instead of the custom implementation in the child class. Test script: https://3v4l.org/mXdWO This appears to affect all versions between 5.5.0 and 7.0.4 Test script: --------------- class Test extends \SplObjectStorage { /** * {@inheritDoc} */ public function attach($object, $data = null) { throw new \RuntimeException('this is a test'); } } $instance = new Test; $object = new \stdClass; $data = ['foo' => 'bar']; $instance[$object] = $data; Expected result: ---------------- A RuntimeException being thrown. Actual result: -------------- No RuntimeException was thrown. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71851&edit=1

« previous php.bugs (#199933) next »