-
Bug
-
Resolution: Fixed
-
Minor
-
3.3, 3.4
-
MOODLE_33_STABLE, MOODLE_34_STABLE
-
MOODLE_33_STABLE
-
MDL-59855-master -
In IntelliJ, the class resolution rules for type hints are identical to that of PHP compilation / execution. That means
- if the using class is not in a namespace, relative and absolute namespace resolution is identical.
- If the using class is in a namespace, all namespaces/classes are considered relative paths, starting at the current namespace,
- unless the to-be-resolved namespace starts with a backslash () (we've all been there, pondering about bugs because \stdClass is not the same as stdClass, unless, of course, it is, because we are outside a namespace... ugh.
)
IntelliJ assumes the same rules for interpreting types in PHPDoc as well. This causes problems in the new OAuth core libs. core\oauth2\api is namespaced (https://github.com/moodle/moodle/blob/1c6106e8a8dbeb95ce158e7013c226e033d0cb11/lib/classes/oauth2/api.php#L24) and provides type hints for its methods (parameter and return types), for example get_user_oauth_client(), https://github.com/moodle/moodle/blob/1c6106e8a8dbeb95ce158e7013c226e033d0cb11/lib/classes/oauth2/api.php#L317. The paths in those type hints (core\oauth2\client), however, are interpreted as relative paths, resulting effectively in e.g. \core\oauth2\core\oauth2\client.
Steps to reproduce:
Open lib/classes/oauth2/api.php in IntelliJ/PHPStorm and, after the full index is built, hover over the types. You will see the message "Undefined namespace oauth2".