Skip to content

Only rewrite strings as ::class on an exact class-name match - #48

Open
edalzell wants to merge 1 commit into
Stillat:masterfrom
edalzell:fix/case-sensitive-class-fetch
Open

edalzell wants to merge 1 commit into
Stillat:masterfrom
edalzell:fix/case-sensitive-class-fetch

Conversation

@edalzell

Copy link
Copy Markdown
Collaborator

TypeWriter::write() rewrites any string as \Foo::class when class_exists() is true, but that check is case-insensitive. With phpredis or the Redis facade alias loaded, 'driver' => 'redis' is written as 'driver' => \redis::class.

The guard now also requires the string to equal ReflectionClass::getName() (ignoring a leading backslash), so only exact class names become ::class and 'redis' stays a string.

Closes #47

@edalzell
edalzell force-pushed the fix/case-sensitive-class-fetch branch from f650162 to fa3d8f9 Compare October 20, 2026 21:29
@edalzell
edalzell force-pushed the fix/case-sensitive-class-fetch branch from fa3d8f9 to 206c601 Compare October 20, 2026 21:29
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.

TypeWriter rewrites class-like strings as ::class case-insensitively

1 participant