Updated Rector to commit 2ba0aa6297b0ccc405564cb76c9f9fb939ac8348

2ba0aa6297 syntax
This commit is contained in:
Tomas Votruba 2022-10-13 02:02:59 +00:00
parent 078b535f61
commit cf91d46f0b
16 changed files with 254 additions and 52 deletions

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '68a349061e4733a1708ee272bce2f75a35042021';
public const PACKAGE_VERSION = '2ba0aa6297b0ccc405564cb76c9f9fb939ac8348';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-10-09 09:55:59';
public const RELEASE_DATE = '2022-10-13 03:58:22';
/**
* @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 ComposerAutoloaderInitf3314a8d7ded35702d1dab21d9ced1e5::getLoader();
return ComposerAutoloaderInite0901a27c49417dbd79530c719100c95::getLoader();

View File

@ -31,6 +31,7 @@ return array(
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\MethodTagValueNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\MethodTagValueParameterNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueParameterNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\MixinTagValueNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/MixinTagValueNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\ParamOutTagValueNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamOutTagValueNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\ParamTagValueNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamTagValueNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\PhpDocChildNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocChildNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\PhpDocNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocNode.php',
@ -2057,6 +2058,7 @@ return array(
'Rector\\PHPUnit\\Rector\\Class_\\AddSeeTestAnnotationRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\ArrayArgumentToDataProviderRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\ConstructClassMethodToSetUpTestCaseRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\ProphecyPHPDocRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/ProphecyPHPDocRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\RemoveDataProviderTestPrefixRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/RemoveDataProviderTestPrefixRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\TestListenerToHooksRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Class_/TestListenerToHooksRector.php',
'Rector\\PHPUnit\\Rector\\Foreach_\\SimplifyForeachInstanceOfRector' => $vendorDir . '/rector/rector-phpunit/src/Rector/Foreach_/SimplifyForeachInstanceOfRector.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitf3314a8d7ded35702d1dab21d9ced1e5
class ComposerAutoloaderInite0901a27c49417dbd79530c719100c95
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitf3314a8d7ded35702d1dab21d9ced1e5
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitf3314a8d7ded35702d1dab21d9ced1e5', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInite0901a27c49417dbd79530c719100c95', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitf3314a8d7ded35702d1dab21d9ced1e5', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInite0901a27c49417dbd79530c719100c95', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitf3314a8d7ded35702d1dab21d9ced1e5::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInite0901a27c49417dbd79530c719100c95::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitf3314a8d7ded35702d1dab21d9ced1e5::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInite0901a27c49417dbd79530c719100c95::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiref3314a8d7ded35702d1dab21d9ced1e5($fileIdentifier, $file);
composerRequiree0901a27c49417dbd79530c719100c95($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitf3314a8d7ded35702d1dab21d9ced1e5
* @param string $file
* @return void
*/
function composerRequiref3314a8d7ded35702d1dab21d9ced1e5($fileIdentifier, $file)
function composerRequiree0901a27c49417dbd79530c719100c95($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 ComposerStaticInitf3314a8d7ded35702d1dab21d9ced1e5
class ComposerStaticInite0901a27c49417dbd79530c719100c95
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -286,6 +286,7 @@ class ComposerStaticInitf3314a8d7ded35702d1dab21d9ced1e5
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\MethodTagValueNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\MethodTagValueParameterNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/MethodTagValueParameterNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\MixinTagValueNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/MixinTagValueNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\ParamOutTagValueNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamOutTagValueNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\ParamTagValueNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/ParamTagValueNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\PhpDocChildNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocChildNode.php',
'PHPStan\\PhpDocParser\\Ast\\PhpDoc\\PhpDocNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocNode.php',
@ -2312,6 +2313,7 @@ class ComposerStaticInitf3314a8d7ded35702d1dab21d9ced1e5
'Rector\\PHPUnit\\Rector\\Class_\\AddSeeTestAnnotationRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/AddSeeTestAnnotationRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\ArrayArgumentToDataProviderRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/ArrayArgumentToDataProviderRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\ConstructClassMethodToSetUpTestCaseRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/ConstructClassMethodToSetUpTestCaseRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\ProphecyPHPDocRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/ProphecyPHPDocRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\RemoveDataProviderTestPrefixRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/RemoveDataProviderTestPrefixRector.php',
'Rector\\PHPUnit\\Rector\\Class_\\TestListenerToHooksRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Class_/TestListenerToHooksRector.php',
'Rector\\PHPUnit\\Rector\\Foreach_\\SimplifyForeachInstanceOfRector' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Rector/Foreach_/SimplifyForeachInstanceOfRector.php',
@ -3088,9 +3090,9 @@ class ComposerStaticInitf3314a8d7ded35702d1dab21d9ced1e5
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitf3314a8d7ded35702d1dab21d9ced1e5::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf3314a8d7ded35702d1dab21d9ced1e5::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf3314a8d7ded35702d1dab21d9ced1e5::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInite0901a27c49417dbd79530c719100c95::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInite0901a27c49417dbd79530c719100c95::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInite0901a27c49417dbd79530c719100c95::$classMap;
}, null, ClassLoader::class);
}

View File

@ -685,17 +685,17 @@
},
{
"name": "phpstan\/phpdoc-parser",
"version": "1.9.0",
"version_normalized": "1.9.0.0",
"version": "1.10.0",
"version_normalized": "1.10.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/phpstan\/phpdoc-parser.git",
"reference": "5f7eb9724b0ae386b922f34b62b3b55fee3b26cd"
"reference": "87fa2d526e56737a2ae8fa201a61b15efae59b8a"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpdoc-parser\/zipball\/5f7eb9724b0ae386b922f34b62b3b55fee3b26cd",
"reference": "5f7eb9724b0ae386b922f34b62b3b55fee3b26cd",
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpdoc-parser\/zipball\/87fa2d526e56737a2ae8fa201a61b15efae59b8a",
"reference": "87fa2d526e56737a2ae8fa201a61b15efae59b8a",
"shasum": ""
},
"require": {
@ -710,7 +710,7 @@
"phpunit\/phpunit": "^9.5",
"symfony\/process": "^5.2"
},
"time": "2022-10-06T11:32:36+00:00",
"time": "2022-10-12T19:19:18+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -727,7 +727,7 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https:\/\/github.com\/phpstan\/phpdoc-parser\/issues",
"source": "https:\/\/github.com\/phpstan\/phpdoc-parser\/tree\/1.9.0"
"source": "https:\/\/github.com\/phpstan\/phpdoc-parser\/tree\/1.10.0"
},
"install-path": "..\/phpstan\/phpdoc-parser"
},
@ -2127,12 +2127,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "963c24df5d7c459b4fb9b82f2e7c59644f66b306"
"reference": "5568edaff83ae5ece8eec7bc8e6bfa61e1074d8f"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/963c24df5d7c459b4fb9b82f2e7c59644f66b306",
"reference": "963c24df5d7c459b4fb9b82f2e7c59644f66b306",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/5568edaff83ae5ece8eec7bc8e6bfa61e1074d8f",
"reference": "5568edaff83ae5ece8eec7bc8e6bfa61e1074d8f",
"shasum": ""
},
"require": {
@ -2158,7 +2158,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-09-21T17:56:12+00:00",
"time": "2022-10-09T18:39:43+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -2196,12 +2196,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "947b1bac3f5a996599424fd70e7d346227705f00"
"reference": "39f8c399f0c686afa2643f2a351993050fff8c4e"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/947b1bac3f5a996599424fd70e7d346227705f00",
"reference": "947b1bac3f5a996599424fd70e7d346227705f00",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/39f8c399f0c686afa2643f2a351993050fff8c4e",
"reference": "39f8c399f0c686afa2643f2a351993050fff8c4e",
"shasum": ""
},
"require": {
@ -2232,7 +2232,7 @@
"symplify\/rule-doc-generator": "^11.1",
"symplify\/vendor-patches": "^11.1"
},
"time": "2022-10-09T07:56:31+00:00",
"time": "2022-10-10T18:26:15+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -2414,17 +2414,17 @@
},
{
"name": "symfony\/console",
"version": "v6.1.5",
"version_normalized": "6.1.5.0",
"version": "v6.1.6",
"version_normalized": "6.1.6.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/console.git",
"reference": "17524a64ebcfab68d237bbed247e9a9917747096"
"reference": "7fa3b9cf17363468795e539231a5c91b02b608fc"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/17524a64ebcfab68d237bbed247e9a9917747096",
"reference": "17524a64ebcfab68d237bbed247e9a9917747096",
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/7fa3b9cf17363468795e539231a5c91b02b608fc",
"reference": "7fa3b9cf17363468795e539231a5c91b02b608fc",
"shasum": ""
},
"require": {
@ -2459,7 +2459,7 @@
"symfony\/lock": "",
"symfony\/process": ""
},
"time": "2022-09-03T14:24:42+00:00",
"time": "2022-10-07T08:04:03+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -2493,7 +2493,7 @@
"terminal"
],
"support": {
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.1.5"
"source": "https:\/\/github.com\/symfony\/console\/tree\/v6.1.6"
},
"funding": [
{
@ -3019,17 +3019,17 @@
},
{
"name": "symfony\/string",
"version": "v6.1.5",
"version_normalized": "6.1.5.0",
"version": "v6.1.6",
"version_normalized": "6.1.6.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/string.git",
"reference": "17c08b068176996a1d7db8d00ffae3c248267016"
"reference": "7e7e0ff180d4c5a6636eaad57b65092014b61864"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/string\/zipball\/17c08b068176996a1d7db8d00ffae3c248267016",
"reference": "17c08b068176996a1d7db8d00ffae3c248267016",
"url": "https:\/\/api.github.com\/repos\/symfony\/string\/zipball\/7e7e0ff180d4c5a6636eaad57b65092014b61864",
"reference": "7e7e0ff180d4c5a6636eaad57b65092014b61864",
"shasum": ""
},
"require": {
@ -3048,7 +3048,7 @@
"symfony\/translation-contracts": "^2.0|^3.0",
"symfony\/var-exporter": "^5.4|^6.0"
},
"time": "2022-09-02T08:05:20+00:00",
"time": "2022-10-10T09:34:31+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -3087,7 +3087,7 @@
"utf8"
],
"support": {
"source": "https:\/\/github.com\/symfony\/string\/tree\/v6.1.5"
"source": "https:\/\/github.com\/symfony\/string\/tree\/v6.1.6"
},
"funding": [
{

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,28 @@
<?php
declare (strict_types=1);
namespace PHPStan\PhpDocParser\Ast\PhpDoc;
use PHPStan\PhpDocParser\Ast\NodeAttributes;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use function trim;
class ParamOutTagValueNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode
{
use NodeAttributes;
/** @var TypeNode */
public $type;
/** @var string */
public $parameterName;
/** @var string (may be empty) */
public $description;
public function __construct(TypeNode $type, string $parameterName, string $description)
{
$this->type = $type;
$this->parameterName = $parameterName;
$this->description = $description;
}
public function __toString() : string
{
return trim("{$this->type} {$this->parameterName} {$this->description}");
}
}

View File

@ -228,6 +228,15 @@ class PhpDocNode implements Node
return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\SelfOutTagValueNode;
});
}
/**
* @return ParamOutTagValueNode[]
*/
public function getParamOutTypeTagValues(string $tagName = '@param-out') : array
{
return array_filter(array_column($this->getTagsByName($tagName), 'value'), static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $value) : bool {
return $value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamOutTagValueNode;
});
}
public function __toString() : string
{
$children = array_map(static function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $child) : string {

View File

@ -179,6 +179,11 @@ class PhpDocParser
case '@psalm-self-out':
$tagValue = $this->parseSelfOutTagValue($tokens);
break;
case '@param-out':
case '@phpstan-param-out':
case '@psalm-param-out':
$tagValue = $this->parseParamOutTagValue($tokens);
break;
default:
$tagValue = new Ast\PhpDoc\GenericTagValueNode($this->parseOptionalDescription($tokens));
break;
@ -396,6 +401,13 @@ class PhpDocParser
$description = $this->parseOptionalDescription($tokens);
return new Ast\PhpDoc\SelfOutTagValueNode($type, $description);
}
private function parseParamOutTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\ParamOutTagValueNode
{
$type = $this->typeParser->parse($tokens);
$parameterName = $this->parseRequiredVariableName($tokens);
$description = $this->parseOptionalDescription($tokens);
return new Ast\PhpDoc\ParamOutTagValueNode($type, $parameterName, $description);
}
private function parseOptionalVariableName(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : string
{
if ($tokens->isCurrentTokenType(Lexer::TOKEN_VARIABLE)) {

View File

@ -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/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c56069f'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main d75c674'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2decdcf'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9c21f5f'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 294de0c'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 963c24d'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 947b1ba'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main c56069f'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main d75c674'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2decdcf'), 'rector/rector-php-parser' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-php-parser', 'relative_install_path' => '../../rector-php-parser', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 9c21f5f'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 294de0c'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5568eda'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 39f8c39'));
private function __construct()
{
}

View File

@ -0,0 +1,147 @@
<?php
declare (strict_types=1);
namespace Rector\PHPUnit\Rector\Class_;
use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Property;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
use Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode;
use Rector\Core\NodeManipulator\ClassMethodPropertyFetchManipulator;
use Rector\Core\Rector\AbstractRector;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\PHPUnit\Tests\Rector\Class_\ProphecyPHPDocRector\ProphecyPHPDocRectorTest
*/
class ProphecyPHPDocRector extends AbstractRector
{
/**
* @readonly
* @var \Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer
*/
private $testsNodeAnalyzer;
/**
* @readonly
* @var \Rector\Core\NodeManipulator\ClassMethodPropertyFetchManipulator
*/
private $classMethodPropertyFetchManipulator;
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, ClassMethodPropertyFetchManipulator $classMethodPropertyFetchManipulator)
{
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
$this->classMethodPropertyFetchManipulator = $classMethodPropertyFetchManipulator;
}
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Add correct @var to ObjectProphecy instances based on $this->prophesize() call.', [new CodeSample(<<<'CODE_SAMPLE'
class HelloTest extends TestCase
{
/**
* @var SomeClass
*/
private $propesizedObject;
public function setUp(): void
{
$this->propesizedObject = $this->prophesize(SomeClass::class);
}
}
CODE_SAMPLE
, <<<'CODE_SAMPLE'
class HelloTest extends TestCase
{
/**
* @var ObjectProphecy<SomeClass>
*/
private $propesizedObject;
public function setUp(): void
{
$this->propesizedObject = $this->prophesize(SomeClass::class);
}
}
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [Class_::class];
}
/**
* @param Class_ $node
*/
public function refactor(Node $node) : ?\PhpParser\Node\Stmt\Class_
{
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
return null;
}
$hasChanged = \false;
foreach ($node->getProperties() as $property) {
$propertyName = $this->getName($property);
$toPropertyAssignExprs = $this->findAssignToPropertyName($node, $propertyName);
foreach ($toPropertyAssignExprs as $toPropertyAssignExpr) {
$prophesizedObjectArg = $this->matchThisProphesizeMethodCallFirstArg($toPropertyAssignExpr);
if (!$prophesizedObjectArg instanceof Arg) {
continue;
}
$prophesizedClass = $this->valueResolver->getValue($prophesizedObjectArg->value);
if (!\is_string($prophesizedClass)) {
return null;
}
$this->changePropertyDoc($property, $prophesizedClass);
$hasChanged = \true;
break;
}
}
if ($hasChanged) {
return $node;
}
return null;
}
private function matchThisProphesizeMethodCallFirstArg(Expr $expr) : ?Arg
{
if (!$expr instanceof MethodCall) {
return null;
}
$var = $expr->var;
if (!$var instanceof Variable) {
return null;
}
if (!$this->isName($var, 'this')) {
return null;
}
if (!$this->isName($expr->name, 'prophesize')) {
return null;
}
return $expr->getArgs()[0];
}
/**
* @return Expr[]
*/
private function findAssignToPropertyName(Class_ $class, string $propertyName) : array
{
$assignExprs = [];
foreach ($class->getMethods() as $classMethod) {
$currentAssignExprs = $this->classMethodPropertyFetchManipulator->findAssignsToPropertyName($classMethod, $propertyName);
$assignExprs = \array_merge($assignExprs, $currentAssignExprs);
}
return $assignExprs;
}
private function changePropertyDoc(Property $property, string $prophesizedClass) : void
{
$propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
// replace old one
$propertyPhpDocInfo->removeByType(VarTagValueNode::class);
$propertyPhpDocInfo->addTagValueNode(new VarTagValueNode(new GenericTypeNode(new FullyQualifiedIdentifierTypeNode('Prophecy\\Prophecy\\ObjectProphecy'), [new FullyQualifiedIdentifierTypeNode($prophesizedClass)]), '', ''));
}
}

View File

@ -139,7 +139,7 @@ CODE_SAMPLE
}
}
} else {
$class->stmts = \array_merge($class->stmts, [$defaultDescriptionProperty]);
$class->stmts = \array_merge([$defaultDescriptionProperty], $class->stmts);
}
return $class;
}

View File

@ -113,6 +113,8 @@ abstract class Helper implements HelperInterface
$string = $formatter->format($string ?? '');
// remove already formatted characters
$string = \preg_replace("/\x1b\\[[^m]*m/", '', $string ?? '');
// remove terminal hyperlinks
$string = \preg_replace('/\\033]8;[^;]*;[^\\033]*\\033\\\\/', '', $string ?? '');
$formatter->setDecorated($isDecorated);
return $string;
}

View File

@ -5,7 +5,7 @@ namespace RectorPrefix202210;
/*
* This file has been auto-generated by the Symfony String Component for internal use.
*
* Unicode version: 14.0.0
* Date: 2021-09-17T09:20:30+02:00
* Unicode version: 15.0.0
* Date: 2022-10-05T17:16:36+02:00
*/
return [[4352, 4447], [8986, 8987], [9001, 9001], [9002, 9002], [9193, 9196], [9200, 9200], [9203, 9203], [9725, 9726], [9748, 9749], [9800, 9811], [9855, 9855], [9875, 9875], [9889, 9889], [9898, 9899], [9917, 9918], [9924, 9925], [9934, 9934], [9940, 9940], [9962, 9962], [9970, 9971], [9973, 9973], [9978, 9978], [9981, 9981], [9989, 9989], [9994, 9995], [10024, 10024], [10060, 10060], [10062, 10062], [10067, 10069], [10071, 10071], [10133, 10135], [10160, 10160], [10175, 10175], [11035, 11036], [11088, 11088], [11093, 11093], [11904, 11929], [11931, 12019], [12032, 12245], [12272, 12283], [12288, 12288], [12289, 12291], [12292, 12292], [12293, 12293], [12294, 12294], [12295, 12295], [12296, 12296], [12297, 12297], [12298, 12298], [12299, 12299], [12300, 12300], [12301, 12301], [12302, 12302], [12303, 12303], [12304, 12304], [12305, 12305], [12306, 12307], [12308, 12308], [12309, 12309], [12310, 12310], [12311, 12311], [12312, 12312], [12313, 12313], [12314, 12314], [12315, 12315], [12316, 12316], [12317, 12317], [12318, 12319], [12320, 12320], [12321, 12329], [12330, 12333], [12334, 12335], [12336, 12336], [12337, 12341], [12342, 12343], [12344, 12346], [12347, 12347], [12348, 12348], [12349, 12349], [12350, 12350], [12353, 12438], [12441, 12442], [12443, 12444], [12445, 12446], [12447, 12447], [12448, 12448], [12449, 12538], [12539, 12539], [12540, 12542], [12543, 12543], [12549, 12591], [12593, 12686], [12688, 12689], [12690, 12693], [12694, 12703], [12704, 12735], [12736, 12771], [12784, 12799], [12800, 12830], [12832, 12841], [12842, 12871], [12880, 12880], [12881, 12895], [12896, 12927], [12928, 12937], [12938, 12976], [12977, 12991], [12992, 13055], [13056, 13311], [13312, 19903], [19968, 40959], [40960, 40980], [40981, 40981], [40982, 42124], [42128, 42182], [43360, 43388], [44032, 55203], [63744, 64109], [64110, 64111], [64112, 64217], [64218, 64255], [65040, 65046], [65047, 65047], [65048, 65048], [65049, 65049], [65072, 65072], [65073, 65074], [65075, 65076], [65077, 65077], [65078, 65078], [65079, 65079], [65080, 65080], [65081, 65081], [65082, 65082], [65083, 65083], [65084, 65084], [65085, 65085], [65086, 65086], [65087, 65087], [65088, 65088], [65089, 65089], [65090, 65090], [65091, 65091], [65092, 65092], [65093, 65094], [65095, 65095], [65096, 65096], [65097, 65100], [65101, 65103], [65104, 65106], [65108, 65111], [65112, 65112], [65113, 65113], [65114, 65114], [65115, 65115], [65116, 65116], [65117, 65117], [65118, 65118], [65119, 65121], [65122, 65122], [65123, 65123], [65124, 65126], [65128, 65128], [65129, 65129], [65130, 65131], [65281, 65283], [65284, 65284], [65285, 65287], [65288, 65288], [65289, 65289], [65290, 65290], [65291, 65291], [65292, 65292], [65293, 65293], [65294, 65295], [65296, 65305], [65306, 65307], [65308, 65310], [65311, 65312], [65313, 65338], [65339, 65339], [65340, 65340], [65341, 65341], [65342, 65342], [65343, 65343], [65344, 65344], [65345, 65370], [65371, 65371], [65372, 65372], [65373, 65373], [65374, 65374], [65375, 65375], [65376, 65376], [65504, 65505], [65506, 65506], [65507, 65507], [65508, 65508], [65509, 65510], [94176, 94177], [94178, 94178], [94179, 94179], [94180, 94180], [94192, 94193], [94208, 100343], [100352, 101119], [101120, 101589], [101632, 101640], [110576, 110579], [110581, 110587], [110589, 110590], [110592, 110847], [110848, 110882], [110928, 110930], [110948, 110951], [110960, 111355], [126980, 126980], [127183, 127183], [127374, 127374], [127377, 127386], [127488, 127490], [127504, 127547], [127552, 127560], [127568, 127569], [127584, 127589], [127744, 127776], [127789, 127797], [127799, 127868], [127870, 127891], [127904, 127946], [127951, 127955], [127968, 127984], [127988, 127988], [127992, 127994], [127995, 127999], [128000, 128062], [128064, 128064], [128066, 128252], [128255, 128317], [128331, 128334], [128336, 128359], [128378, 128378], [128405, 128406], [128420, 128420], [128507, 128511], [128512, 128591], [128640, 128709], [128716, 128716], [128720, 128722], [128725, 128727], [128733, 128735], [128747, 128748], [128756, 128764], [128992, 129003], [129008, 129008], [129292, 129338], [129340, 129349], [129351, 129535], [129648, 129652], [129656, 129660], [129664, 129670], [129680, 129708], [129712, 129722], [129728, 129733], [129744, 129753], [129760, 129767], [129776, 129782], [131072, 173791], [173792, 173823], [173824, 177976], [177977, 177983], [177984, 178205], [178206, 178207], [178208, 183969], [183970, 183983], [183984, 191456], [191457, 194559], [194560, 195101], [195102, 195103], [195104, 196605], [196608, 201546], [201547, 262141]];
return [[4352, 4447], [8986, 8987], [9001, 9001], [9002, 9002], [9193, 9196], [9200, 9200], [9203, 9203], [9725, 9726], [9748, 9749], [9800, 9811], [9855, 9855], [9875, 9875], [9889, 9889], [9898, 9899], [9917, 9918], [9924, 9925], [9934, 9934], [9940, 9940], [9962, 9962], [9970, 9971], [9973, 9973], [9978, 9978], [9981, 9981], [9989, 9989], [9994, 9995], [10024, 10024], [10060, 10060], [10062, 10062], [10067, 10069], [10071, 10071], [10133, 10135], [10160, 10160], [10175, 10175], [11035, 11036], [11088, 11088], [11093, 11093], [11904, 11929], [11931, 12019], [12032, 12245], [12272, 12283], [12288, 12288], [12289, 12291], [12292, 12292], [12293, 12293], [12294, 12294], [12295, 12295], [12296, 12296], [12297, 12297], [12298, 12298], [12299, 12299], [12300, 12300], [12301, 12301], [12302, 12302], [12303, 12303], [12304, 12304], [12305, 12305], [12306, 12307], [12308, 12308], [12309, 12309], [12310, 12310], [12311, 12311], [12312, 12312], [12313, 12313], [12314, 12314], [12315, 12315], [12316, 12316], [12317, 12317], [12318, 12319], [12320, 12320], [12321, 12329], [12330, 12333], [12334, 12335], [12336, 12336], [12337, 12341], [12342, 12343], [12344, 12346], [12347, 12347], [12348, 12348], [12349, 12349], [12350, 12350], [12353, 12438], [12441, 12442], [12443, 12444], [12445, 12446], [12447, 12447], [12448, 12448], [12449, 12538], [12539, 12539], [12540, 12542], [12543, 12543], [12549, 12591], [12593, 12686], [12688, 12689], [12690, 12693], [12694, 12703], [12704, 12735], [12736, 12771], [12784, 12799], [12800, 12830], [12832, 12841], [12842, 12871], [12880, 12880], [12881, 12895], [12896, 12927], [12928, 12937], [12938, 12976], [12977, 12991], [12992, 13055], [13056, 13311], [13312, 19903], [19968, 40959], [40960, 40980], [40981, 40981], [40982, 42124], [42128, 42182], [43360, 43388], [44032, 55203], [63744, 64109], [64110, 64111], [64112, 64217], [64218, 64255], [65040, 65046], [65047, 65047], [65048, 65048], [65049, 65049], [65072, 65072], [65073, 65074], [65075, 65076], [65077, 65077], [65078, 65078], [65079, 65079], [65080, 65080], [65081, 65081], [65082, 65082], [65083, 65083], [65084, 65084], [65085, 65085], [65086, 65086], [65087, 65087], [65088, 65088], [65089, 65089], [65090, 65090], [65091, 65091], [65092, 65092], [65093, 65094], [65095, 65095], [65096, 65096], [65097, 65100], [65101, 65103], [65104, 65106], [65108, 65111], [65112, 65112], [65113, 65113], [65114, 65114], [65115, 65115], [65116, 65116], [65117, 65117], [65118, 65118], [65119, 65121], [65122, 65122], [65123, 65123], [65124, 65126], [65128, 65128], [65129, 65129], [65130, 65131], [65281, 65283], [65284, 65284], [65285, 65287], [65288, 65288], [65289, 65289], [65290, 65290], [65291, 65291], [65292, 65292], [65293, 65293], [65294, 65295], [65296, 65305], [65306, 65307], [65308, 65310], [65311, 65312], [65313, 65338], [65339, 65339], [65340, 65340], [65341, 65341], [65342, 65342], [65343, 65343], [65344, 65344], [65345, 65370], [65371, 65371], [65372, 65372], [65373, 65373], [65374, 65374], [65375, 65375], [65376, 65376], [65504, 65505], [65506, 65506], [65507, 65507], [65508, 65508], [65509, 65510], [94176, 94177], [94178, 94178], [94179, 94179], [94180, 94180], [94192, 94193], [94208, 100343], [100352, 101119], [101120, 101589], [101632, 101640], [110576, 110579], [110581, 110587], [110589, 110590], [110592, 110847], [110848, 110882], [110898, 110898], [110928, 110930], [110933, 110933], [110948, 110951], [110960, 111355], [126980, 126980], [127183, 127183], [127374, 127374], [127377, 127386], [127488, 127490], [127504, 127547], [127552, 127560], [127568, 127569], [127584, 127589], [127744, 127776], [127789, 127797], [127799, 127868], [127870, 127891], [127904, 127946], [127951, 127955], [127968, 127984], [127988, 127988], [127992, 127994], [127995, 127999], [128000, 128062], [128064, 128064], [128066, 128252], [128255, 128317], [128331, 128334], [128336, 128359], [128378, 128378], [128405, 128406], [128420, 128420], [128507, 128511], [128512, 128591], [128640, 128709], [128716, 128716], [128720, 128722], [128725, 128727], [128732, 128735], [128747, 128748], [128756, 128764], [128992, 129003], [129008, 129008], [129292, 129338], [129340, 129349], [129351, 129535], [129648, 129660], [129664, 129672], [129680, 129725], [129727, 129733], [129742, 129755], [129760, 129768], [129776, 129784], [131072, 173791], [173792, 173823], [173824, 177977], [177978, 177983], [177984, 178205], [178206, 178207], [178208, 183969], [183970, 183983], [183984, 191456], [191457, 194559], [194560, 195101], [195102, 195103], [195104, 196605], [196608, 201546], [201547, 201551], [201552, 205743], [205744, 262141]];

File diff suppressed because one or more lines are too long