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

Codestyle wrongly assumes some strings are classes #112

Closed
krzysztofrewak opened this issue Feb 21, 2024 · 5 comments · Fixed by #128
Closed

Codestyle wrongly assumes some strings are classes #112

krzysztofrewak opened this issue Feb 21, 2024 · 5 comments · Fixed by #128

Comments

@krzysztofrewak
Copy link
Member

krzysztofrewak commented Feb 21, 2024

In one of our projects Codestyle wants to change this:

        if (in_array($response->status(), $this->handleByInertia, true)) {
            return Inertia::render("Error", [
                "status" => $response->status(),
            ])
                ->toResponse($request)
                ->setStatusCode($response->status());
        }

into:

        if (in_array($response->status(), $this->handleByInertia, true)) {
            return Inertia::render(\Error::class, [
                "status" => $response->status(),
            ])
                ->toResponse($request)
                ->setStatusCode($response->status());
        }

And this makes no sense at all. Other example:

            ["name" => "Redis"],

into:

            ["name" => \Redis::class],

We should handle this somehow.

@kamilpiech97
Copy link
Member

I think, updating this if line with if in this fixer should help:

from:
if ($token->isGivenKind(T_CONSTANT_ENCAPSED_STRING))
to:
if ($token->isGivenKind(T_CONSTANT_ENCAPSED_STRING) && $token->getContent()[1] === "\\")

@krzysztofrewak
should we create our fixer or update in core?

@krzysztofrewak
Copy link
Member Author

@kamilpiech97, you can try to open pull request in CS Fixer directly.

@krzysztofrewak
Copy link
Member Author

@kamilpiech97, any updates?

@kamilpiech97
Copy link
Member

kamilpiech97 commented Jul 2, 2024

Opened PR, we will see.
@krzysztofrewak

@krzysztofrewak
Copy link
Member Author

@kamilpiech97, looks like you need to implement it on your way here.

kamilpiech97 added a commit that referenced this issue Jul 22, 2024
kamilpiech97 added a commit that referenced this issue Jul 23, 2024
kamilpiech97 added a commit that referenced this issue Jul 23, 2024
kamilpiech97 added a commit that referenced this issue Jul 30, 2024
* #112 - feat: added own class keyword fixer

* #112 - fix: csf

* #112 - fix: cdoe review fix

* #112 - fix: code review fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants