Skip to content

feat: Add StringableForToStringFixer#9218

Merged
keradus merged 3 commits intoPHP-CS-Fixer:masterfrom
santysisi:feat/add_stringable_for_to_string_fixer
Nov 28, 2025
Merged

feat: Add StringableForToStringFixer#9218
keradus merged 3 commits intoPHP-CS-Fixer:masterfrom
santysisi:feat/add_stringable_for_to_string_fixer

Conversation

@santysisi
Copy link
Copy Markdown
Contributor

This PR resolves #9186

I would like to mention that the majority of this code is part of an existing library php-cs-fixer-custom-fixers.
I also want to thank @kubawerlos as the original author of most of the code.

@santysisi santysisi force-pushed the feat/add_stringable_for_to_string_fixer branch from 61b610a to f82cd0b Compare November 25, 2025 01:20
@coveralls
Copy link
Copy Markdown

coveralls commented Nov 25, 2025

Coverage Status

coverage: 93.384% (+0.02%) from 93.361%
when pulling e612417 on santysisi:feat/add_stringable_for_to_string_fixer
into 4bb7f3e on PHP-CS-Fixer:master.

@santysisi
Copy link
Copy Markdown
Contributor Author

If the Symfony core team agrees, I think we can add this new rule to the SymfonySet

Co-authored-by: Kuba Werłos <werlos@gmail.com>
@santysisi santysisi force-pushed the feat/add_stringable_for_to_string_fixer branch from f82cd0b to e4362dc Compare November 25, 2025 03:46
@keradus
Copy link
Copy Markdown
Member

keradus commented Nov 26, 2025

If the Symfony core team agrees,

check with them directly


public function isCandidate(Tokens $tokens): bool
{
return \PHP_VERSION_ID >= 80_000 && $tokens->isAllTokenKindsFound([\T_CLASS, \T_STRING]);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you applied the Fixer's changes blindly.

Suggested change
return \PHP_VERSION_ID >= 80_000 && $tokens->isAllTokenKindsFound([\T_CLASS, \T_STRING]);
return \PHP_VERSION_ID >= 8_00_00 && $tokens->isAllTokenKindsFound([\T_CLASS, \T_STRING]);

@keradus keradus requested a review from kubawerlos November 26, 2025 00:47
Copy link
Copy Markdown
Member

@keradus keradus left a comment

Choose a reason for hiding this comment

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

kudos for keeping the authorship in class annotation and git-commit

@kubawerlos , want to make the review? you know the initial state of the fixer

Copy link
Copy Markdown
Member

@keradus keradus left a comment

Choose a reason for hiding this comment

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

nice

@keradus keradus merged commit 2e09b82 into PHP-CS-Fixer:master Nov 28, 2025
32 checks passed
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.

New fixer StringableForToStringFixer

4 participants