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

#112 - class keyword fixer #128

Merged
merged 4 commits into from
Jul 30, 2024
Merged

#112 - class keyword fixer #128

merged 4 commits into from
Jul 30, 2024

Conversation

kamilpiech97
Copy link
Member

Should close #112.

Before:

class TestException extends \Exception
{
    protected string $var = "Error";
    protected string $class = "\Error";
    protected string $laravel = "LaravelPaths";
    protected string $bar = "\PhpCsFixer\Tokenizer\Tokens";
    protected string $foo = "PhpCsFixer\Tokenizer\Tokens";
    protected string $faz = "\Tokens";

    public function rules(\Blumilk\Codestyle\Configuration\Defaults\CommonRules $rules): void
    {
        echo 123;
    }

    public function test(): void
    {
        $foo = 'Blumilk\Codestyle\Configuration\Defaults\Paths';
        $baz = "\Exception";
        $fuz = "Exception";
    }
}

After:

declare(strict_types=1);

use Blumilk\Codestyle\Configuration\Defaults\CommonRules;

class TestException extends Exception
{
    protected string $var = "Error";
    protected string $class = \Error::class;
    protected string $laravel = "LaravelPaths";
    protected string $bar = \PhpCsFixer\Tokenizer\Tokens::class;
    protected string $foo = \PhpCsFixer\Tokenizer\Tokens::class;
    protected string $faz = "\Tokens";

    public function rules(CommonRules $rules): void
    {
        echo 123;
    }

    public function test(): void
    {
        $foo = \Blumilk\Codestyle\Configuration\Defaults\Paths::class;
        $baz = \Exception::class;
        $fuz = "Exception";
    }
}

tests/fixtures/classesImport/expected.php Outdated Show resolved Hide resolved
src/Fixers/ClassKeywordFixer.php Outdated Show resolved Hide resolved
src/Fixers/ClassKeywordFixer.php Outdated Show resolved Hide resolved
src/Fixers/ClassKeywordFixer.php Outdated Show resolved Hide resolved
@kamilpiech97 kamilpiech97 merged commit a1acc0d into main Jul 30, 2024
3 checks passed
@kamilpiech97 kamilpiech97 deleted the #112-class-keyword-fixer branch July 30, 2024 12:03
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 this pull request may close these issues.

Codestyle wrongly assumes some strings are classes
3 participants