Skip to content

polymorphic string based checks #1330

@exussum12

Description

@exussum12

I'm not sure if this is an error, as the code should check in a better way but I have come across the following

https://phpstan.org/r/051b7ab22cbb5241e32200e723a0bf3c

This should use instanceof ideally which resolves the issue, just wondering if code like this should also verify ?

Using something like

switch ($object->getType()) {
     case something::class :
}

vs

switch (true) {
     case $object instanceof something :
}

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