Updated Rector to commit 0947481ee6

0947481ee6 Prevent UnionTypes rule from removing literal value scalar types (#1666)
This commit is contained in:
Tomas Votruba 2022-01-14 15:04:58 +00:00
parent 840ae52412
commit 342033ded5
15 changed files with 78 additions and 52 deletions

View File

@ -11,6 +11,7 @@ use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\ArrayType;
use PHPStan\Type\BooleanType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\ConstantScalarType;
use PHPStan\Type\Generic\GenericClassStringType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
@ -108,17 +109,10 @@ final class TypeComparator
if ($this->isTypeSelfAndDocParamTypeStatic($phpStanDocType, $phpParserNodeType, $phpStanDocTypeNode)) {
return \false;
}
// special case for non-final $this/self compare; in case of interface/abstract class, it can be another $this
if ($phpStanDocType instanceof \PHPStan\Type\ThisType && $phpParserNodeType instanceof \PHPStan\Type\ThisType) {
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
if ($scope instanceof \PHPStan\Analyser\Scope) {
$classReflection = $scope->getClassReflection();
if ($classReflection instanceof \PHPStan\Reflection\ClassReflection) {
return $classReflection->isFinal();
}
}
if ($this->areTypesSameWithLiteralTypeInPhpDoc($areDifferentScalarTypes, $phpStanDocType, $phpParserNodeType)) {
return \false;
}
return \true;
return $this->isThisTypeInFinalClass($phpStanDocType, $phpParserNodeType, $node);
}
public function isSubtype(\PHPStan\Type\Type $checkedType, \PHPStan\Type\Type $mainType) : bool
{
@ -230,4 +224,22 @@ final class TypeComparator
{
return $phpStanDocType instanceof \PHPStan\Type\StaticType && $phpParserNodeType instanceof \PHPStan\Type\ThisType && $phpStanDocTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT) instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
}
private function areTypesSameWithLiteralTypeInPhpDoc(bool $areDifferentScalarTypes, \PHPStan\Type\Type $phpStanDocType, \PHPStan\Type\Type $phpParserNodeType) : bool
{
return $areDifferentScalarTypes && $phpStanDocType instanceof \PHPStan\Type\ConstantScalarType && $phpParserNodeType->isSuperTypeOf($phpStanDocType)->yes();
}
private function isThisTypeInFinalClass(\PHPStan\Type\Type $phpStanDocType, \PHPStan\Type\Type $phpParserNodeType, \PhpParser\Node $node) : bool
{
// special case for non-final $this/self compare; in case of interface/abstract class, it can be another $this
if ($phpStanDocType instanceof \PHPStan\Type\ThisType && $phpParserNodeType instanceof \PHPStan\Type\ThisType) {
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
if ($scope instanceof \PHPStan\Analyser\Scope) {
$classReflection = $scope->getClassReflection();
if ($classReflection instanceof \PHPStan\Reflection\ClassReflection) {
return $classReflection->isFinal();
}
}
}
return \true;
}
}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'fda8d1af45875248ab46a5a97ad7d207823aaeba';
public const PACKAGE_VERSION = '0947481ee67d0df4d72faee6408a671d487e387d';
/**
* @var string
*/
public const RELEASE_DATE = '2022-01-14 12:36:51';
public const RELEASE_DATE = '2022-01-14 15:58:11';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20220114\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257::getLoader();
return ComposerAutoloaderInit0df3b22675084ce18767e2071e1a5b89::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257
class ComposerAutoloaderInit0df3b22675084ce18767e2071e1a5b89
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit0df3b22675084ce18767e2071e1a5b89', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit0df3b22675084ce18767e2071e1a5b89', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit9ce8117903529ea4d4ec981749d7e257::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit0df3b22675084ce18767e2071e1a5b89::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,12 +42,12 @@ class ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit9ce8117903529ea4d4ec981749d7e257::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit0df3b22675084ce18767e2071e1a5b89::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire9ce8117903529ea4d4ec981749d7e257($fileIdentifier, $file);
composerRequire0df3b22675084ce18767e2071e1a5b89($fileIdentifier, $file);
}
return $loader;
@ -59,7 +59,7 @@ class ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257
* @param string $file
* @return void
*/
function composerRequire9ce8117903529ea4d4ec981749d7e257($fileIdentifier, $file)
function composerRequire0df3b22675084ce18767e2071e1a5b89($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit9ce8117903529ea4d4ec981749d7e257
class ComposerStaticInit0df3b22675084ce18767e2071e1a5b89
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3865,9 +3865,9 @@ class ComposerStaticInit9ce8117903529ea4d4ec981749d7e257
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit9ce8117903529ea4d4ec981749d7e257::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit9ce8117903529ea4d4ec981749d7e257::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit9ce8117903529ea4d4ec981749d7e257::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit0df3b22675084ce18767e2071e1a5b89::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit0df3b22675084ce18767e2071e1a5b89::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit0df3b22675084ce18767e2071e1a5b89::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1866,17 +1866,17 @@
},
{
"name": "react\/socket",
"version": "v1.10.0",
"version_normalized": "1.10.0.0",
"version": "v1.11.0",
"version_normalized": "1.11.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/reactphp\/socket.git",
"reference": "d132fde589ea97f4165f2d94b5296499eac125ec"
"reference": "f474156aaab4f09041144fa8b57c7d70aed32a1c"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/reactphp\/socket\/zipball\/d132fde589ea97f4165f2d94b5296499eac125ec",
"reference": "d132fde589ea97f4165f2d94b5296499eac125ec",
"url": "https:\/\/api.github.com\/repos\/reactphp\/socket\/zipball\/f474156aaab4f09041144fa8b57c7d70aed32a1c",
"reference": "f474156aaab4f09041144fa8b57c7d70aed32a1c",
"shasum": ""
},
"require": {
@ -1885,15 +1885,15 @@
"react\/dns": "^1.8",
"react\/event-loop": "^1.2",
"react\/promise": "^2.6.0 || ^1.2.1",
"react\/promise-timer": "^1.4.0",
"react\/promise-timer": "^1.8",
"react\/stream": "^1.2"
},
"require-dev": {
"clue\/block-react": "^1.2",
"clue\/block-react": "^1.5",
"phpunit\/phpunit": "^9.3 || ^5.7 || ^4.8.35",
"react\/promise-stream": "^1.2"
},
"time": "2021-11-29T10:08:24+00:00",
"time": "2022-01-14T10:14:32+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -1937,7 +1937,7 @@
],
"support": {
"issues": "https:\/\/github.com\/reactphp\/socket\/issues",
"source": "https:\/\/github.com\/reactphp\/socket\/tree\/v1.10.0"
"source": "https:\/\/github.com\/reactphp\/socket\/tree\/v1.11.0"
},
"funding": [
{

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,18 @@
# Changelog
## 1.10.0 (2021-09-13)
## 1.11.0 (2022-01-14)
* Feature: Full support for PHP 8.1 release.
(#277 by @clue)
* Feature: Avoid dependency on `ext-filter`.
(#279 by @clue)
* Improve test suite to skip FD test when hitting memory limit
and skip legacy TLS 1.0 tests if disabled by system.
(#278 and #281 by @clue and #283 by @SimonFrings)
## 1.10.0 (2021-11-29)
* Feature: Support listening on existing file descriptors (FDs) with `SocketServer`.
(#269 by @clue)
@ -9,9 +21,7 @@
$socket = new React\Socket\SocketSever('php://fd/3');
```
This is particularly useful when using
[systemd socket activation](https://www.freedesktop.org/software/systemd/man/systemd.socket.html)
like this:
This is particularly useful when using [systemd socket activation](https://www.freedesktop.org/software/systemd/man/systemd.socket.html) like this:
```bash
$ systemd-socket-activate -l 8000 php examples/03-http-server.php php://fd/3

View File

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

View File

@ -37,11 +37,11 @@
"react\/dns": "^1.8",
"react\/event-loop": "^1.2",
"react\/promise": "^2.6.0 || ^1.2.1",
"react\/promise-timer": "^1.4.0",
"react\/promise-timer": "^1.8",
"react\/stream": "^1.2"
},
"require-dev": {
"clue\/block-react": "^1.2",
"clue\/block-react": "^1.5",
"phpunit\/phpunit": "^9.3 || ^5.7 || ^4.8.35",
"react\/promise-stream": "^1.2"
},

View File

@ -20,7 +20,9 @@ final class DnsConnector implements \RectorPrefix20220114\React\Socket\Connector
if (\strpos($uri, '://') === \false) {
$uri = 'tcp://' . $uri;
$parts = \parse_url($uri);
unset($parts['scheme']);
if (isset($parts['scheme'])) {
unset($parts['scheme']);
}
} else {
$parts = \parse_url($uri);
}
@ -30,7 +32,7 @@ final class DnsConnector implements \RectorPrefix20220114\React\Socket\Connector
$host = \trim($parts['host'], '[]');
$connector = $this->connector;
// skip DNS lookup / URI manipulation if this URI already contains an IP
if (\false !== \filter_var($host, \FILTER_VALIDATE_IP)) {
if (@\inet_pton($host) !== \false) {
return $connector->connect($original);
}
$promise = $this->resolver->resolve($host);

View File

@ -31,7 +31,9 @@ final class HappyEyeBallsConnector implements \RectorPrefix20220114\React\Socket
if (\strpos($uri, '://') === \false) {
$uri = 'tcp://' . $uri;
$parts = \parse_url($uri);
unset($parts['scheme']);
if (isset($parts['scheme'])) {
unset($parts['scheme']);
}
} else {
$parts = \parse_url($uri);
}
@ -40,7 +42,7 @@ final class HappyEyeBallsConnector implements \RectorPrefix20220114\React\Socket
}
$host = \trim($parts['host'], '[]');
// skip DNS lookup / URI manipulation if this URI already contains an IP
if (\false !== \filter_var($host, \FILTER_VALIDATE_IP)) {
if (@\inet_pton($host) !== \false) {
return $this->connector->connect($original);
}
$builder = new \RectorPrefix20220114\React\Socket\HappyEyeBallsConnectionBuilder($this->loop, $this->connector, $this->resolver, $uri, $host, $parts);

View File

@ -26,7 +26,7 @@ final class TcpConnector implements \RectorPrefix20220114\React\Socket\Connector
return \RectorPrefix20220114\React\Promise\reject(new \InvalidArgumentException('Given URI "' . $uri . '" is invalid (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22));
}
$ip = \trim($parts['host'], '[]');
if (\false === \filter_var($ip, \FILTER_VALIDATE_IP)) {
if (@\inet_pton($ip) === \false) {
return \RectorPrefix20220114\React\Promise\reject(new \InvalidArgumentException('Given URI "' . $uri . '" does not contain a valid host IP (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22));
}
// use context given in constructor

View File

@ -150,7 +150,7 @@ final class TcpServer extends \RectorPrefix20220114\Evenement\EventEmitter imple
if (!$parts || !isset($parts['scheme'], $parts['host'], $parts['port']) || $parts['scheme'] !== 'tcp') {
throw new \InvalidArgumentException('Invalid URI "' . $uri . '" given (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22);
}
if (\false === \filter_var(\trim($parts['host'], '[]'), \FILTER_VALIDATE_IP)) {
if (@\inet_pton(\trim($parts['host'], '[]')) === \false) {
throw new \InvalidArgumentException('Given URI "' . $uri . '" does not contain a valid host IP (EINVAL)', \defined('SOCKET_EINVAL') ? \SOCKET_EINVAL : 22);
}
$this->master = @\stream_socket_server($uri, $errno, $errstr, \STREAM_SERVER_BIND | \STREAM_SERVER_LISTEN, \stream_context_create(array('socket' => $context + array('backlog' => 511))));

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220114\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257', false) && !interface_exists('ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257', false) && !trait_exists('ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257', false)) {
spl_autoload_call('RectorPrefix20220114\ComposerAutoloaderInit9ce8117903529ea4d4ec981749d7e257');
if (!class_exists('ComposerAutoloaderInit0df3b22675084ce18767e2071e1a5b89', false) && !interface_exists('ComposerAutoloaderInit0df3b22675084ce18767e2071e1a5b89', false) && !trait_exists('ComposerAutoloaderInit0df3b22675084ce18767e2071e1a5b89', false)) {
spl_autoload_call('RectorPrefix20220114\ComposerAutoloaderInit0df3b22675084ce18767e2071e1a5b89');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20220114\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -71,9 +71,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220114\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire9ce8117903529ea4d4ec981749d7e257')) {
function composerRequire9ce8117903529ea4d4ec981749d7e257() {
return \RectorPrefix20220114\composerRequire9ce8117903529ea4d4ec981749d7e257(...func_get_args());
if (!function_exists('composerRequire0df3b22675084ce18767e2071e1a5b89')) {
function composerRequire0df3b22675084ce18767e2071e1a5b89() {
return \RectorPrefix20220114\composerRequire0df3b22675084ce18767e2071e1a5b89(...func_get_args());
}
}
if (!function_exists('scanPath')) {