Skip to content

Undefined type with combination of class_alias and namespace #3556

@fapdash

Description

@fapdash

Describe the bug

We're having issues with a class_alias in the Moodle code base.
\moodle_exception gets defined as an alias without namespace, but Intelephense can't resolve the type ([P1009])

To Reproduce

This code snippet reproduces the problem:

<?php

namespace core\exception;

class moodle_exception {

}

class_alias(moodle_exception::class, \moodle_exception::class);

The \moodle_exception type gets resolved when I remove the namespace (line 3).

The snippet is a reduced example from the class in the Moodle code base that exhibits this problem: https://github.com/moodle/moodle/blob/5586d836a9a0b36308b3d73a2a00cd174c272115/public/lib/classes/exception/moodle_exception.php#L105-L108

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions