Skip to content

Interaction between anonymous classes, get_declared_classes(), and class wildcards (like redefine('*::__construct', ...)) #220

Description

@antecedent

#214 (comment):

... PHP 7.4 changed the behavior of anonymous classes with respect to get_declared_classes(). It seems that since 7.4.0, there are more conditions on an anonymous class being added to get_declared_classes() (i.e. to the list returned by this function). Specifically, it might not be added if it is never instantiated, even if it is in a file that was compiled. Therefore Patchwork's wildcards (like redefine('*::__construct', ...)) theoretically allow capturing anonymous classes across all supported PHP versions, but since PHP 7.4 this works unreliably.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions