-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typehints sometimes incorrectly prepend the current namespace #76
Comments
GuySartorelli
added a commit
to GuySartorelli/silverstripe-deprecation-checker
that referenced
this issue
Mar 19, 2025
- Work out types as best as we can - Ugly workaround for code-lts/doctum#76 - Don't rely on indexes for function comparison - Detect renamed params
This was referenced Mar 19, 2025
GuySartorelli
added a commit
to GuySartorelli/silverstripe-deprecation-checker
that referenced
this issue
Apr 2, 2025
- Work out types as best as we can - Ugly workaround for code-lts/doctum#76 - Don't rely on indexes for function comparison - Detect renamed params
GuySartorelli
added a commit
to GuySartorelli/silverstripe-deprecation-checker
that referenced
this issue
Apr 2, 2025
- Work out types as best as we can - Ugly workaround for code-lts/doctum#76 - Don't rely on indexes for function comparison - Detect renamed params
GuySartorelli
added a commit
to creative-commoners/deprecation-checker
that referenced
this issue
Apr 2, 2025
- Work out types as best as we can - Ugly workaround for code-lts/doctum#76 - Don't rely on indexes for function comparison - Detect renamed params
This was referenced Apr 2, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 evaluatedarray
asSilverStripe\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 inSilverStripe\Admin\array|string|false
.PR
The text was updated successfully, but these errors were encountered: