Repository navigation
Define DBAL 4's parameter type aliases in the Connection stub, and accept LockMode for the lock mode - #171
Merged
Conversation
…cept LockMode for the lock mode The DBAL 4 Connection stub used WrapperParameterTypeArray without declaring it. The stub replaces the class docblock where DBAL declares it, so Psalm read it as a class that doesn't exist and reported every $types argument. The stub now declares WrapperParameterType and WrapperParameterTypeArray as DBAL does. EntityRepository::find(), EntityManager::find() and refresh(), and EntityManagerInterface::find() and refresh() typed the lock mode as ?int. ORM 3 takes the DBAL 4 LockMode enum, so they now take LockMode|int|null. With DBAL before 4, LockMode is a class of int constants, and the int still matches. Fixes psalm#170 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
THanks! |
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.
Fixes #170.
Psalm 7.11 enables this plugin automatically for Doctrine projects. With v2.12.2 on DBAL 4 and ORM 3, two stub problems give false
InvalidArgumenterrors.WrapperParameterTypeArrayin the DBAL 4ConnectionstubThe stub uses
@phpstan-param WrapperParameterTypeArray $typesbut doesn't declare the alias. The stub replaces the class docblock where DBAL declares it, so Psalm reads it as the classDoctrine\DBAL\WrapperParameterTypeArray. Every$typesargument is reported.The stub now declares
WrapperParameterTypeandWrapperParameterTypeArrayas DBAL 4 does.The lock mode of
find()andrefresh()EntityRepository::find(),EntityManager::find()andrefresh(), andEntityManagerInterface::find()andrefresh()typed the lock mode as?int. ORM 3 takes the DBAL 4LockModeenum, sofind($id, LockMode::PESSIMISTIC_WRITE)was reported.They now take
LockMode|int|null, as ORM 3 declares. With DBAL before 4,LockModeis a class of int constants, so the existing int calls still match.Tests
Connection.feature: named and positional$typeson every query method that takes them, plus an invalid type that must still be reported. Gated to DBAL >= 4.All 22 new scenarios fail before the change. The suite passes locally:
phpcs and Psalm are clean.
🤖 Generated with Claude Code