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

Compiler optimized native function invocation incorrectly detected after nullsafe operator #5584

Closed
tpetry opened this issue Mar 31, 2021 · 2 comments · Fixed by #5586
Closed
Assignees
Labels

Comments

@tpetry
Copy link

tpetry commented Mar 31, 2021

Bug report

  • PHP version: 8.0.3
  • PHP CS Fixer version: 2.18.4-DEV
  • the configuration (file) you used:
return (new PhpCsFixer\Config())
    ->setFinder(
        PhpCsFixer\Finder::create()
            ->in(__DIR__)
            ->ignoreDotFiles(true)
            ->ignoreVCS(true)
    )
    ->setRules([
        '@Symfony:risky' => true,
    ]);

Code snippet that reproduces the problem

<?php

declare(strict_types=1);

namespace App;

$this->resource?->count();

What PHP-CS-Fixer is trying to do

  • Applied fixers: native_function_invocation
--- Original
+++ New
@@ @@
 
-$this->resource?->count();
+$this->resource?->\count();
@tpetry
Copy link
Author

tpetry commented Mar 31, 2021

The root cause of the bug is that currently the source code does not handle T_NULLSAFE_OBJECT_OPERATOR, presumably all places containing T_OBJECT_OPERATOR should be extended to include T_NULLSAFE_OBJECT_OPERATOR?

@kubawerlos kubawerlos self-assigned this Mar 31, 2021
@kubawerlos
Copy link
Contributor

I'm on it: #5586 (quite few fixers, so might not be today 😉).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants