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

feat: Enable symbol importing in @PhpCsFixer ruleset #7629

Conversation

Wirone
Copy link
Member

@Wirone Wirone commented Dec 27, 2023

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.

@Wirone Wirone added the topic/fqcn Fully Qualified Class Name usage and conversions label Dec 27, 2023
@Wirone Wirone requested a review from keradus December 27, 2023 01:38
@Wirone Wirone self-assigned this Dec 27, 2023
@Wirone
Copy link
Member Author

Wirone commented Dec 27, 2023

@nicolas-grekas are you interested in importing FQCNs in @Symfony ruleset? Then I can move the configuration and @PhpCsFixer will inherit it 🙂.

@coveralls
Copy link

coveralls commented Dec 27, 2023

Coverage Status

coverage: 94.774% (+0.001%) from 94.773%
when pulling a67266d on Wirone:codito/enable-fqcn-importing-in-internal-ruleset
into f6f9b7f on PHP-CS-Fixer:master.

@nicolas-grekas
Copy link

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.
Let's not for now, then run the rule on the codebase so we can consider what we want.

@Wirone
Copy link
Member Author

Wirone commented Dec 27, 2023

Rule is already available, you just need to run Fixer with --rules='{"fully_qualified_strict_types":{"import_symbols":true}}" to verify the range of changes 🙂.

@Wirone Wirone force-pushed the codito/enable-fqcn-importing-in-internal-ruleset branch from c5dc561 to 929c850 Compare December 29, 2023 00:38
@Wirone Wirone marked this pull request as ready for review December 29, 2023 00:41
Comment on lines +58 to +60
'fully_qualified_strict_types' => [
'import_symbols' => true,
],
Copy link
Member

@keradus keradus Dec 29, 2023

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

@keradus keradus changed the title DX: Enable symbol importing in @PhpCsFixer ruleset feat: Enable symbol importing in @PhpCsFixer ruleset Dec 29, 2023
@@ -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']) {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦🏻 with split-view, I misseen the check as it was visually broken to line above 🤦🏻

Screenshot 2023-12-30 at 01 18 08

@@ -30,6 +30,72 @@
use PhpCsFixer\PhpunitConstraintIsIdenticalString\Constraint\IsIdenticalString;
use PhpCsFixer\Preg;
use PhpCsFixer\StdinFileInfo;
use PhpCsFixer\Tests\Fixer\ClassNotation\ClassAttributesSeparationFixerTest;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yey 😅

@Wirone Wirone force-pushed the codito/enable-fqcn-importing-in-internal-ruleset branch from 929c850 to a67266d Compare December 29, 2023 21:48
@Wirone Wirone enabled auto-merge (squash) December 29, 2023 21:48
@Wirone Wirone merged commit adaea49 into PHP-CS-Fixer:master Dec 29, 2023
26 checks passed
@Wirone Wirone deleted the codito/enable-fqcn-importing-in-internal-ruleset branch December 29, 2023 22:03
danog pushed a commit to zoonru/PHP-CS-Fixer that referenced this pull request Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/fqcn Fully Qualified Class Name usage and conversions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants