Updated Rector to commit be24410a00da07e1aeb4eba8083d0e06f19868a9

be24410a00  [PostRector] Skip remove unused used at @see for Generic tag  (#3562)
This commit is contained in:
Tomas Votruba 2023-04-05 00:15:15 +00:00
parent c2fef6bfc2
commit 288d74ea5d
17 changed files with 110 additions and 48 deletions

View File

@ -5,6 +5,7 @@ namespace Rector\BetterPhpDocParser\PhpDocInfo;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode;
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
@ -414,6 +415,19 @@ final class PhpDocInfo
}
return $resolvedClasses;
}
/**
* @return string[]
*/
public function getGenericTagClassNames() : array
{
/** @var GenericTagValueNode[] $genericTagValueNodes */
$genericTagValueNodes = $this->phpDocNodeByTypeFinder->findByType($this->phpDocNode, GenericTagValueNode::class);
$resolvedClasses = [];
foreach ($genericTagValueNodes as $genericTagValueNode) {
$resolvedClasses[] = $genericTagValueNode->value;
}
return $resolvedClasses;
}
/**
* @return string[]
*/

View File

@ -143,6 +143,8 @@ CODE_SAMPLE
$names = \array_merge($names, $phpDocInfo->getAnnotationClassNames());
$constFetchNodeNames = $phpDocInfo->getConstFetchNodeClassNames();
$names = \array_merge($names, $constFetchNodeNames);
$genericTagClassNames = $phpDocInfo->getGenericTagClassNames();
$names = \array_merge($names, $genericTagClassNames);
});
return $names;
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '1da22824edd107108e087d40233769817a2cbe25';
public const PACKAGE_VERSION = 'be24410a00da07e1aeb4eba8083d0e06f19868a9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-04-04 07:52:59';
public const RELEASE_DATE = '2023-04-05 07:11:07';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

@ -59,6 +59,7 @@ return array(
'PHPStan\\PhpDocParser\\Ast\\Type\\GenericTypeNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/Type/GenericTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\IdentifierTypeNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/Type/IdentifierTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\IntersectionTypeNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/Type/IntersectionTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\InvalidTypeNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/Type/InvalidTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\NullableTypeNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/Type/NullableTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\OffsetAccessTypeNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/Type/OffsetAccessTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\ThisTypeNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/Type/ThisTypeNode.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit4fd1f544aa8f7722ab02524f353da142
class ComposerAutoloaderInit1372064fed4bfb229fc8833f8bd18c76
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit4fd1f544aa8f7722ab02524f353da142
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit4fd1f544aa8f7722ab02524f353da142', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit1372064fed4bfb229fc8833f8bd18c76', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit4fd1f544aa8f7722ab02524f353da142', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit1372064fed4bfb229fc8833f8bd18c76', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit4fd1f544aa8f7722ab02524f353da142::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit1372064fed4bfb229fc8833f8bd18c76::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit4fd1f544aa8f7722ab02524f353da142::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit1372064fed4bfb229fc8833f8bd18c76::$files;
$requireFile = \Closure::bind(static function ($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 ComposerStaticInit4fd1f544aa8f7722ab02524f353da142
class ComposerStaticInit1372064fed4bfb229fc8833f8bd18c76
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -306,6 +306,7 @@ class ComposerStaticInit4fd1f544aa8f7722ab02524f353da142
'PHPStan\\PhpDocParser\\Ast\\Type\\GenericTypeNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/Type/GenericTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\IdentifierTypeNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/Type/IdentifierTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\IntersectionTypeNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/Type/IntersectionTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\InvalidTypeNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/Type/InvalidTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\NullableTypeNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/Type/NullableTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\OffsetAccessTypeNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/Type/OffsetAccessTypeNode.php',
'PHPStan\\PhpDocParser\\Ast\\Type\\ThisTypeNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/Type/ThisTypeNode.php',
@ -3131,9 +3132,9 @@ class ComposerStaticInit4fd1f544aa8f7722ab02524f353da142
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit4fd1f544aa8f7722ab02524f353da142::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit4fd1f544aa8f7722ab02524f353da142::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit4fd1f544aa8f7722ab02524f353da142::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit1372064fed4bfb229fc8833f8bd18c76::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit1372064fed4bfb229fc8833f8bd18c76::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit1372064fed4bfb229fc8833f8bd18c76::$classMap;
}, null, ClassLoader::class);
}

View File

@ -821,17 +821,17 @@
},
{
"name": "phpstan\/phpdoc-parser",
"version": "1.16.1",
"version_normalized": "1.16.1.0",
"version": "1.17.1",
"version_normalized": "1.17.1.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/phpstan\/phpdoc-parser.git",
"reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571"
"reference": "d3753fcb3abc6f78f5de6f72153d4b9c99c72dee"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpdoc-parser\/zipball\/e27e92d939e2e3636f0a1f0afaba59692c0bf571",
"reference": "e27e92d939e2e3636f0a1f0afaba59692c0bf571",
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpdoc-parser\/zipball\/d3753fcb3abc6f78f5de6f72153d4b9c99c72dee",
"reference": "d3753fcb3abc6f78f5de6f72153d4b9c99c72dee",
"shasum": ""
},
"require": {
@ -846,7 +846,7 @@
"phpunit\/phpunit": "^9.5",
"symfony\/process": "^5.2"
},
"time": "2023-02-07T18:11:17+00:00",
"time": "2023-04-04T11:11:22+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@ -863,23 +863,23 @@
"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.16.1"
"source": "https:\/\/github.com\/phpstan\/phpdoc-parser\/tree\/1.17.1"
},
"install-path": "..\/phpstan\/phpdoc-parser"
},
{
"name": "phpstan\/phpstan",
"version": "1.10.10",
"version_normalized": "1.10.10.0",
"version": "1.10.11",
"version_normalized": "1.10.11.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/phpstan\/phpstan.git",
"reference": "f1e22c9b17a879987f8743d81533250a5fff47f9"
"reference": "8aa62e6ea8b58ffb650e02940e55a788cbc3fe21"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/f1e22c9b17a879987f8743d81533250a5fff47f9",
"reference": "f1e22c9b17a879987f8743d81533250a5fff47f9",
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/8aa62e6ea8b58ffb650e02940e55a788cbc3fe21",
"reference": "8aa62e6ea8b58ffb650e02940e55a788cbc3fe21",
"shasum": ""
},
"require": {
@ -888,7 +888,7 @@
"conflict": {
"phpstan\/phpstan-shim": "*"
},
"time": "2023-04-01T17:06:15+00:00",
"time": "2023-04-04T19:17:42+00:00",
"bin": [
"phpstan",
"phpstan.phar"
@ -2056,12 +2056,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "dfeb67c1b2950de2dbc093ed187fb6559a4ddf21"
"reference": "8a1a1637ea4c39ff1fdbcdb3671beddbd5108978"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/dfeb67c1b2950de2dbc093ed187fb6559a4ddf21",
"reference": "dfeb67c1b2950de2dbc093ed187fb6559a4ddf21",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/8a1a1637ea4c39ff1fdbcdb3671beddbd5108978",
"reference": "8a1a1637ea4c39ff1fdbcdb3671beddbd5108978",
"shasum": ""
},
"require": {
@ -2090,7 +2090,7 @@
"tomasvotruba\/type-coverage": "^0.0.9",
"tomasvotruba\/unused-public": "^0.0.34"
},
"time": "2023-02-27T21:11:40+00:00",
"time": "2023-04-04T23:27:38+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,25 @@
<?php
declare (strict_types=1);
namespace PHPStan\PhpDocParser\Ast\Type;
use PHPStan\PhpDocParser\Ast\NodeAttributes;
use PHPStan\PhpDocParser\Parser\ParserException;
class InvalidTypeNode implements \PHPStan\PhpDocParser\Ast\Type\TypeNode
{
use NodeAttributes;
/** @var mixed[] */
private $exceptionArgs;
public function __construct(ParserException $exception)
{
$this->exceptionArgs = [$exception->getCurrentTokenValue(), $exception->getCurrentTokenType(), $exception->getCurrentOffset(), $exception->getExpectedTokenType(), $exception->getExpectedTokenValue()];
}
public function getException() : ParserException
{
return new ParserException(...$this->exceptionArgs);
}
public function __toString() : string
{
return '*Invalid type*';
}
}

View File

@ -20,11 +20,14 @@ class PhpDocParser
private $constantExprParser;
/** @var bool */
private $requireWhitespaceBeforeDescription;
public function __construct(\PHPStan\PhpDocParser\Parser\TypeParser $typeParser, \PHPStan\PhpDocParser\Parser\ConstExprParser $constantExprParser, bool $requireWhitespaceBeforeDescription = \false)
/** @var bool */
private $preserveTypeAliasesWithInvalidTypes;
public function __construct(\PHPStan\PhpDocParser\Parser\TypeParser $typeParser, \PHPStan\PhpDocParser\Parser\ConstExprParser $constantExprParser, bool $requireWhitespaceBeforeDescription = \false, bool $preserveTypeAliasesWithInvalidTypes = \false)
{
$this->typeParser = $typeParser;
$this->constantExprParser = $constantExprParser;
$this->requireWhitespaceBeforeDescription = $requireWhitespaceBeforeDescription;
$this->preserveTypeAliasesWithInvalidTypes = $preserveTypeAliasesWithInvalidTypes;
}
public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens) : Ast\PhpDoc\PhpDocNode
{
@ -352,6 +355,20 @@ class PhpDocParser
$tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER);
// support psalm-type syntax
$tokens->tryConsumeTokenType(Lexer::TOKEN_EQUAL);
if ($this->preserveTypeAliasesWithInvalidTypes) {
try {
$type = $this->typeParser->parse($tokens);
if (!$tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC)) {
if (!$tokens->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) {
throw new \PHPStan\PhpDocParser\Parser\ParserException($tokens->currentTokenValue(), $tokens->currentTokenType(), $tokens->currentTokenOffset(), Lexer::TOKEN_PHPDOC_EOL);
}
}
return new Ast\PhpDoc\TypeAliasTagValueNode($alias, $type);
} catch (\PHPStan\PhpDocParser\Parser\ParserException $e) {
$this->parseOptionalDescription($tokens);
return new Ast\PhpDoc\TypeAliasTagValueNode($alias, new Ast\Type\InvalidTypeNode($e));
}
}
$type = $this->typeParser->parse($tokens);
return new Ast\PhpDoc\TypeAliasTagValueNode($alias, $type);
}

Binary file not shown.

View File

@ -1,16 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmQoZG4ACgkQUcZzBf/C
5c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9bl6V9B439JF70ORLCsinGwHUBjT
ZOnzbAfRY8jTHIo9RW9Qk4dO/oOu6QYzfBLzmkL20Qbv+3EbvgZim25lsq7FlxpJ
jdc3ckUi/0OMcD0sNnuyQovNdUNxrDoQEY+tlBPUdFXIUMtVUpfDy3N7GPUsfd5i
1cccMmUyUuVIgyq8QF3BHZVQQUMbLurYfEhpzhTbNjfWgIrBQKbBy8lxadqDQ43q
VdMXScR+BeaJG/mwW35JgkkZ0p7+R0AjuwO7yPt2dLh2wkbYsiGQgmeEJXQ2xgLY
YUeC3lLRdlRmNSepuDCf8uDur9qthfM1vWoLsB6CaWxiTDSchCuwfL80nUg7CsZA
X0K6tg8z0qh8mMySb07zERLChBgJcZkSqTELhGOdWQ7PbMaqL/o=
=/4qC
-----END PGP SIGNATURE-----

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 b88c766'), '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 23e55c6'), '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 dfeb67c'), '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 141e7e2'));
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 b88c766'), '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 23e55c6'), '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 8a1a163'), '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 141e7e2'));
private function __construct()
{
}

View File

@ -117,7 +117,7 @@ final class AssertCallAnalyzer
if ($currentClassMethod === $classMethod) {
return \false;
}
if ($classMethod !== null) {
if ($classMethod instanceof ClassMethod) {
return $this->containsAssertCall($classMethod);
}
return \false;

View File

@ -108,7 +108,9 @@ final class DataProviderClassMethodFinder
if ($parentClassReflection->getName() === 'PHPUnit\\Framework\\TestCase') {
break;
}
$parentClasses[] = $this->astResolver->resolveClassFromClassReflection($parentClassReflection);
/** @var Class_ $parentClass */
$parentClass = $this->astResolver->resolveClassFromClassReflection($parentClassReflection);
$parentClasses[] = $parentClass;
}
return $parentClasses;
}

View File

@ -85,7 +85,7 @@ CODE_SAMPLE
}
foreach (self::REPLACEMENTS as $class => $method) {
$newNode = $this->replaceExceptionWith($node, $class, $method);
if ($newNode !== null) {
if ($newNode instanceof Node) {
return $newNode;
}
}