Skip to content

Could not get storage for stdclass #5099

@wildlyinaccurate

Description

@wildlyinaccurate

Hi there! I saw a couple of issues related to this: #2826 and #1016. My issue seems to be slightly different though - it happens when a property on a stdClass object is accessed more than once, and it only seems to happen with results from PDO:

<?php

$db = new PDO('');
$q = $db->prepare('');
$q->execute();
$o = $q->fetch(PDO::FETCH_OBJ);
$o && ($o->p || $o->p); // Uncaught InvalidArgumentException: Could not get class storage for stdclass

Here's the failing case on psalm.dev: https://psalm.dev/r/816787d4b3
Here's a passing case with only one $o->p access: https://psalm.dev/r/1918607874
Here's a similar chunk of code using a plain stdClass constructor: https://psalm.dev/r/0d6d9aae0a

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