Skip to content

Require string-castable values in strtr() replacement pairs - #7124

Open
kamil-tekiela wants to merge 2 commits into
phpstan:2.3.xfrom
kamil-tekiela:strtr-replace-pairs-castable
Open

kamil-tekiela wants to merge 2 commits into
phpstan:2.3.xfrom
kamil-tekiela:strtr-replace-pairs-castable

Conversation

@kamil-tekiela

Copy link
Copy Markdown
Contributor

Closes phpstan/phpstan#15800

🤖 Generated with Claude Code

kamil-tekiela and others added 2 commits November 22, 2026 14:34
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@staabm

staabm commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

There are already pre-existing rules for similar cases.
(ParameterCastableToStringRule, ImplodeParameterCastableToStringRule, SortParameterCastableToStringRule, maybe more)

I would need to check why its implemented in rules instead of signature files. I can't remember from the top of my head.

In case we can/want keep it in the signature files it needs to be in a bleeding edge file, because narrowing parameter types is a BC break

@VincentLanglet

Copy link
Copy Markdown
Contributor

There are already pre-existing rules for similar cases.

But the type stringAndStringable is also made for this case.

In case we can/want keep it in the signature files it needs to be in a bleeding edge file, because narrowing parameter types is a BC break

I'm not sure about this point given the fact even when the type was introduce/use it wasn't behing bleeding edge.
670d04d

This feels more like a fix to me...

@staabm

staabm commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

just checked back with ondrej. it needs to be bleeding edge

it’s introducing new errors, it’s narrowing parameter types → bleeding edge

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.

Check that strtr() replacement values are castable to string

3 participants