Skip to content

"Cannot instantiate" from|trait|abstract class from #9675

Closed
@PhilETaylor

Description

@PhilETaylor

Description

Im sorry but I cannot replicate this on demand. I cannot give you a test case and the details I have are very vague.

Basically, when trying to instantiate a concrete class (in production, which might mean this is when opcache is ramped up, or other caching in place), PHP will randomly throw an exception with the message in the format of the following - note this is the FULL message, the actual class is not mentioned and the message appears to be truncated.

"Cannot instantiate interface from"

"Cannot instantiate abstract class from"

"Cannot instantiate trait from"

The code for this appears to be somewhere near

static zend_always_inline zend_result _object_and_properties_init(zval *arg, zend_class_entry *class_type, HashTable *properties) /* {{{ */

Full details were first discovered when running Symfony in PHP 8.2 rc 2 in production (I know I know but someone has to lead :))

symfony/symfony#47653

A further report was then made by @julienchey in Monolog with PHP 8.1.0

Seldaek/monolog#1765

// Tagging @stof @mfn

PHP Version

Observed in 8.1.0/8.2.0rc2/8.2.0rc3

Operating System

Alpine Docker Container

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions