Description
Type hints sometimes incorrectly include the namespace of the class they're from when they shouldn't.
For example: https://api.silverstripe.org/6/SilverStripe/Admin/AdminController.html#method_getRequiredPermissions
The markup for the typehint here is <abbr title="SilverStripe\Admin\array|string|false">array|string|false</abbr>
- you can see it has evaluated array
as SilverStripe\Admin\array
.
The source code for this is
https://github.com/silverstripe/silverstripe-admin/blob/eafa62e9ff167f4d5444b20867641f415be9b9f8/code/AdminController.php#L69
public static function getRequiredPermissions(): array|string|false
The namespace declaration in that class is namespace SilverStripe\Admin;
This seems to be happening because NodeVisitor::manageHint()
converts the typehint to a string (array|string|false
) from its array representation which had the types separated into individual type declarations.
Then NodeVisitor::resolvehint()
expects them to still be in the form of an array, but since they're not it goes "array|string|false
isn't a PHP type and isn't a FQCN so it must be a class name relative to the current namespace", resulting in SilverStripe\Admin\array|string|false
.