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

- importing FQCNs #109

Merged
merged 2 commits into from
Feb 12, 2024
Merged

- importing FQCNs #109

merged 2 commits into from
Feb 12, 2024

Conversation

krzysztofrewak
Copy link
Member

With this PR this code:

<?php

class TestException extends \Exception
{
    protected string $rules = "\Blumilk\Codestyle\Configuration\Defaults\LaravelPaths";

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

should be transformed into:

<?php

declare(strict_types=1);

use Blumilk\Codestyle\Configuration\Defaults\CommonRules;
use Blumilk\Codestyle\Configuration\Defaults\LaravelPaths;

class TestException extends Exception
{
    protected string $rules = LaravelPaths::class;

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

So:

  • all imports should be imported in import section
  • all hardcoded class names should be transformed to FQCNs and imported as well

Additionally:

  • deprecated CurlyBracesPositionFixer was replaced with BracesPositionFixer
  • deprecated NewWithBracesFixer was replaced with NewWithParenthesesFixer
  • deprecated CompactNullableTypehintFixer was replaced with CompactNullableTypeDeclarationFixer

For now it won't pass test cases, as priority of one of new fixers is wrong. We need to wait until PHP-CS-Fixer/PHP-CS-Fixer#7767 would be merged.

@krzysztofrewak krzysztofrewak marked this pull request as ready for review February 5, 2024 12:52
@krzysztofrewak krzysztofrewak merged commit 4c5bf75 into main Feb 12, 2024
4 checks passed
@krzysztofrewak krzysztofrewak deleted the fqcns branch February 12, 2024 14:55
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.

None yet

3 participants