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

DX: re-apply CS #53233

Merged
merged 1 commit into from Dec 30, 2023
Merged

DX: re-apply CS #53233

merged 1 commit into from Dec 30, 2023

Conversation

keradus
Copy link
Member

@keradus keradus commented Dec 27, 2023

Q A
Branch? 7.1
Bug fix? no
New feature? no
Deprecations? no
Issues Fix CS
License MIT

@carsonbot carsonbot added this to the 7.1 milestone Dec 27, 2023
@keradus keradus marked this pull request as draft December 27, 2023 11:54
@keradus keradus changed the title 7.1 cs DX: re-apply CS Dec 27, 2023
@@ -420,9 +420,9 @@ public function addArgument(string $name, int $mode = null, string $description
/**
* Adds an option.
Copy link
Member Author

Choose a reason for hiding this comment

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

overall, we got curious if phpdoc_align make sense on Fixer side, especially because of such cases like here. WDYT?
The version proposed by PR is one in-line with current CS rules.

Copy link
Member

Choose a reason for hiding this comment

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

I agree it might be better to not align those

Copy link
Member Author

@keradus keradus Dec 27, 2023

Choose a reason for hiding this comment

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

I would love to have conclusion that is "always align" or "never align".

If we say always, let's pay this little price of having this single case out of 100k phpdocs ugly. Maintaining exception and not letting tool to do it's job for single case is painful and preventing auto-apply of tool results.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think the current changes on this are improving the source. Consistency is nice, but this goes against readability here to me.
I understand you'd like a rule, so maybe we could just decide which length is too much to align? or say that complex types shouldn't trigger alignment?
we can revert these from the PR and discuss that separately if you don't want to other changes to wait for this to be resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

for 6k files in this repo, we have the rule not applied for TWO cases only. instead of making some special handling of this and implementing rule for exception, I would ask to get this applied. Let's be pragmatic here and avoid increasing rule complexity for such rare case.

Copy link
Member

Choose a reason for hiding this comment

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

we accept exceptions so it's fine have two cases that don't follow the rule
please revert the related changes in this PR and 🚀

Copy link
Member Author

Choose a reason for hiding this comment

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

It makes it tricky to apply the CS (and on long run, have CS always green) - because manually reverting the exceptions each time :(

reverting as requested

@@ -184,7 +184,7 @@ public function getClassLoader(): callable
public static function enable(): void
{
// Ensures we don't hit https://bugs.php.net/42098
class_exists(\Symfony\Component\ErrorHandler\ErrorHandler::class);
class_exists(ErrorHandler::class);
class_exists(\Psr\Log\LogLevel::class);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should also be imported, right?

Copy link
Member Author

@keradus keradus Dec 27, 2023

Choose a reason for hiding this comment

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

In this PR, I applied the fully_qualified_strict_types rule, which (with current config) simplifies usage of symbols.

If you want to import symbols, we can enable import_symbols.
Please decide if you would like to go this path as separated PR: #53244

@keradus
Copy link
Member Author

keradus commented Dec 29, 2023

(rebased due to fabbot.io request)

@nicolas-grekas
Copy link
Member

Thank you @keradus.

@nicolas-grekas nicolas-grekas merged commit f63c682 into symfony:7.1 Dec 30, 2023
2 of 9 checks passed
@keradus keradus deleted the 7.1_CS branch December 30, 2023 21:58
@@ -24,7 +24,7 @@ trait OidcTrait
{
private function createUser(array $claims): OidcUser
{
if (!\function_exists(\Symfony\Component\String\u::class)) {
if (!\function_exists(u::class)) {
Copy link
Member

Choose a reason for hiding this comment

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

we need the namespace to check for the existence of the function (fixed in 862c6fb)

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, let me convert it into bug report:
PHP-CS-Fixer/PHP-CS-Fixer#7652

Copy link
Member Author

@keradus keradus Jan 1, 2024

Choose a reason for hiding this comment

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

I find this very curious inconsistency on PHP engine side.

https://3v4l.org/qtBRn

Copy link
Member

Choose a reason for hiding this comment

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

deserves a bug report to php-src IMHO

Copy link
Member Author

@keradus keradus Jan 1, 2024

Choose a reason for hiding this comment

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

I see reason why PHP allows for that. For ::class, one can do whatever, like fooisufdhsilufgvhlaiuwrgfliudfzbhsdfbsdfb::class, and it's not evaluated if that foo..sth exists at all, therefore also not if it's a class or any other symbol like function.
It would need the compiler to already have execution context, or at least import all files... to analyse. IMHO doubtful to get in, but if you think otherwise and have better expertise on it, please consider to drive this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants