Repository navigation
Un-prefix Filter\ and PDO\ class name strings in the phar - #6512
Merged
Merged
Conversation
php-scoper prefixes namespaced string literals such as
`new ObjectType('Filter\FilterFailedException')` even when they name
internal PHP classes, so the phar reported
`_PHPStan_<sha>\Filter\FilterFailedException` and returned prefixed
`PDO\*` subclasses from `PDO::connect()`.
The namespaces un-prefixed by the patcher now live in
compiler/build/scoper-namespaces.php, shared with a test that fails when
src/ contains a class name string whose namespace is not handled.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SCH8hvECi7zaEUr1Get7sG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
php-scoper prefixes namespaced string literals such as
new ObjectType('Filter\FilterFailedException')even when they name internal PHP classes. The phpstorm-stubs are only consulted for real class references, not for strings, so updating them incompiler/boxdoes not help. As a result the phar reports_PHPStan_<sha>\Filter\FilterFailedExceptioninmissingType.checkedException, andPDO::connect()returns prefixedPDO\Mysql,PDO\Pgsql, … class names.FilterandPDOare added to the namespaces thesrc/patcher un-prefixes, next toBcMath,Dom,FFIandDs.compiler/build/scoper-namespaces.phptogether withexclude-namespaces, soScoperClassNameStringsTestcan fail wheneversrc/gains a class name string in a namespace that is neither excluded nor un-prefixed.Foobar\BuzinErrorFormatterTestCaseis covered by the generic patcher instead of its one-off.Verification: built the phar (
PHAR_CHECKSUM=1) before and after this change and diffed the extracted contents. OnlyFilterVarThrowTypeExtension.php(1 literal) andPDOConnectReturnTypeExtension.php(6 literals) differ, and the issue's snippet no longer reports the prefixed class.Split out of #6112. The
argument.invalidConstanterror from the same snippet is fixed in #6513.Closes phpstan/phpstan#15007
🤖 Generated with Claude Code
https://claude.ai/code/session_01SCH8hvECi7zaEUr1Get7sG