Skip to content

Move away from using static function variables to cache instances in classes with type hierarchies #571

@TysonAndre

Description

@TysonAndre

This causes weird, hard to debug issues when trying to modify Type::make. The same issue also affects NativeType::instance().

Related bug on php.net: https://bugs.php.net/bug.php?id=73872
Also see https://3v4l.org/dt9bg

If there is a method that uses static variables, then there are multiple solutions

  • Redeclare the method (or caching portion of this method) in each subclass and link to the bugs
  • Use a protected/private static variable ( array mapping (possibly type) and fully qualified name to the signature)
    Or use a public static variable(array), redeclared in each subclass, accessed with static::$map

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