Skip to content

[TypeDeclarationDocblocks] Skip empty array return in DocblockReturnArrayFromDirectArrayInstanceRector - #8434

Open
TomasVotruba wants to merge 1 commit into
mainfrom
tv/docblock-return-skip-empty-array
Open

[TypeDeclarationDocblocks] Skip empty array return in DocblockReturnArrayFromDirectArrayInstanceRector#8434
TomasVotruba wants to merge 1 commit into
mainfrom
tv/docblock-return-skip-empty-array

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

A method that only does return []; was annotated with @return array{}.

array{} is the narrowest possible array type. Added to a base method, every child that overrides it and returns a filled array then violates the parent contract:

Method Repository::getDefaultOrder() should return array{} but returns array{array{'c.name', 'ASC'}}.

An empty array{} docblock carries no useful information anyway, so skip empty array returns entirely.

The existing return_empty fixture asserted the array{} output; it becomes a skip fixture.

…rrayFromDirectArrayInstanceRector

A @return array{} is the narrowest array type. When added to a method that
can be overridden, any child returning a filled array violates it. Empty
array{} docblocks carry no useful information, so skip them entirely.
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