Skip to content
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

PHP8 Nullsafe operator triggers RequireImports.Symbol #49

Open
BenceSzalai opened this issue May 3, 2021 · 3 comments
Open

PHP8 Nullsafe operator triggers RequireImports.Symbol #49

BenceSzalai opened this issue May 3, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@BenceSzalai
Copy link

BenceSzalai commented May 3, 2021

I'm trying to use the PHP8 nullsafe operator but I'm getting an issue from PHP Code Sniffer as ImportDetection.Imports.RequireImports.Symbol.

So in the context of a class method this is fine:

$this->property;

but I get an issue for this:

$this?->property;

claiming Found unimported symbol 'property'.

The same is happening outside of a class method context too, when trying to access a property of an object using the ?-> operator.

This is happening with php_codesniffer v3.6.0 and phpcs-import-detection v1.3.1.

Please let me know if I'm doing something wrong or if you need more info from me!

@sirbrillig sirbrillig added the bug Something isn't working label May 3, 2021
@sirbrillig
Copy link
Owner

Thanks for the report! This is likely happening because the sniff is not aware of the nullsafe operator syntax in php 8. That can be fixed.

@underdpt
Copy link

underdpt commented Jun 9, 2021

I just opened this same bug (squizlabs/PHP_CodeSniffer#3374) on PHP CodeSniffer by mistake. Just linking here for reference.

@sirbrillig
Copy link
Owner

Thanks. Sorry I haven't had a chance to get to this yet. It's on my list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants