Updated Rector to commit 459843b1617a401d02e8cf5e6a1054f43f069f0d

459843b161 [DeadCode] Use PHPStan $functionReflection->hasSideEffects()->yes() early when possible on PureFunctionDetector (#5962)
This commit is contained in:
Tomas Votruba 2024-06-11 22:11:13 +00:00
parent e952e0ba80
commit 5b56f97fec
11 changed files with 75 additions and 23 deletions

View File

@ -258,6 +258,11 @@ final class PureFunctionDetector
if (!$functionReflection instanceof NativeFunctionReflection) {
return \false;
}
// use PHPStan first check
if ($functionReflection->hasSideEffects()->yes()) {
return \false;
}
// otherwise, use added defined here
return !\in_array($funcCallName, self::IMPURE_FUNCTIONS, \true);
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '324bf249b01745819521490f3066f3a51a8f6249';
public const PACKAGE_VERSION = '459843b1617a401d02e8cf5e6a1054f43f069f0d';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-06-11 16:37:24';
public const RELEASE_DATE = '2024-06-12 05:07:48';
/**
* @var int
*/

View File

@ -1541,17 +1541,17 @@
},
{
"name": "react\/stream",
"version": "v1.3.0",
"version_normalized": "1.3.0.0",
"version": "v1.4.0",
"version_normalized": "1.4.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/reactphp\/stream.git",
"reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66"
"reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/reactphp\/stream\/zipball\/6fbc9672905c7d5a885f2da2fc696f65840f4a66",
"reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66",
"url": "https:\/\/api.github.com\/repos\/reactphp\/stream\/zipball\/1e5b0acb8fe55143b5b426817155190eb6f5b18d",
"reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d",
"shasum": ""
},
"require": {
@ -1561,9 +1561,9 @@
},
"require-dev": {
"clue\/stream-filter": "~1.2",
"phpunit\/phpunit": "^9.5 || ^5.7 || ^4.8.35"
"phpunit\/phpunit": "^9.6 || ^5.7 || ^4.8.36"
},
"time": "2023-06-16T10:52:11+00:00",
"time": "2024-06-11T12:45:25+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -1610,7 +1610,7 @@
],
"support": {
"issues": "https:\/\/github.com\/reactphp\/stream\/issues",
"source": "https:\/\/github.com\/reactphp\/stream\/tree\/v1.3.0"
"source": "https:\/\/github.com\/reactphp\/stream\/tree\/v1.4.0"
},
"funding": [
{

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,16 @@
# Changelog
## 1.4.0 (2024-06-11)
* Feature: Improve PHP 8.4+ support by avoiding implicitly nullable type declarations.
(#179 by @clue)
* Feature: Full PHP 8.3 compatibility.
(#172 by @clue)
* Fix: Fix `drain` event of `ThroughStream` to handle potential race condition.
(#171 by @clue)
## 1.3.0 (2023-06-16)
* Feature: Full PHP 8.1 and PHP 8.2 compatibility.

View File

@ -1203,7 +1203,7 @@ This project follows [SemVer](https://semver.org/).
This will install the latest supported version:
```bash
composer require react/stream:^1.3
composer require react/stream:^1.4
```
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.

View File

@ -40,7 +40,7 @@
"evenement\/evenement": "^3.0 || ^2.0 || ^1.0"
},
"require-dev": {
"phpunit\/phpunit": "^9.5 || ^5.7 || ^4.8.35",
"phpunit\/phpunit": "^9.6 || ^5.7 || ^4.8.36",
"clue\/stream-filter": "~1.2"
},
"autoload": {

View File

@ -33,7 +33,13 @@ final class DuplexResourceStream extends EventEmitter implements DuplexStreamInt
private $writable = \true;
private $closing = \false;
private $listening = \false;
public function __construct($stream, LoopInterface $loop = null, $readChunkSize = null, WritableStreamInterface $buffer = null)
/**
* @param resource $stream
* @param ?LoopInterface $loop
* @param ?int $readChunkSize
* @param ?WritableStreamInterface $buffer
*/
public function __construct($stream, $loop = null, $readChunkSize = null, $buffer = null)
{
if (!\is_resource($stream) || \get_resource_type($stream) !== "stream") {
throw new InvalidArgumentException('First parameter must be a valid stream resource');
@ -48,6 +54,14 @@ final class DuplexResourceStream extends EventEmitter implements DuplexStreamInt
if ($buffer !== null && !$buffer instanceof WritableResourceStream && \stream_set_blocking($stream, \false) !== \true) {
throw new \RuntimeException('Unable to set stream resource to non-blocking mode');
}
if ($loop !== null && !$loop instanceof LoopInterface) {
// manual type check to support legacy PHP < 7.1
throw new \InvalidArgumentException('Argument #2 ($loop) expected null|React\\EventLoop\\LoopInterface');
}
if ($buffer !== null && !$buffer instanceof WritableStreamInterface) {
// manual type check to support legacy PHP < 7.1
throw new \InvalidArgumentException('Argument #4 ($buffer) expected null|React\\Stream\\WritableStreamInterface');
}
// Use unbuffered read operations on the underlying stream resource.
// Reading chunks from the stream may otherwise leave unread bytes in
// PHP's stream buffers which some event loop implementations do not

View File

@ -35,7 +35,12 @@ final class ReadableResourceStream extends EventEmitter implements ReadableStrea
private $bufferSize;
private $closed = \false;
private $listening = \false;
public function __construct($stream, LoopInterface $loop = null, $readChunkSize = null)
/**
* @param resource $stream
* @param ?LoopInterface $loop
* @param ?int $readChunkSize
*/
public function __construct($stream, $loop = null, $readChunkSize = null)
{
if (!\is_resource($stream) || \get_resource_type($stream) !== "stream") {
throw new InvalidArgumentException('First parameter must be a valid stream resource');
@ -50,6 +55,10 @@ final class ReadableResourceStream extends EventEmitter implements ReadableStrea
if (\stream_set_blocking($stream, \false) !== \true) {
throw new \RuntimeException('Unable to set stream resource to non-blocking mode');
}
if ($loop !== null && !$loop instanceof LoopInterface) {
// manual type check to support legacy PHP < 7.1
throw new \InvalidArgumentException('Argument #2 ($loop) expected null|React\\EventLoop\\LoopInterface');
}
// Use unbuffered read operations on the underlying stream resource.
// Reading chunks from the stream may otherwise leave unread bytes in
// PHP's stream buffers which some event loop implementations do not

View File

@ -89,15 +89,17 @@ final class ThroughStream extends EventEmitter implements DuplexStreamInterface
}
public function pause()
{
$this->paused = \true;
// only allow pause if still readable, false otherwise
$this->paused = $this->readable;
}
public function resume()
{
$this->paused = \false;
// emit drain event if previous write was paused (throttled)
if ($this->drain) {
$this->drain = \false;
$this->emit('drain');
}
$this->paused = \false;
}
public function pipe(WritableStreamInterface $dest, array $options = array())
{
@ -126,11 +128,12 @@ final class ThroughStream extends EventEmitter implements DuplexStreamInterface
}
}
$this->emit('data', array($data));
// emit drain event on next resume if currently paused (throttled)
if ($this->paused) {
$this->drain = \true;
return \false;
}
return \true;
// continue writing if still writable and not paused (throttled), false otherwise
return $this->writable && !$this->paused;
}
public function end($data = null)
{
@ -146,7 +149,7 @@ final class ThroughStream extends EventEmitter implements DuplexStreamInterface
}
$this->readable = \false;
$this->writable = \false;
$this->paused = \true;
$this->paused = \false;
$this->drain = \false;
$this->emit('end');
$this->close();
@ -158,9 +161,9 @@ final class ThroughStream extends EventEmitter implements DuplexStreamInterface
}
$this->readable = \false;
$this->writable = \false;
$this->closed = \true;
$this->paused = \true;
$this->paused = \false;
$this->drain = \false;
$this->closed = \true;
$this->callback = null;
$this->emit('close');
$this->removeAllListeners();

View File

@ -22,7 +22,13 @@ final class WritableResourceStream extends EventEmitter implements WritableStrea
private $writable = \true;
private $closed = \false;
private $data = '';
public function __construct($stream, LoopInterface $loop = null, $writeBufferSoftLimit = null, $writeChunkSize = null)
/**
* @param resource $stream
* @param ?LoopInterface $loop
* @param ?int $writeBufferSoftLimit
* @param ?int $writeChunkSize
*/
public function __construct($stream, $loop = null, $writeBufferSoftLimit = null, $writeChunkSize = null)
{
if (!\is_resource($stream) || \get_resource_type($stream) !== "stream") {
throw new \InvalidArgumentException('First parameter must be a valid stream resource');
@ -37,6 +43,10 @@ final class WritableResourceStream extends EventEmitter implements WritableStrea
if (\stream_set_blocking($stream, \false) !== \true) {
throw new \RuntimeException('Unable to set stream resource to non-blocking mode');
}
if ($loop !== null && !$loop instanceof LoopInterface) {
// manual type check to support legacy PHP < 7.1
throw new \InvalidArgumentException('Argument #2 ($loop) expected null|React\\EventLoop\\LoopInterface');
}
$this->stream = $stream;
$this->loop = $loop ?: Loop::get();
$this->softLimit = $writeBufferSoftLimit === null ? 65536 : (int) $writeBufferSoftLimit;