|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71851 SplObjectStorage incorrectly aliases offsetSet
Submitted: 2016-03-18 07:35 UTC Modified: -
From: tom at theanalogguy dot be Assigned:
Status: Open Package: SPL related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: tom at theanalogguy dot be
New email:
PHP Version: OS:


 [2016-03-18 07:35 UTC] tom at theanalogguy dot be
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:

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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-18 21:08 UTC] jachimcoudenys at gmail dot com
I've started to write a test case:
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Aug 09 09:01:24 2020 UTC