-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat: Enable symbol importing in @PhpCsFixer
ruleset
#7629
feat: Enable symbol importing in @PhpCsFixer
ruleset
#7629
Conversation
@nicolas-grekas are you interested in importing FQCNs in |
Naively I'd say yes but on second thought we have symbols that are not imported on purpose and we should have very few occurrences that need an actual fix. |
Rule is already available, you just need to run Fixer with |
c5dc561
to
929c850
Compare
'fully_qualified_strict_types' => [ | ||
'import_symbols' => true, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, changing rule configuration is not DX, it's feat - it affects users of project who decided to follow our public ruleset.
changing .php-cs-fixer.dist.php
config is DX/chore
@PhpCsFixer
ruleset@PhpCsFixer
ruleset
@@ -86,7 +87,7 @@ public function listErrors(string $process, array $errors): void | |||
$this->output->writeln(''); | |||
$stackTrace = $e->getTrace(); | |||
foreach ($stackTrace as $trace) { | |||
if (isset($trace['class']) && \Symfony\Component\Console\Command\Command::class === $trace['class'] && 'run' === $trace['function']) { | |||
if (isset($trace['class']) && Command::class === $trace['class'] && 'run' === $trace['function']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you describe why we needed to add isset?
it was some warning in phpstan, or we changed the logic somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isset()
was already there, the only changes in this PR are: ruleset reconfiguration (manual) and applying CS fixes (automated). Here FQCN was shortened, nothing more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -30,6 +30,72 @@ | |||
use PhpCsFixer\PhpunitConstraintIsIdenticalString\Constraint\IsIdenticalString; | |||
use PhpCsFixer\Preg; | |||
use PhpCsFixer\StdinFileInfo; | |||
use PhpCsFixer\Tests\Fixer\ClassNotation\ClassAttributesSeparationFixerTest; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yey 😅
929c850
to
a67266d
Compare
In general I believe it should be enabled for our codebase, the only place where it produces large overhead is
tests/Test/AbstractFixerTestCase.php
but this list of tests should shrink in time so amount of imports will be reduced too.