🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Optimize UnionType for cases in which all innerTypes are a constant string #15008

Description

@staabm

Feature request

when constructing a UnionType we should check all inner types and remember whether it only contains of constant string types.

these constant string types could than be put into a trie datastructure so searching for another constant string type in isSuperTypeOf/isSubTypeOf can be a very fast operation (similar to how a high performance router component in a MVC framework would search a catalog of all system known routes against the current request uri)

the trie datastructure should be represented as a separate class. when possible the trie datastructure could also be used to represent big lists of enum cases to match against a EnumCaseObjectType.

maybe it would even work for big unions of constant integers (with a Trie? with a different datastructure?) ?

maybe we can even do it for any finite type

if one extra null or something like that is in the union it should not defeat the optimization

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