Skip to content

Readonly SplObjectStorage array assignment error #13856

@cs278

Description

@cs278

Bug report

private readonly \SplObjectStorage $store;

public function __construct()
{
    $this->store = new \SplObjectStorage();
    $this->store[(object) ['foo' => 'bar']] = true;
}

Results in:

Readonly property foo::$store is already assigned.

Seems to be related/similar to: #8929

Code snippet that reproduces the problem

https://phpstan.org/r/ce3b5b97-2dfd-403e-8be0-1c8d38e0cf87

Expected output

No error

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions