Skip to content

Fix bug identified on Shopware's Ci on TypePHP's end - #35

Merged
rcalicdan merged 1 commit into
mainfrom
quick-patch-8
Aug 18, 2026
Merged

Fix bug identified on Shopware's Ci on TypePHP's end#35
rcalicdan merged 1 commit into
mainfrom
quick-patch-8

Conversation

@rcalicdan

Copy link
Copy Markdown
Member

In PHP, constructors do not follow LSP and child classes often declare completely different constructor parameters than their parents.

Previously, ContractParser::resolveTargetParamName() used positional index fallback to map missing parameter docblocks from parent constructors to child constructors. In frameworks like Shopware, this caused parent constructor docblocks (e.g. @param array $parameters at index 1) to be incorrectly mapped onto child parameters (e.g. ?\Throwable $previousException at index 1), throwing false TypeError exceptions.

  • Disabled positional index fallback for __construct() methods in ContractParser.
  • Child constructors now only inherit docblocks from parent constructors if the parameter names match explicitly.
  • Normal methods continue to support positional renaming for LSP method overriding.

@rcalicdan
rcalicdan merged commit 8911a64 into main Aug 18, 2026
12 checks passed
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