Skip to content

class_alias breaks if class exists #336

Closed
@muglug

Description

@muglug

Bug report

Question Answer
Box version 3.8
PHP version 7.3.5
MacOs
Github Repo - https://github.com/vimeo/psalm

PHP Scoper slightly breaks this polyfill for JsonException.

It gets a class_alias appended (as expected), but that class_alias causes a warning when running on PHP 7.3 as PHP 7.3 includes the class.

\class_alias('_HumbugBoxc9de1eddd699\\JsonException', 'JsonException', \false);

I'm currently fixing it in Psalm's build with this hideous patch that wraps a class_exists check around the class_alias:

if (!\class_exists(\JsonException::class, false)) {
    \class_alias('_HumbugBox9de1eddd699\\JsonException', 'JsonException', \false);
}

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