Skip to content

[TypeDeclarationDocblocks] Skip keyed and direct property assigns in AddVarArrayDocblockFromDimFetchAssignRector - #8437

Open
TomasVotruba wants to merge 1 commit into
mainfrom
tv/var-dimfetch-skip-direct-assign
Open

[TypeDeclarationDocblocks] Skip keyed and direct property assigns in AddVarArrayDocblockFromDimFetchAssignRector#8437
TomasVotruba wants to merge 1 commit into
mainfrom
tv/var-dimfetch-skip-direct-assign

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

The rule inferred @var only from bare appends $this->prop[] = .... When the same property is also written with a keyed dim assign $this->prop['error'] = 'text' or a direct $this->prop = ..., those value types were ignored and the resulting @var was too narrow, rejecting them:

Property FileController::$response (array<array<string, string>>)
does not accept array<array<string, string>|string>.

Skip such properties instead. A new finder helper detects keyed/direct assigns; bare-append-only properties are unaffected.

…AddVarArrayDocblockFromDimFetchAssignRector

The rule inferred @var only from bare appends ($this->prop[] = ...). When
the same property is also written with a keyed dim assign
($this->prop['error'] = 'text') or a direct assign, those value types were
ignored and the resulting @var was too narrow, rejecting them. Skip such
properties instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant