psr7 icon indicating copy to clipboard operation
psr7 copied to clipboard

Clarify static return type of MessageTrait methods

Open braindawg opened this issue 4 months ago • 0 comments

Per the PSR spec (and the code), the methods on MessageTrait currently hinting MessageInterface should be returning static. That return type was not supported until PHP 8.0, so to maintain PHP 7 compatibility, a docblock can be used to clarify the return behavior of these methods.

This should appease static analyzers that throw errors when these methods are used on more specific implementations of MessageInterface.

Closes #617, which should hopefully explain the benefit of this change. Happy to clarify if not.

braindawg avatar Sep 08 '25 20:09 braindawg