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

native_constant_invocation applies to catch section without variables #5684

Closed
BoShurik opened this issue May 5, 2021 · 5 comments · Fixed by #6264
Closed

native_constant_invocation applies to catch section without variables #5684

BoShurik opened this issue May 5, 2021 · 5 comments · Fixed by #6264
Labels

Comments

@BoShurik
Copy link

BoShurik commented May 5, 2021

Bug report

PHP 8.0.2
PHP CS Fixer 3.0.0

Code snippet that reproduces the problem

return (new PhpCsFixer\Config())
    ->setFinder($finder)
    ->setRules([
        'native_constant_invocation' => true,
    ])
;
try {
    $date = new \DateTime();
} catch (\Exception) {
}

Suggests

try {
    $date = new \DateTime();
} catch (Exception) {
}
@kubawerlos
Copy link
Contributor

@BoShurik can you take a look at the PR ☝🏼 (and maybe drop a review)?

@BoShurik
Copy link
Author

BoShurik commented May 5, 2021

@kubawerlos works for me

@niji-mneute
Copy link

niji-mneute commented Feb 4, 2022

The bug is still present in version 3.5.0

try {
    // ...
} catch (\InvalidArgumentException|\LogicException) {
    // ...
}

Suggests :

try {
    // ...
} catch (\InvalidArgumentException|LogicException) {
    // ...
}

@SpacePossum
Copy link
Contributor

thanks for reporting @niji-mneute , proposed fix is here #6264

SpacePossum added a commit that referenced this issue Feb 5, 2022
…itple exce… (SpacePossum)

This PR was squashed before being merged into the master branch (closes #6264).

Discussion
----------

TokensAnalyzer - fix isConstantInvocation detection for mulitple exce…

…ption types catch without variable

fixes #5684 (comment)

Commits
-------

eb1e3d5 TokensAnalyzer - fix isConstantInvocation detection for mulitple exce…
@benjaminmal
Copy link

I can confirm that #6264 fix #6271. Thank you @SpacePossum!

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