Skip to content

Conversation

@7-zete-7
Copy link

@7-zete-77-zete-7 commented Aug 21, 2025

These changes allow IDEs and PHPStan to more correctly detect the type of objects returned from the React\Stream\Util::pipe() and React\Stream\ReadableStreamInterface::pipe() methods.

After applying these changes, calling chains from pipe() methods will no longer result in PHPStan errors for the following code:

$stream1 = newReact\Stream\ThroughStream(); $stream2 = newReact\Stream\ThroughStream(); $stream3 = newReact\Stream\ThroughStream(); $stream4 = newReact\Stream\ThroughStream(); $stream1 ->pipe($stream2) ->pipe($stream3) // Call to an undefined method React\Stream\WritableStreamInterface::pipe(). ->pipe($stream4) // Call to an undefined method React\Stream\WritableStreamInterface::pipe(). ;

Also, the IDE (using PhpStorm as an example) will be able to correctly understand the object type returned from the pipe() method. The following warning will no longer appear:

Potentially polymorphic call. WritableResourceStream does not have members in its hierarchy 

@7-zete-77-zete-7 marked this pull request as draft August 21, 2025 21:34
@7-zete-77-zete-7 changed the base branch from 3.x to 1.xAugust 22, 2025 09:52
@7-zete-77-zete-7 changed the title chore: declare the return type of the ReadableStreamInterface::pipe() method via @templatechore: declare return of pipe() methods by @templateAug 22, 2025
@7-zete-77-zete-7 changed the title chore: declare return of pipe() methods by @templatechore: declare return type of pipe() methods by @templateAug 22, 2025
@7-zete-77-zete-7 marked this pull request as ready for review August 22, 2025 10:07
Sign up for freeto 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

@7-zete-7