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

False positive when converting to native enums #355

Open
atymic opened this issue Feb 18, 2024 · 2 comments · May be fixed by #356
Open

False positive when converting to native enums #355

atymic opened this issue Feb 18, 2024 · 2 comments · May be fixed by #356
Labels

Comments

@atymic
Copy link
Contributor

atymic commented Feb 18, 2024

For some reason the rector rule is catching random bits of unrelated code, for example the below sample.
It seems to be a bit random, will attempt to debug further to figure out why, by have narrowed it down to \BenSampo\Enum\Rector\ToNativeRector::inConfiguredClasses returning true when it should not.

    ---------- begin diff ----------
@@ @@
     {
         $jwtHeader = explode(' ', $request->header('authorization', ''));

-        abort_if(empty($jwtHeader) || count($jwtHeader) !== 2, 400);
+        abort_if((empty($jwtHeader))->value || count($jwtHeader) !== 2, 400);

         $jwt = $jwtHeader[1];
    ----------- end diff -----------

Applied rules:
 * ToNativeUsagesRector

Screen Shot 2024-02-18 at 18 09 00@2x

@atymic
Copy link
Contributor Author

atymic commented Feb 18, 2024

Okay, digging deeper it seems like somehow NeverType is a subtype of my class according to the AST?
I unfortunately don't think I have enough knowledge in this area to debug haha.

Screen Shot 2024-02-18 at 18 19 13@2x

spawnia added a commit that referenced this issue Mar 5, 2024
@spawnia spawnia linked a pull request Mar 5, 2024 that will close this issue
3 tasks
@spawnia spawnia added the bug label Mar 5, 2024
@spawnia
Copy link
Collaborator

spawnia commented Mar 5, 2024

Can you try if #355 fixes the issue?

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