Updated Rector to commit effe4d38f68cfe64a38f7c2422befed3a872142e

effe4d38f6 [Skipper] Handle provide direct relative path in Skipper (#2921)
This commit is contained in:
Tomas Votruba 2022-09-11 12:05:24 +00:00
parent 5a43eee340
commit d1c230fe39
17 changed files with 137 additions and 51 deletions

View File

@ -5,6 +5,7 @@ namespace Rector\Skipper\Matcher;
use Rector\Skipper\FileSystem\FnMatchPathNormalizer;
use Rector\Skipper\Fnmatcher;
use Rector\Skipper\RealpathMatcher;
final class FileInfoMatcher
{
/**
@ -17,10 +18,16 @@ final class FileInfoMatcher
* @var \Rector\Skipper\Fnmatcher
*/
private $fnmatcher;
public function __construct(FnMatchPathNormalizer $fnMatchPathNormalizer, Fnmatcher $fnmatcher)
/**
* @readonly
* @var \Rector\Skipper\RealpathMatcher
*/
private $realpathMatcher;
public function __construct(FnMatchPathNormalizer $fnMatchPathNormalizer, Fnmatcher $fnmatcher, RealpathMatcher $realpathMatcher)
{
$this->fnMatchPathNormalizer = $fnMatchPathNormalizer;
$this->fnmatcher = $fnmatcher;
$this->realpathMatcher = $realpathMatcher;
}
/**
* @param string[] $filePatterns
@ -53,6 +60,9 @@ final class FileInfoMatcher
if (\substr_compare($filePath, $ignoredPath, -\strlen($ignoredPath)) === 0) {
return \true;
}
return $this->fnmatcher->match($ignoredPath, $filePath);
if ($this->fnmatcher->match($ignoredPath, $filePath)) {
return \true;
}
return $this->realpathMatcher->match($ignoredPath, $filePath);
}
}

View File

@ -0,0 +1,34 @@
<?php
declare (strict_types=1);
namespace Rector\Skipper;
final class RealpathMatcher
{
public function match(string $matchingPath, string $filePath) : bool
{
$realPathMatchingPath = \realpath($matchingPath);
$realpathFilePath = \realpath($filePath);
if (!\is_string($realPathMatchingPath)) {
return \false;
}
if (!\is_string($realpathFilePath)) {
return \false;
}
$normalizedMatchingPath = $this->normalizePath($realPathMatchingPath);
$normalizedFilePath = $this->normalizePath($realpathFilePath);
// skip define direct path
if (\is_file($normalizedMatchingPath)) {
return $normalizedMatchingPath === $normalizedFilePath;
}
// ensure add / suffix to ensure no same prefix directory
if (\is_dir($normalizedMatchingPath)) {
$normalizedMatchingPath = \rtrim($normalizedMatchingPath, '/') . '/';
}
return \strncmp($normalizedFilePath, $normalizedMatchingPath, \strlen($normalizedMatchingPath)) === 0;
}
private function normalizePath(string $path) : string
{
return \str_replace('\\', '/', $path);
}
}

View File

@ -46,7 +46,10 @@ final class Skipper
if (!$skipVoter->match($element)) {
continue;
}
return $skipVoter->shouldSkip($element, $filePath);
if (!$skipVoter->shouldSkip($element, $filePath)) {
continue;
}
return \true;
}
return \false;
}

View File

@ -227,6 +227,9 @@ CODE_SAMPLE
private function shouldSkip(FuncCall $funcCall) : bool
{
$functionNames = \array_keys(self::ARG_POSITION_NAME_NULL_TO_STRICT_STRING);
return !$this->nodeNameResolver->isNames($funcCall, $functionNames) || $funcCall->isFirstClassCallable();
if (!$this->nodeNameResolver->isNames($funcCall, $functionNames)) {
return \true;
}
return $funcCall->isFirstClassCallable();
}
}

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '2975a1bb0cc1a9e76c4cf09ad9b32494ac90d4e0';
public const PACKAGE_VERSION = 'effe4d38f68cfe64a38f7c2422befed3a872142e';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-09-07 14:59:44';
public const RELEASE_DATE = '2022-09-11 13:59:51';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitd1b8e60390512bbd8e181e0929a62fa4::getLoader();
return ComposerAutoloaderInit98e9b293f18091f1ab5c89ae86f8dd9c::getLoader();

View File

@ -2436,6 +2436,7 @@ return array(
'Rector\\Skipper\\FileSystem\\FnMatchPathNormalizer' => $baseDir . '/packages/Skipper/FileSystem/FnMatchPathNormalizer.php',
'Rector\\Skipper\\Fnmatcher' => $baseDir . '/packages/Skipper/Fnmatcher.php',
'Rector\\Skipper\\Matcher\\FileInfoMatcher' => $baseDir . '/packages/Skipper/Matcher/FileInfoMatcher.php',
'Rector\\Skipper\\RealpathMatcher' => $baseDir . '/packages/Skipper/RealpathMatcher.php',
'Rector\\Skipper\\SkipCriteriaResolver\\SkippedClassResolver' => $baseDir . '/packages/Skipper/SkipCriteriaResolver/SkippedClassResolver.php',
'Rector\\Skipper\\SkipCriteriaResolver\\SkippedPathsResolver' => $baseDir . '/packages/Skipper/SkipCriteriaResolver/SkippedPathsResolver.php',
'Rector\\Skipper\\SkipVoter\\ClassSkipVoter' => $baseDir . '/packages/Skipper/SkipVoter/ClassSkipVoter.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitd1b8e60390512bbd8e181e0929a62fa4
class ComposerAutoloaderInit98e9b293f18091f1ab5c89ae86f8dd9c
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitd1b8e60390512bbd8e181e0929a62fa4
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitd1b8e60390512bbd8e181e0929a62fa4', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit98e9b293f18091f1ab5c89ae86f8dd9c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitd1b8e60390512bbd8e181e0929a62fa4', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit98e9b293f18091f1ab5c89ae86f8dd9c', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitd1b8e60390512bbd8e181e0929a62fa4::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit98e9b293f18091f1ab5c89ae86f8dd9c::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitd1b8e60390512bbd8e181e0929a62fa4::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit98e9b293f18091f1ab5c89ae86f8dd9c::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequired1b8e60390512bbd8e181e0929a62fa4($fileIdentifier, $file);
composerRequire98e9b293f18091f1ab5c89ae86f8dd9c($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitd1b8e60390512bbd8e181e0929a62fa4
* @param string $file
* @return void
*/
function composerRequired1b8e60390512bbd8e181e0929a62fa4($fileIdentifier, $file)
function composerRequire98e9b293f18091f1ab5c89ae86f8dd9c($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 ComposerStaticInitd1b8e60390512bbd8e181e0929a62fa4
class ComposerStaticInit98e9b293f18091f1ab5c89ae86f8dd9c
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -2691,6 +2691,7 @@ class ComposerStaticInitd1b8e60390512bbd8e181e0929a62fa4
'Rector\\Skipper\\FileSystem\\FnMatchPathNormalizer' => __DIR__ . '/../..' . '/packages/Skipper/FileSystem/FnMatchPathNormalizer.php',
'Rector\\Skipper\\Fnmatcher' => __DIR__ . '/../..' . '/packages/Skipper/Fnmatcher.php',
'Rector\\Skipper\\Matcher\\FileInfoMatcher' => __DIR__ . '/../..' . '/packages/Skipper/Matcher/FileInfoMatcher.php',
'Rector\\Skipper\\RealpathMatcher' => __DIR__ . '/../..' . '/packages/Skipper/RealpathMatcher.php',
'Rector\\Skipper\\SkipCriteriaResolver\\SkippedClassResolver' => __DIR__ . '/../..' . '/packages/Skipper/SkipCriteriaResolver/SkippedClassResolver.php',
'Rector\\Skipper\\SkipCriteriaResolver\\SkippedPathsResolver' => __DIR__ . '/../..' . '/packages/Skipper/SkipCriteriaResolver/SkippedPathsResolver.php',
'Rector\\Skipper\\SkipVoter\\ClassSkipVoter' => __DIR__ . '/../..' . '/packages/Skipper/SkipVoter/ClassSkipVoter.php',
@ -3093,9 +3094,9 @@ class ComposerStaticInitd1b8e60390512bbd8e181e0929a62fa4
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitd1b8e60390512bbd8e181e0929a62fa4::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitd1b8e60390512bbd8e181e0929a62fa4::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitd1b8e60390512bbd8e181e0929a62fa4::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit98e9b293f18091f1ab5c89ae86f8dd9c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit98e9b293f18091f1ab5c89ae86f8dd9c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit98e9b293f18091f1ab5c89ae86f8dd9c::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1225,17 +1225,17 @@
},
{
"name": "react\/dns",
"version": "v1.9.0",
"version_normalized": "1.9.0.0",
"version": "v1.10.0",
"version_normalized": "1.10.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/reactphp\/dns.git",
"reference": "6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb"
"reference": "a5427e7dfa47713e438016905605819d101f238c"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/reactphp\/dns\/zipball\/6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb",
"reference": "6d38296756fa644e6cb1bfe95eff0f9a4ed6edcb",
"url": "https:\/\/api.github.com\/repos\/reactphp\/dns\/zipball\/a5427e7dfa47713e438016905605819d101f238c",
"reference": "a5427e7dfa47713e438016905605819d101f238c",
"shasum": ""
},
"require": {
@ -1243,13 +1243,13 @@
"react\/cache": "^1.0 || ^0.6 || ^0.5",
"react\/event-loop": "^1.2",
"react\/promise": "^3.0 || ^2.7 || ^1.2.1",
"react\/promise-timer": "^1.8"
"react\/promise-timer": "^1.9"
},
"require-dev": {
"clue\/block-react": "^1.2",
"phpunit\/phpunit": "^9.3 || ^4.8.35"
"phpunit\/phpunit": "^9.3 || ^4.8.35",
"react\/async": "^4 || ^3 || ^2"
},
"time": "2021-12-20T08:46:54+00:00",
"time": "2022-09-08T12:22:46+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -1292,7 +1292,7 @@
],
"support": {
"issues": "https:\/\/github.com\/reactphp\/dns\/issues",
"source": "https:\/\/github.com\/reactphp\/dns\/tree\/v1.9.0"
"source": "https:\/\/github.com\/reactphp\/dns\/tree\/v1.10.0"
},
"funding": [
{

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,25 @@
# Changelog
## 1.10.0 (2022-09-08)
* Feature: Full support for PHP 8.2 release.
(#201 by @clue and #207 by @WyriHaximus)
* Feature: Optimize forward compatibility with Promise v3, avoid hitting autoloader.
(#202 by @clue)
* Feature / Fix: Improve error reporting when custom error handler is used.
(#197 by @clue)
* Fix: Fix invalid references in exception stack trace.
(#191 by @clue)
* Minor documentation improvements.
(#195 by @SimonFrings and #203 by @nhedger)
* Improve test suite, update to use default loop and new reactphp/async package.
(#204, #205 and #206 by @clue and #196 by @SimonFrings)
## 1.9.0 (2021-12-20)
* Feature: Full support for PHP 8.1 release and prepare PHP 8.2 compatibility

View File

@ -1,6 +1,7 @@
# DNS
[![CI status](https://github.com/reactphp/dns/workflows/CI/badge.svg)](https://github.com/reactphp/dns/actions)
[![CI status](https://github.com/reactphp/dns/actions/workflows/ci.yml/badge.svg)](https://github.com/reactphp/dns/actions)
[![installs on Packagist](https://img.shields.io/packagist/dt/react/dns?color=blue&label=installs%20on%20Packagist)](https://packagist.org/packages/react/dns)
Async DNS resolver for [ReactPHP](https://reactphp.org/).
@ -409,7 +410,7 @@ This project follows [SemVer](https://semver.org/).
This will install the latest supported version:
```bash
$ composer require react/dns:^1.9
composer require react/dns:^1.10
```
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
@ -425,13 +426,13 @@ To run the test suite, you first need to clone this repo and then install all
dependencies [through Composer](https://getcomposer.org/):
```bash
$ composer install
composer install
```
To run the test suite, go to the project root and run:
```bash
$ vendor/bin/phpunit
vendor/bin/phpunit
```
The test suite also contains a number of functional integration tests that rely
@ -439,7 +440,7 @@ on a stable internet connection.
If you do not want to run these, they can simply be skipped like this:
```bash
$ vendor/bin/phpunit --exclude-group internet
vendor/bin/phpunit --exclude-group internet
```
## License

View File

@ -35,11 +35,11 @@
"react\/cache": "^1.0 || ^0.6 || ^0.5",
"react\/event-loop": "^1.2",
"react\/promise": "^3.0 || ^2.7 || ^1.2.1",
"react\/promise-timer": "^1.8"
"react\/promise-timer": "^1.9"
},
"require-dev": {
"clue\/block-react": "^1.2",
"phpunit\/phpunit": "^9.3 || ^4.8.35"
"phpunit\/phpunit": "^9.3 || ^4.8.35",
"react\/async": "^4 || ^3 || ^2"
},
"autoload": {
"psr-4": {

View File

@ -2,7 +2,6 @@
namespace RectorPrefix202209\React\Dns\Query;
use RectorPrefix202209\React\Promise\CancellablePromiseInterface;
use RectorPrefix202209\React\Promise\Deferred;
use RectorPrefix202209\React\Promise\PromiseInterface;
final class RetryExecutor implements ExecutorInterface
@ -21,7 +20,7 @@ final class RetryExecutor implements ExecutorInterface
public function tryQuery(Query $query, $retries)
{
$deferred = new Deferred(function () use(&$promise) {
if ($promise instanceof CancellablePromiseInterface || !\interface_exists('RectorPrefix202209\\React\\Promise\\CancellablePromiseInterface') && \method_exists($promise, 'cancel')) {
if ($promise instanceof PromiseInterface && \method_exists($promise, 'cancel')) {
$promise->cancel();
}
});
@ -44,11 +43,11 @@ final class RetryExecutor implements ExecutorInterface
$trace = $r->getValue($e);
// Exception trace arguments are not available on some PHP 7.4 installs
// @codeCoverageIgnoreStart
foreach ($trace as &$one) {
foreach ($trace as $ti => $one) {
if (isset($one['args'])) {
foreach ($one['args'] as &$arg) {
foreach ($one['args'] as $ai => $arg) {
if ($arg instanceof \Closure) {
$arg = 'Object(' . \get_class($arg) . ')';
$trace[$ti]['args'][$ai] = 'Object(' . \get_class($arg) . ')';
}
}
}

View File

@ -215,11 +215,19 @@ class TcpTransportExecutor implements ExecutorInterface
$this->readPending = \true;
$this->loop->addReadStream($this->socket, array($this, 'handleRead'));
}
$written = @\fwrite($this->socket, $this->writeBuffer);
$errno = 0;
$errstr = '';
\set_error_handler(function ($_, $error) use(&$errno, &$errstr) {
// Match errstr from PHP's warning message.
// fwrite(): Send of 327712 bytes failed with errno=32 Broken pipe
\preg_match('/errno=(\\d+) (.+)/', $error, $m);
$errno = isset($m[1]) ? (int) $m[1] : 0;
$errstr = isset($m[2]) ? $m[2] : $error;
});
$written = \fwrite($this->socket, $this->writeBuffer);
\restore_error_handler();
if ($written === \false || $written === 0) {
$error = \error_get_last();
\preg_match('/errno=(\\d+) (.+)/', $error['message'], $m);
$this->closeError('Unable to send query to DNS server ' . $this->nameserver . ' (' . (isset($m[2]) ? $m[2] : $error['message']) . ')', isset($m[1]) ? (int) $m[1] : 0);
$this->closeError('Unable to send query to DNS server ' . $this->nameserver . ' (' . $errstr . ')', $errno);
return;
}
if (isset($this->writeBuffer[$written])) {

View File

@ -118,21 +118,27 @@ final class UdpTransportExecutor implements ExecutorInterface
return \RectorPrefix202209\React\Promise\reject(new \RuntimeException('DNS query for ' . $query->describe() . ' failed: Query too large for UDP transport', \defined('SOCKET_EMSGSIZE') ? \SOCKET_EMSGSIZE : 90));
}
// UDP connections are instant, so try connection without a loop or timeout
$errno = 0;
$errstr = '';
$socket = @\stream_socket_client($this->nameserver, $errno, $errstr, 0);
if ($socket === \false) {
return \RectorPrefix202209\React\Promise\reject(new \RuntimeException('DNS query for ' . $query->describe() . ' failed: Unable to connect to DNS server ' . $this->nameserver . ' (' . $errstr . ')', $errno));
}
// set socket to non-blocking and immediately try to send (fill write buffer)
\stream_set_blocking($socket, \false);
$written = @\fwrite($socket, $queryData);
if ($written !== \strlen($queryData)) {
\set_error_handler(function ($_, $error) use(&$errno, &$errstr) {
// Write may potentially fail, but most common errors are already caught by connection check above.
// Among others, macOS is known to report here when trying to send to broadcast address.
// This can also be reproduced by writing data exceeding `stream_set_chunk_size()` to a server refusing UDP data.
// fwrite(): send of 8192 bytes failed with errno=111 Connection refused
$error = \error_get_last();
\preg_match('/errno=(\\d+) (.+)/', $error['message'], $m);
return \RectorPrefix202209\React\Promise\reject(new \RuntimeException('DNS query for ' . $query->describe() . ' failed: Unable to send query to DNS server ' . $this->nameserver . ' (' . (isset($m[2]) ? $m[2] : $error['message']) . ')', isset($m[1]) ? (int) $m[1] : 0));
\preg_match('/errno=(\\d+) (.+)/', $error, $m);
$errno = isset($m[1]) ? (int) $m[1] : 0;
$errstr = isset($m[2]) ? $m[2] : $error;
});
$written = \fwrite($socket, $queryData);
\restore_error_handler();
if ($written !== \strlen($queryData)) {
return \RectorPrefix202209\React\Promise\reject(new \RuntimeException('DNS query for ' . $query->describe() . ' failed: Unable to send query to DNS server ' . $this->nameserver . ' (' . $errstr . ')', $errno));
}
$loop = $this->loop;
$deferred = new Deferred(function () use($loop, $socket, $query) {