Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refactor: implementsStringable when possible#62305

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
santysisi wants to merge1 commit intosymfony:8.0
base:8.0
Choose a base branch
Loading
fromsantysisi:refactor/add-stringable-interface-when-possible

Conversation

@santysisi
Copy link
Contributor

@santysisisantysisi commentedNov 4, 2025
edited
Loading

QA
Branch?8.0
Bug fix?no
New feature?yes
Deprecations?no
Issues-
LicenseMIT

Reference from thephp manual

From the manual: "TheStringable interface denotes a class as having a__toString() method. Unlike most interfaces,Stringable is implicitly present on any class that has the magic__toString() method defined, although it can andshould be declared explicitly."

I used the Rector ruleStringableForToStringRector

Therector.php file I used.

<?phpuseRector\Config\RectorConfig;useRector\Php80\Rector\Class_\StringableForToStringRector;return RectorConfig::configure()    ->withPaths([__DIR__ .'/src',    ])    ->withSkip([__DIR__ .'/src/*/Tests/*',    ])    ->withRules([        StringableForToStringRector::class,    ]);

Also, I want to mention that this change is allowed under theBackward Compatibility Promise.

@carsonbotcarsonbot added this to the8.0 milestoneNov 4, 2025
@carsonbotcarsonbot changed the titleRefactor: addStringable when possible Refactor: addStringable when possibleNov 4, 2025
@santysisisantysisi changed the title Refactor: addStringable when possible Refactor: implementsStringable when possibleNov 4, 2025
@santysisi
Copy link
ContributorAuthor

I targeted the 8.0 branch because I think we are in feature freeze.

So I think this change could be added (if you like it) for the 8.1 🤔

@santysisi
Copy link
ContributorAuthor

I think the errors aren't relevant and were resolved by thiscontribution.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

Overall I'm -0 on this: it's strictly equivalent - except the explicit casts which might hide bugs.

@alexandre-daubois
Copy link
Member

I'm not totally convinced either by this addition. Even though I never felt the need (or lack) of it, why not if it is recommended by the docs.

@OskarStark
Copy link
Contributor

I agree with@nicolas-grekas and@alexandre-daubois, the only thing I like is the readability and that you see directly that it is string able when reading the class

@derrabus
Copy link
Member

We have rejected PRs that only change code-style without being able to enfore the new style.

@santysisisantysisiforce-pushed therefactor/add-stringable-interface-when-possible branch from5ac5f7e toe16e36fCompareNovember 5, 2025 11:56
@santysisi
Copy link
ContributorAuthor

We have rejected PRs that only change code-style without being able to enfore the new style.

If you and the other core members agree with this change, I can try to add this rule (probably over the weekend) tophp-cs-fixer, since Symfony uses this tool.

@nicolas-grekas
Copy link
Member

That'd be fine to me yes, thanks for proposing !

santysisi reacted with heart emoji

@santysisi
Copy link
ContributorAuthor

Status: needs work
It's necessary being able to enfore the new style before merge

I will try to implement the new rule over this weekend

xabbuh and mtarld reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@welcoMatticwelcoMatticAwaiting requested review from welcoMatticwelcoMattic is a code owner

@kbondkbondAwaiting requested review from kbond

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

@jderussejderusseAwaiting requested review from jderussejderusse is a code owner

@alexandre-dauboisalexandre-dauboisAwaiting requested review from alexandre-dauboisalexandre-daubois is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

8.0

Development

Successfully merging this pull request may close these issues.

6 participants

@santysisi@alexandre-daubois@OskarStark@derrabus@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp