Skip to content

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

Merged
TomasVotruba merged 2 commits into
mainfrom
tv/docblock-return-skip-empty-array
Sep 6, 2026
Merged

[TypeDeclarationDocblocks] Skip empty array return in DocblockReturnArrayFromDirectArrayInstanceRector#8434
TomasVotruba merged 2 commits 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.
@TomasVotruba

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…ip-empty-array

# Conflicts:
#	rules/TypeDeclarationDocblocks/Rector/ClassMethod/DocblockReturnArrayFromDirectArrayInstanceRector.php

Co-authored-by: TomasVotruba <924196+TomasVotruba@users.noreply.github.com>

Copilot AI commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved in fa440fd2.

@TomasVotruba
TomasVotruba enabled auto-merge (squash) September 6, 2026 10:39
@TomasVotruba
TomasVotruba merged commit c3088b7 into main Sep 6, 2026
43 checks passed
@TomasVotruba
TomasVotruba deleted the tv/docblock-return-skip-empty-array branch September 6, 2026 10:40
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.

2 participants