mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 58abec4c5663a5d92ac6cd0a2eef6aace80ab408
58abec4c56
[automated] Apply Coding Standard (#5665)
This commit is contained in:
parent
a958e6bf2a
commit
d34d554ada
|
@ -1802,12 +1802,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "cdbe3907cd64fe07de118b0b722d7d84802988d1"
|
||||
"reference": "1de46189c807347a5c57e74a3e2a7f12ed60782e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/cdbe3907cd64fe07de118b0b722d7d84802988d1",
|
||||
"reference": "cdbe3907cd64fe07de118b0b722d7d84802988d1",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/1de46189c807347a5c57e74a3e2a7f12ed60782e",
|
||||
"reference": "1de46189c807347a5c57e74a3e2a7f12ed60782e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1830,7 +1830,7 @@
|
|||
"tomasvotruba\/class-leak": "^0.2",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2024-02-12T14:24:54+00:00",
|
||||
"time": "2024-02-27T10:47:52+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
@ -1998,17 +1998,17 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony\/console",
|
||||
"version": "v6.4.3",
|
||||
"version_normalized": "6.4.3.0",
|
||||
"version": "v6.4.4",
|
||||
"version_normalized": "6.4.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symfony\/console.git",
|
||||
"reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e"
|
||||
"reference": "0d9e4eb5ad413075624378f474c4167ea202de78"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e",
|
||||
"reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e",
|
||||
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/0d9e4eb5ad413075624378f474c4167ea202de78",
|
||||
"reference": "0d9e4eb5ad413075624378f474c4167ea202de78",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2041,7 +2041,7 @@
|
|||
"symfony\/stopwatch": "^5.4|^6.0|^7.0",
|
||||
"symfony\/var-dumper": "^5.4|^6.0|^7.0"
|
||||
},
|
||||
"time": "2024-01-23T14:51:35+00:00",
|
||||
"time": "2024-02-22T20:27:10+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"patches_applied": [
|
||||
|
@ -2080,7 +2080,7 @@
|
|||
"terminal"
|
||||
],
|
||||
"support": {
|
||||
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.4.3"
|
||||
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.4.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -2386,23 +2386,23 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony\/process",
|
||||
"version": "v6.4.3",
|
||||
"version_normalized": "6.4.3.0",
|
||||
"version": "v6.4.4",
|
||||
"version_normalized": "6.4.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symfony\/process.git",
|
||||
"reference": "31642b0818bfcff85930344ef93193f8c607e0a3"
|
||||
"reference": "710e27879e9be3395de2b98da3f52a946039f297"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symfony\/process\/zipball\/31642b0818bfcff85930344ef93193f8c607e0a3",
|
||||
"reference": "31642b0818bfcff85930344ef93193f8c607e0a3",
|
||||
"url": "https:\/\/api.github.com\/repos\/symfony\/process\/zipball\/710e27879e9be3395de2b98da3f52a946039f297",
|
||||
"reference": "710e27879e9be3395de2b98da3f52a946039f297",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"time": "2024-01-23T14:51:35+00:00",
|
||||
"time": "2024-02-20T12:31:00+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
@ -2430,7 +2430,7 @@
|
|||
"description": "Executes commands in sub-processes",
|
||||
"homepage": "https:\/\/symfony.com",
|
||||
"support": {
|
||||
"source": "https:\/\/github.com\/symfony\/process\/tree\/v6.4.3"
|
||||
"source": "https:\/\/github.com\/symfony\/process\/tree\/v6.4.4"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
|||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main a9f411d'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 68e0635'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main cdbe390'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 59edb62'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main a9f411d'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 68e0635'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 1de4618'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 59edb62'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Rector\PHPUnit\CodeQuality\Rector\MethodCall;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
|
||||
|
@ -81,10 +82,15 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
$callArgs = $node->getArgs();
|
||||
if (!$callArgs[0]->value instanceof MethodCall) {
|
||||
$firstArg = $callArgs[0];
|
||||
// special case for new map
|
||||
if ($firstArg->value instanceof New_) {
|
||||
return $this->refactorNew($firstArg->value, $node);
|
||||
}
|
||||
if (!$firstArg->value instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
$nestedMethodCall = $callArgs[0]->value;
|
||||
$nestedMethodCall = $firstArg->value;
|
||||
foreach (self::NESTED_METHOD_TO_RENAME_MAP as $oldMethodName => $newParentMethodName) {
|
||||
if (!$this->isName($nestedMethodCall->name, $oldMethodName)) {
|
||||
continue;
|
||||
|
@ -96,4 +102,17 @@ CODE_SAMPLE
|
|||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $call
|
||||
* @return null|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall
|
||||
*/
|
||||
private function refactorNew(New_ $new, $call)
|
||||
{
|
||||
if (!$this->isName($new->class, 'PHPUnit\\Framework\\MockObject\\Stub\\ReturnValueMap')) {
|
||||
return null;
|
||||
}
|
||||
$call->name = new Identifier('willReturnMap');
|
||||
$call->args = $new->args;
|
||||
return $call;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -422,16 +422,7 @@ class QuestionHelper extends Helper
|
|||
if (isset(self::$stdinIsInteractive)) {
|
||||
return self::$stdinIsInteractive;
|
||||
}
|
||||
if (\function_exists('stream_isatty')) {
|
||||
return self::$stdinIsInteractive = @\stream_isatty(\fopen('php://stdin', 'r'));
|
||||
}
|
||||
if (\function_exists('posix_isatty')) {
|
||||
return self::$stdinIsInteractive = @\posix_isatty(\fopen('php://stdin', 'r'));
|
||||
}
|
||||
if (!\function_exists('shell_exec')) {
|
||||
return self::$stdinIsInteractive = \true;
|
||||
}
|
||||
return self::$stdinIsInteractive = (bool) \shell_exec('stty 2> ' . ('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
|
||||
return self::$stdinIsInteractive = @\stream_isatty(\fopen('php://stdin', 'r'));
|
||||
}
|
||||
/**
|
||||
* Reads one or more lines of input and returns what is read.
|
||||
|
|
|
@ -361,7 +361,8 @@ class Table
|
|||
$maxRows = \max(\count($headers), \count($row));
|
||||
for ($i = 0; $i < $maxRows; ++$i) {
|
||||
$cell = (string) ($row[$i] ?? '');
|
||||
$parts = \explode("\n", $cell);
|
||||
$eol = \strpos($cell, "\r\n") !== \false ? "\r\n" : "\n";
|
||||
$parts = \explode($eol, $cell);
|
||||
foreach ($parts as $idx => $part) {
|
||||
if ($headers && !$containsColspan) {
|
||||
if (0 === $idx) {
|
||||
|
@ -577,9 +578,10 @@ class Table
|
|||
if (\strpos($cell ?? '', "\n") === \false) {
|
||||
continue;
|
||||
}
|
||||
$escaped = \implode("\n", \array_map(\Closure::fromCallable([OutputFormatter::class, 'escapeTrailingBackslash']), \explode("\n", $cell)));
|
||||
$eol = \strpos($cell ?? '', "\r\n") !== \false ? "\r\n" : "\n";
|
||||
$escaped = \implode($eol, \array_map(\Closure::fromCallable([OutputFormatter::class, 'escapeTrailingBackslash']), \explode($eol, $cell)));
|
||||
$cell = $cell instanceof TableCell ? new TableCell($escaped, ['colspan' => $cell->getColspan()]) : $escaped;
|
||||
$lines = \explode("\n", \str_replace("\n", "<fg=default;bg=default></>\n", $cell));
|
||||
$lines = \explode($eol, \str_replace($eol, '<fg=default;bg=default></>' . $eol, $cell));
|
||||
foreach ($lines as $lineKey => $line) {
|
||||
if ($colspan > 1) {
|
||||
$line = new TableCell($line, ['colspan' => $colspan]);
|
||||
|
@ -636,8 +638,9 @@ class Table
|
|||
$nbLines = $cell->getRowspan() - 1;
|
||||
$lines = [$cell];
|
||||
if (\strpos($cell, "\n") !== \false) {
|
||||
$lines = \explode("\n", \str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
|
||||
$nbLines = \count($lines) > $nbLines ? \substr_count($cell, "\n") : $nbLines;
|
||||
$eol = \strpos($cell, "\r\n") !== \false ? "\r\n" : "\n";
|
||||
$lines = \explode($eol, \str_replace($eol, '<fg=default;bg=default>' . $eol . '</>', $cell));
|
||||
$nbLines = \count($lines) > $nbLines ? \substr_count($cell, $eol) : $nbLines;
|
||||
$rows[$line][$column] = new TableCell($lines[0], ['colspan' => $cell->getColspan(), 'style' => $cell->getStyle()]);
|
||||
unset($lines[0]);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ class InputOption
|
|||
if (empty($name)) {
|
||||
throw new InvalidArgumentException('An option name cannot be empty.');
|
||||
}
|
||||
if ('' === $shortcut || [] === $shortcut) {
|
||||
if ('' === $shortcut || [] === $shortcut || \false === $shortcut) {
|
||||
$shortcut = null;
|
||||
}
|
||||
if (null !== $shortcut) {
|
||||
|
|
|
@ -85,37 +85,21 @@ class StreamOutput extends Output
|
|||
if (isset($_SERVER['NO_COLOR']) || \false !== \getenv('NO_COLOR')) {
|
||||
return \false;
|
||||
}
|
||||
if (!$this->isTty()) {
|
||||
return \false;
|
||||
}
|
||||
if (\DIRECTORY_SEPARATOR === '\\' && \function_exists('sapi_windows_vt100_support') && @\sapi_windows_vt100_support($this->stream)) {
|
||||
return \true;
|
||||
}
|
||||
return 'Hyper' === \getenv('TERM_PROGRAM') || \false !== \getenv('ANSICON') || 'ON' === \getenv('ConEmuANSI') || \strncmp((string) \getenv('TERM'), 'xterm', \strlen('xterm')) === 0;
|
||||
}
|
||||
/**
|
||||
* Checks if the stream is a TTY, i.e; whether the output stream is connected to a terminal.
|
||||
*
|
||||
* Reference: Composer\Util\Platform::isTty
|
||||
* https://github.com/composer/composer
|
||||
*/
|
||||
private function isTty() : bool
|
||||
{
|
||||
// Detect msysgit/mingw and assume this is a tty because detection
|
||||
// does not work correctly, see https://github.com/composer/composer/issues/9690
|
||||
if (\in_array(\strtoupper((string) \getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], \true)) {
|
||||
if (!@\stream_isatty($this->stream) && !\in_array(\strtoupper((string) \getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], \true)) {
|
||||
return \false;
|
||||
}
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && @\sapi_windows_vt100_support($this->stream)) {
|
||||
return \true;
|
||||
}
|
||||
// Modern cross-platform function, includes the fstat fallback so if it is present we trust it
|
||||
if (\function_exists('stream_isatty')) {
|
||||
return \stream_isatty($this->stream);
|
||||
}
|
||||
// Only trusting this if it is positive, otherwise prefer fstat fallback.
|
||||
if (\function_exists('posix_isatty') && \posix_isatty($this->stream)) {
|
||||
if ('Hyper' === \getenv('TERM_PROGRAM') || \false !== \getenv('COLORTERM') || \false !== \getenv('ANSICON') || 'ON' === \getenv('ConEmuANSI')) {
|
||||
return \true;
|
||||
}
|
||||
$stat = @\fstat($this->stream);
|
||||
// Check if formatted mode is S_IFCHR
|
||||
return $stat ? 020000 === ($stat['mode'] & 0170000) : \false;
|
||||
if ('dumb' === ($term = (string) \getenv('TERM'))) {
|
||||
return \false;
|
||||
}
|
||||
// See https://github.com/chalk/supports-color/blob/d4f413efaf8da045c5ab440ed418ef02dbb28bf1/index.js#L157
|
||||
return \preg_match('/^((screen|xterm|vt100|vt220|putty|rxvt|ansi|cygwin|linux).*)|(.*-256(color)?(-bce)?)$/', $term);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class ExecutableFinder
|
|||
}
|
||||
}
|
||||
}
|
||||
$command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v';
|
||||
$command = '\\' === \DIRECTORY_SEPARATOR ? 'where' : 'command -v --';
|
||||
if (\function_exists('exec') && ($executablePath = \strtok(@\exec($command . ' ' . \escapeshellarg($name)), \PHP_EOL)) && @\is_executable($executablePath)) {
|
||||
return $executablePath;
|
||||
}
|
||||
|
|
|
@ -135,6 +135,10 @@ class Process implements \IteratorAggregate
|
|||
* @var int|null
|
||||
*/
|
||||
private $latestSignal;
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $cachedExitCode;
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
|
@ -1183,6 +1187,17 @@ class Process implements \IteratorAggregate
|
|||
}
|
||||
$this->processInformation = \proc_get_status($this->process);
|
||||
$running = $this->processInformation['running'];
|
||||
// In PHP < 8.3, "proc_get_status" only returns the correct exit status on the first call.
|
||||
// Subsequent calls return -1 as the process is discarded. This workaround caches the first
|
||||
// retrieved exit status for consistent results in later calls, mimicking PHP 8.3 behavior.
|
||||
if (\PHP_VERSION_ID < 80300) {
|
||||
if (!isset($this->cachedExitCode) && !$running && -1 !== $this->processInformation['exitcode']) {
|
||||
$this->cachedExitCode = $this->processInformation['exitcode'];
|
||||
}
|
||||
if (isset($this->cachedExitCode) && !$running && -1 === $this->processInformation['exitcode']) {
|
||||
$this->processInformation['exitcode'] = $this->cachedExitCode;
|
||||
}
|
||||
}
|
||||
$this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
|
||||
if ($this->fallbackStatus && $this->isSigchildEnabled()) {
|
||||
$this->processInformation = $this->fallbackStatus + $this->processInformation;
|
||||
|
|
Loading…
Reference in New Issue