Skip to content

Pass a string key to Enum::isValidKey() in undiscoverable-symbols-2 - #15478

Open
gnutix wants to merge 1 commit into
phpstan:2.3.xfrom
gnutix:undiscoverable-symbols-2-isvalidkey-string
Open

gnutix wants to merge 1 commit into
phpstan:2.3.xfrom
gnutix:undiscoverable-symbols-2-isvalidkey-string

Conversation

@gnutix

@gnutix gnutix commented Oct 13, 2026

Copy link
Copy Markdown

Companion to phpstan/phpstan-src#5976, which checks static method calls through class-string unions. Merge both or neither.

EnumValidator calls $enumClass::isValidKey($value) with $enumClass typed class-string<ClabsEnum<int>>|class-string<ClabsEnum<string>> and $value typed int|string. That call was skipped before; now it's reported as Parameter #1 $key of static method MyCLabs\Enum\Enum<int>::isValidKey() expects string, int|string given., which is what a direct ClabsEnum::isValidKey($value) call reports too. The (string) cast keeps the behaviour identical: isValidKey() looks the key up in an array, and PHP normalises numeric-string keys to ints.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QW8VaDtn3cMdQowPSh1xGG

phpstan/phpstan-src#5976 checks static calls through class-string
unions, so $enumClass::isValidKey($value) with int|string $value is now
reported against the method's @PARAM string $key. Casting keeps the
lookup identical, since array keys normalise numeric strings to ints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QW8VaDtn3cMdQowPSh1xGG
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.

1 participant