From d3d583f3ac7869127c96e6b3515b53278f809675 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 19 Feb 2025 15:30:21 +0000 Subject: [PATCH] Updated Rector to commit e0e88ed2dd5573bde7197d40c770f8b8504646cc https://github.com/rectorphp/rector-src/commit/e0e88ed2dd5573bde7197d40c770f8b8504646cc Bump phpdoc-parser 2.0.2 and regenerate preload.php (#6744) --- preload.php | 1 + src/Application/VersionResolver.php | 4 +- .../LazyContainerFactory.php | 8 +- vendor/autoload.php | 2 +- vendor/composer/autoload_classmap.php | 1 + vendor/composer/autoload_real.php | 10 +- vendor/composer/autoload_static.php | 9 +- vendor/composer/installed.json | 14 +-- vendor/composer/installed.php | 2 +- vendor/phpstan/phpdoc-parser/README.md | 6 +- .../phpdoc-parser/src/Ast/Attribute.php | 1 + .../phpstan/phpdoc-parser/src/Ast/Comment.php | 22 +++++ .../phpdoc-parser/src/Ast/NodeAttributes.php | 4 + .../phpstan/phpdoc-parser/src/Lexer/Lexer.php | 4 +- .../phpdoc-parser/src/Parser/PhpDocParser.php | 8 ++ .../src/Parser/TokenIterator.php | 56 ++++++++--- .../phpdoc-parser/src/Parser/TypeParser.php | 98 +++++++++++-------- .../phpdoc-parser/src/ParserConfig.php | 4 +- .../phpdoc-parser/src/Printer/Printer.php | 73 ++++++++++---- vendor/scoper-autoload.php | 2 +- 20 files changed, 225 insertions(+), 104 deletions(-) create mode 100644 vendor/phpstan/phpdoc-parser/src/Ast/Comment.php diff --git a/preload.php b/preload.php index 3895d091c0e..7068cc5b820 100644 --- a/preload.php +++ b/preload.php @@ -264,6 +264,7 @@ require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/compatibility_tok require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/Node.php'; require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/NodeVisitor.php'; require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php'; +require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/Comment.php'; require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php'; require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprNode.php'; require_once __DIR__ . '/vendor/phpstan/phpdoc-parser/src/Ast/PhpDoc/PhpDocTagValueNode.php'; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 8f98d0125f2..7c6de95027d 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = 'd4af0ff3eb3ac59534a699a2c3c05e317a10b4d4'; + public const PACKAGE_VERSION = 'e0e88ed2dd5573bde7197d40c770f8b8504646cc'; /** * @api * @var string */ - public const RELEASE_DATE = '2025-02-19 18:18:05'; + public const RELEASE_DATE = '2025-02-19 22:27:43'; /** * @var int */ diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index f772ac15e3f..e3fd927a791 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -11,8 +11,6 @@ use PHPStan\Analyser\NodeScopeResolver; use PHPStan\Analyser\ScopeFactory; use PHPStan\Parser\Parser; use PHPStan\PhpDoc\TypeNodeResolver; -use PHPStan\PhpDocParser\Parser\ConstExprParser; -use PHPStan\PhpDocParser\Parser\TypeParser; use PHPStan\PhpDocParser\ParserConfig; use PHPStan\Reflection\ReflectionProvider; use Rector\Application\ChangedNodeScopeRefresher; @@ -267,9 +265,6 @@ final class LazyContainerFactory $rectorConfig->when(OnlyRuleResolver::class)->needs('$rectors')->giveTagged(RectorInterface::class); $rectorConfig->singleton(FileProcessor::class); $rectorConfig->singleton(PostFileProcessor::class); - // phpdoc-parser - $rectorConfig->when(TypeParser::class)->needs('$usedAttributes')->give(['lines' => \true, 'indexes' => \true]); - $rectorConfig->when(ConstExprParser::class)->needs('$usedAttributes')->give(['lines' => \true, 'indexes' => \true]); $rectorConfig->when(RectorNodeTraverser::class)->needs('$rectors')->giveTagged(RectorInterface::class); $rectorConfig->when(ConfigInitializer::class)->needs('$rectors')->giveTagged(RectorInterface::class); $rectorConfig->when(ClassNameImportSkipper::class)->needs('$classNameImportSkipVoters')->giveTagged(ClassNameImportSkipVoterInterface::class); @@ -357,7 +352,8 @@ final class LazyContainerFactory $this->registerTagged($rectorConfig, self::SCOPE_RESOLVER_NODE_VISITOR_CLASSES, ScopeResolverNodeVisitorInterface::class); $this->createPHPStanServices($rectorConfig); $rectorConfig->when(PhpDocNodeMapper::class)->needs('$phpDocNodeVisitors')->giveTagged(BasePhpDocNodeVisitorInterface::class); - $rectorConfig->singleton(ParserConfig::class, static fn(Container $container): ParserConfig => new ParserConfig(['lines' => \true, 'indexes' => \true])); + // phpdoc-parser + $rectorConfig->singleton(ParserConfig::class, static fn(Container $container): ParserConfig => new ParserConfig(['lines' => \true, 'indexes' => \true, 'comments' => \true])); return $rectorConfig; } /** diff --git a/vendor/autoload.php b/vendor/autoload.php index be33baae40f..ae54777fd16 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInita9ca9624b9ec3b7183135fb9d7d95d23::getLoader(); +return ComposerAutoloaderInit30bd5d3b9b1d532a1d3e11eb20f91e28::getLoader(); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 737fdc4c491..f129e402525 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -9,6 +9,7 @@ return array( 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', 'PHPStan\\PhpDocParser\\Ast\\AbstractNodeVisitor' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/AbstractNodeVisitor.php', 'PHPStan\\PhpDocParser\\Ast\\Attribute' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/Attribute.php', + 'PHPStan\\PhpDocParser\\Ast\\Comment' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/Comment.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprArrayItemNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayItemNode.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprArrayNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprFalseNode' => $vendorDir . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprFalseNode.php', diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index d6696cc9497..0176777240b 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInita9ca9624b9ec3b7183135fb9d7d95d23 +class ComposerAutoloaderInit30bd5d3b9b1d532a1d3e11eb20f91e28 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInita9ca9624b9ec3b7183135fb9d7d95d23 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInita9ca9624b9ec3b7183135fb9d7d95d23', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit30bd5d3b9b1d532a1d3e11eb20f91e28', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInita9ca9624b9ec3b7183135fb9d7d95d23', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit30bd5d3b9b1d532a1d3e11eb20f91e28', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInita9ca9624b9ec3b7183135fb9d7d95d23::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit30bd5d3b9b1d532a1d3e11eb20f91e28::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInita9ca9624b9ec3b7183135fb9d7d95d23::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit30bd5d3b9b1d532a1d3e11eb20f91e28::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index d92335cc13c..52f90d2e66b 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInita9ca9624b9ec3b7183135fb9d7d95d23 +class ComposerStaticInit30bd5d3b9b1d532a1d3e11eb20f91e28 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -228,6 +228,7 @@ class ComposerStaticInita9ca9624b9ec3b7183135fb9d7d95d23 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', 'PHPStan\\PhpDocParser\\Ast\\AbstractNodeVisitor' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/AbstractNodeVisitor.php', 'PHPStan\\PhpDocParser\\Ast\\Attribute' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/Attribute.php', + 'PHPStan\\PhpDocParser\\Ast\\Comment' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/Comment.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprArrayItemNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayItemNode.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprArrayNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprArrayNode.php', 'PHPStan\\PhpDocParser\\Ast\\ConstExpr\\ConstExprFalseNode' => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src/Ast/ConstExpr/ConstExprFalseNode.php', @@ -2864,9 +2865,9 @@ class ComposerStaticInita9ca9624b9ec3b7183135fb9d7d95d23 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInita9ca9624b9ec3b7183135fb9d7d95d23::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInita9ca9624b9ec3b7183135fb9d7d95d23::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInita9ca9624b9ec3b7183135fb9d7d95d23::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit30bd5d3b9b1d532a1d3e11eb20f91e28::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit30bd5d3b9b1d532a1d3e11eb20f91e28::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit30bd5d3b9b1d532a1d3e11eb20f91e28::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index aaa2ef696a6..69db907c45d 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -869,17 +869,17 @@ }, { "name": "phpstan\/phpdoc-parser", - "version": "2.0.2", - "version_normalized": "2.0.2.0", + "version": "2.1.0", + "version_normalized": "2.1.0.0", "source": { "type": "git", "url": "https:\/\/github.com\/phpstan\/phpdoc-parser.git", - "reference": "51087f87dcce2663e1fed4dfd4e56eccd580297e" + "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68" }, "dist": { "type": "zip", - "url": "https:\/\/api.github.com\/repos\/phpstan\/phpdoc-parser\/zipball\/51087f87dcce2663e1fed4dfd4e56eccd580297e", - "reference": "51087f87dcce2663e1fed4dfd4e56eccd580297e", + "url": "https:\/\/api.github.com\/repos\/phpstan\/phpdoc-parser\/zipball\/9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", + "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", "shasum": "" }, "require": { @@ -896,7 +896,7 @@ "phpunit\/phpunit": "^9.6", "symfony\/process": "^5.2" }, - "time": "2025-02-17T20:25:51+00:00", + "time": "2025-02-19T13:28:12+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -913,7 +913,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\/2.0.2" + "source": "https:\/\/github.com\/phpstan\/phpdoc-parser\/tree\/2.1.0" }, "install-path": "..\/phpstan\/phpdoc-parser" }, diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index f0d2a7cdd38..ad5de383d40 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -2,4 +2,4 @@ namespace RectorPrefix202502; -return array('root' => array('name' => 'rector/rector-src', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => null, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \false), 'versions' => array('clue/ndjson-react' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '392dc165fce93b5bb5c637b67e59619223c931b0', 'type' => 'library', 'install_path' => __DIR__ . '/../clue/ndjson-react', 'aliases' => array(), 'dev_requirement' => \false), 'composer/pcre' => array('pretty_version' => '3.3.2', 'version' => '3.3.2.0', 'reference' => 'b2bed4734f0cc156ee1fe9c0da2550420d99a21e', 'type' => 'library', 'install_path' => __DIR__ . '/./pcre', 'aliases' => array(), 'dev_requirement' => \false), 'composer/semver' => array('pretty_version' => '3.4.3', 'version' => '3.4.3.0', 'reference' => '4313d26ada5e0c4edfbd1dc481a92ff7bff91f12', 'type' => 'library', 'install_path' => __DIR__ . '/./semver', 'aliases' => array(), 'dev_requirement' => \false), 'composer/xdebug-handler' => array('pretty_version' => '3.0.5', 'version' => '3.0.5.0', 'reference' => '6c1925561632e83d60a44492e0b344cf48ab85ef', 'type' => 'library', 'install_path' => __DIR__ . '/./xdebug-handler', 'aliases' => array(), 'dev_requirement' => \false), 'doctrine/inflector' => array('pretty_version' => '2.0.10', 'version' => '2.0.10.0', 'reference' => '5817d0659c5b50c9b950feb9af7b9668e2c436bc', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/inflector', 'aliases' => array(), 'dev_requirement' => \false), 'evenement/evenement' => array('pretty_version' => 'v3.0.2', 'version' => '3.0.2.0', 'reference' => '0a16b0d71ab13284339abb99d9d2bd813640efbc', 'type' => 'library', 'install_path' => __DIR__ . '/../evenement/evenement', 'aliases' => array(), 'dev_requirement' => \false), 'fidry/cpu-core-counter' => array('pretty_version' => '1.2.0', 'version' => '1.2.0.0', 'reference' => '8520451a140d3f46ac33042715115e290cf5785f', 'type' => 'library', 'install_path' => __DIR__ . '/../fidry/cpu-core-counter', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/container' => array('pretty_version' => 'v11.43.0', 'version' => '11.43.0.0', 'reference' => '4dcc3fcbab92e734fc0c08d9cfd97f5a1aef18ca', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/container', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/contracts' => array('pretty_version' => 'v11.43.0', 'version' => '11.43.0.0', 'reference' => 'b350a3cd8450846325cb49e1cbc1293598b18898', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/contracts', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v4.0.5', 'version' => '4.0.5.0', 'reference' => '736c567e257dbe0fcf6ce81b4d6dbe05c6899f96', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'nikic/php-parser' => array('pretty_version' => 'v5.4.0', 'version' => '5.4.0.0', 'reference' => '447a020a1f875a434d62f2a401f53b82a396e494', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), 'dev_requirement' => \false), 'ondram/ci-detector' => array('pretty_version' => '4.2.0', 'version' => '4.2.0.0', 'reference' => '8b0223b5ed235fd377c75fdd1bfcad05c0f168b8', 'type' => 'library', 'install_path' => __DIR__ . '/../ondram/ci-detector', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpdoc-parser' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => '51087f87dcce2663e1fed4dfd4e56eccd580297e', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpdoc-parser', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpstan' => array('dev_requirement' => \false, 'replaced' => array(0 => '2.1.5')), 'psr/container' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.1|2.0')), 'psr/log' => array('pretty_version' => '3.0.2', 'version' => '3.0.2.0', 'reference' => 'f16e1d5863e37f8d8c2a01719f5b34baa2b714d3', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0|2.0|3.0')), 'psr/simple-cache' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/simple-cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/cache' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => 'd47c472b64aa5608225f47965a484b75c7817d5b', 'type' => 'library', 'install_path' => __DIR__ . '/../react/cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/child-process' => array('pretty_version' => 'v0.6.6', 'version' => '0.6.6.0', 'reference' => '1721e2b93d89b745664353b9cfc8f155ba8a6159', 'type' => 'library', 'install_path' => __DIR__ . '/../react/child-process', 'aliases' => array(), 'dev_requirement' => \false), 'react/dns' => array('pretty_version' => 'v1.13.0', 'version' => '1.13.0.0', 'reference' => 'eb8ae001b5a455665c89c1df97f6fb682f8fb0f5', 'type' => 'library', 'install_path' => __DIR__ . '/../react/dns', 'aliases' => array(), 'dev_requirement' => \false), 'react/event-loop' => array('pretty_version' => 'v1.5.0', 'version' => '1.5.0.0', 'reference' => 'bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354', 'type' => 'library', 'install_path' => __DIR__ . '/../react/event-loop', 'aliases' => array(), 'dev_requirement' => \false), 'react/promise' => array('pretty_version' => 'v3.2.0', 'version' => '3.2.0.0', 'reference' => '8a164643313c71354582dc850b42b33fa12a4b63', 'type' => 'library', 'install_path' => __DIR__ . '/../react/promise', 'aliases' => array(), 'dev_requirement' => \false), 'react/socket' => array('pretty_version' => 'v1.16.0', 'version' => '1.16.0.0', 'reference' => '23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1', 'type' => 'library', 'install_path' => __DIR__ . '/../react/socket', 'aliases' => array(), 'dev_requirement' => \false), 'react/stream' => array('pretty_version' => 'v1.4.0', 'version' => '1.4.0.0', 'reference' => '1e5b0acb8fe55143b5b426817155190eb6f5b18d', 'type' => 'library', 'install_path' => __DIR__ . '/../react/stream', 'aliases' => array(), 'dev_requirement' => \false), 'rector/extension-installer' => array('pretty_version' => '0.11.2', 'version' => '0.11.2.0', 'reference' => '05544e9b195863b8571ae2a3b903cbec7fa062e0', 'type' => 'composer-plugin', 'install_path' => __DIR__ . '/../rector/extension-installer', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector' => array('dev_requirement' => \false, 'replaced' => array(0 => 'dev-main')), 'rector/rector-doctrine' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '33f8d9bca8f9d2b5d3d28660f19bd4f3390223d4', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-doctrine', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-downgrade-php' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '6dba10960d71bdd442b5ebe54dbbf2c4a72b263d', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-downgrade-php', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-phpunit' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'c0b4dfb141d0ea6633c0021297ea0cfa33b76ffa', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-phpunit', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-src' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => null, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector-symfony' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'c02c2554e1f0a0b2fef936a9bbba07243416f784', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-symfony', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'sebastian/diff' => array('pretty_version' => '6.0.2', 'version' => '6.0.2.0', 'reference' => 'b4ccd857127db5d41a5b676f24b51371d76d8544', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/diff', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/console' => array('pretty_version' => 'v6.4.17', 'version' => '6.4.17.0', 'reference' => '799445db3f15768ecc382ac5699e6da0520a0a04', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('pretty_version' => 'v3.5.1', 'version' => '3.5.1.0', 'reference' => '74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/filesystem' => array('pretty_version' => 'v6.4.13', 'version' => '6.4.13.0', 'reference' => '4856c9cf585d5a0313d8d35afd681a526f038dd3', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/filesystem', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/finder' => array('pretty_version' => 'v6.4.17', 'version' => '6.4.17.0', 'reference' => '1d0e8266248c5d9ab6a87e3789e6dc482af3c9c7', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/finder', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/polyfill-ctype' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-intl-grapheme' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-mbstring' => array('pretty_version' => 'v1.31.0', 'version' => '1.31.0.0', 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/process' => array('pretty_version' => 'v6.4.15', 'version' => '6.4.15.0', 'reference' => '3cb242f059c14ae08591c5c4087d1fe443564392', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/process', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/service-contracts' => array('pretty_version' => 'v3.5.1', 'version' => '3.5.1.0', 'reference' => 'e53260aabf78fb3d63f8d79d69ece59f80d5eda0', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/service-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/string' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/yaml' => array('pretty_version' => 'v7.2.3', 'version' => '7.2.3.0', 'reference' => 'ac238f173df0c9c1120f862d0f599e17535a87ec', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/yaml', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/easy-parallel' => array('pretty_version' => '11.2.2', 'version' => '11.2.2.0', 'reference' => '8586c18bb8efb31cd192a4e5cc94ae7813f72ed9', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/easy-parallel', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/rule-doc-generator-contracts' => array('pretty_version' => '11.2.0', 'version' => '11.2.0.0', 'reference' => '479cfcfd46047f80624aba931d9789e50475b5c6', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/rule-doc-generator-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'webmozart/assert' => array('pretty_version' => '1.11.0', 'version' => '1.11.0.0', 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', 'type' => 'library', 'install_path' => __DIR__ . '/../webmozart/assert', 'aliases' => array(), 'dev_requirement' => \false))); +return array('root' => array('name' => 'rector/rector-src', 'pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => null, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \false), 'versions' => array('clue/ndjson-react' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '392dc165fce93b5bb5c637b67e59619223c931b0', 'type' => 'library', 'install_path' => __DIR__ . '/../clue/ndjson-react', 'aliases' => array(), 'dev_requirement' => \false), 'composer/pcre' => array('pretty_version' => '3.3.2', 'version' => '3.3.2.0', 'reference' => 'b2bed4734f0cc156ee1fe9c0da2550420d99a21e', 'type' => 'library', 'install_path' => __DIR__ . '/./pcre', 'aliases' => array(), 'dev_requirement' => \false), 'composer/semver' => array('pretty_version' => '3.4.3', 'version' => '3.4.3.0', 'reference' => '4313d26ada5e0c4edfbd1dc481a92ff7bff91f12', 'type' => 'library', 'install_path' => __DIR__ . '/./semver', 'aliases' => array(), 'dev_requirement' => \false), 'composer/xdebug-handler' => array('pretty_version' => '3.0.5', 'version' => '3.0.5.0', 'reference' => '6c1925561632e83d60a44492e0b344cf48ab85ef', 'type' => 'library', 'install_path' => __DIR__ . '/./xdebug-handler', 'aliases' => array(), 'dev_requirement' => \false), 'doctrine/inflector' => array('pretty_version' => '2.0.10', 'version' => '2.0.10.0', 'reference' => '5817d0659c5b50c9b950feb9af7b9668e2c436bc', 'type' => 'library', 'install_path' => __DIR__ . '/../doctrine/inflector', 'aliases' => array(), 'dev_requirement' => \false), 'evenement/evenement' => array('pretty_version' => 'v3.0.2', 'version' => '3.0.2.0', 'reference' => '0a16b0d71ab13284339abb99d9d2bd813640efbc', 'type' => 'library', 'install_path' => __DIR__ . '/../evenement/evenement', 'aliases' => array(), 'dev_requirement' => \false), 'fidry/cpu-core-counter' => array('pretty_version' => '1.2.0', 'version' => '1.2.0.0', 'reference' => '8520451a140d3f46ac33042715115e290cf5785f', 'type' => 'library', 'install_path' => __DIR__ . '/../fidry/cpu-core-counter', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/container' => array('pretty_version' => 'v11.43.0', 'version' => '11.43.0.0', 'reference' => '4dcc3fcbab92e734fc0c08d9cfd97f5a1aef18ca', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/container', 'aliases' => array(), 'dev_requirement' => \false), 'illuminate/contracts' => array('pretty_version' => 'v11.43.0', 'version' => '11.43.0.0', 'reference' => 'b350a3cd8450846325cb49e1cbc1293598b18898', 'type' => 'library', 'install_path' => __DIR__ . '/../illuminate/contracts', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v4.0.5', 'version' => '4.0.5.0', 'reference' => '736c567e257dbe0fcf6ce81b4d6dbe05c6899f96', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'nikic/php-parser' => array('pretty_version' => 'v5.4.0', 'version' => '5.4.0.0', 'reference' => '447a020a1f875a434d62f2a401f53b82a396e494', 'type' => 'library', 'install_path' => __DIR__ . '/../nikic/php-parser', 'aliases' => array(), 'dev_requirement' => \false), 'ondram/ci-detector' => array('pretty_version' => '4.2.0', 'version' => '4.2.0.0', 'reference' => '8b0223b5ed235fd377c75fdd1bfcad05c0f168b8', 'type' => 'library', 'install_path' => __DIR__ . '/../ondram/ci-detector', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpdoc-parser' => array('pretty_version' => '2.1.0', 'version' => '2.1.0.0', 'reference' => '9b30d6fd026b2c132b3985ce6b23bec09ab3aa68', 'type' => 'library', 'install_path' => __DIR__ . '/../phpstan/phpdoc-parser', 'aliases' => array(), 'dev_requirement' => \false), 'phpstan/phpstan' => array('dev_requirement' => \false, 'replaced' => array(0 => '2.1.5')), 'psr/container' => array('pretty_version' => '2.0.2', 'version' => '2.0.2.0', 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.1|2.0')), 'psr/log' => array('pretty_version' => '3.0.2', 'version' => '3.0.2.0', 'reference' => 'f16e1d5863e37f8d8c2a01719f5b34baa2b714d3', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0|2.0|3.0')), 'psr/simple-cache' => array('pretty_version' => '3.0.0', 'version' => '3.0.0.0', 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/simple-cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/cache' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => 'd47c472b64aa5608225f47965a484b75c7817d5b', 'type' => 'library', 'install_path' => __DIR__ . '/../react/cache', 'aliases' => array(), 'dev_requirement' => \false), 'react/child-process' => array('pretty_version' => 'v0.6.6', 'version' => '0.6.6.0', 'reference' => '1721e2b93d89b745664353b9cfc8f155ba8a6159', 'type' => 'library', 'install_path' => __DIR__ . '/../react/child-process', 'aliases' => array(), 'dev_requirement' => \false), 'react/dns' => array('pretty_version' => 'v1.13.0', 'version' => '1.13.0.0', 'reference' => 'eb8ae001b5a455665c89c1df97f6fb682f8fb0f5', 'type' => 'library', 'install_path' => __DIR__ . '/../react/dns', 'aliases' => array(), 'dev_requirement' => \false), 'react/event-loop' => array('pretty_version' => 'v1.5.0', 'version' => '1.5.0.0', 'reference' => 'bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354', 'type' => 'library', 'install_path' => __DIR__ . '/../react/event-loop', 'aliases' => array(), 'dev_requirement' => \false), 'react/promise' => array('pretty_version' => 'v3.2.0', 'version' => '3.2.0.0', 'reference' => '8a164643313c71354582dc850b42b33fa12a4b63', 'type' => 'library', 'install_path' => __DIR__ . '/../react/promise', 'aliases' => array(), 'dev_requirement' => \false), 'react/socket' => array('pretty_version' => 'v1.16.0', 'version' => '1.16.0.0', 'reference' => '23e4ff33ea3e160d2d1f59a0e6050e4b0fb0eac1', 'type' => 'library', 'install_path' => __DIR__ . '/../react/socket', 'aliases' => array(), 'dev_requirement' => \false), 'react/stream' => array('pretty_version' => 'v1.4.0', 'version' => '1.4.0.0', 'reference' => '1e5b0acb8fe55143b5b426817155190eb6f5b18d', 'type' => 'library', 'install_path' => __DIR__ . '/../react/stream', 'aliases' => array(), 'dev_requirement' => \false), 'rector/extension-installer' => array('pretty_version' => '0.11.2', 'version' => '0.11.2.0', 'reference' => '05544e9b195863b8571ae2a3b903cbec7fa062e0', 'type' => 'composer-plugin', 'install_path' => __DIR__ . '/../rector/extension-installer', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector' => array('dev_requirement' => \false, 'replaced' => array(0 => 'dev-main')), 'rector/rector-doctrine' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '33f8d9bca8f9d2b5d3d28660f19bd4f3390223d4', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-doctrine', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-downgrade-php' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => '6dba10960d71bdd442b5ebe54dbbf2c4a72b263d', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-downgrade-php', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'rector/rector-phpunit' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'c0b4dfb141d0ea6633c0021297ea0cfa33b76ffa', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-phpunit', 'aliases' => array(0 => '0.11.x-dev'), 'dev_requirement' => \false), 'rector/rector-src' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => null, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'rector/rector-symfony' => array('pretty_version' => 'dev-main', 'version' => 'dev-main', 'reference' => 'c02c2554e1f0a0b2fef936a9bbba07243416f784', 'type' => 'rector-extension', 'install_path' => __DIR__ . '/../rector/rector-symfony', 'aliases' => array(0 => '9999999-dev'), 'dev_requirement' => \false), 'sebastian/diff' => array('pretty_version' => '6.0.2', 'version' => '6.0.2.0', 'reference' => 'b4ccd857127db5d41a5b676f24b51371d76d8544', 'type' => 'library', 'install_path' => __DIR__ . '/../sebastian/diff', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/console' => array('pretty_version' => 'v6.4.17', 'version' => '6.4.17.0', 'reference' => '799445db3f15768ecc382ac5699e6da0520a0a04', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('pretty_version' => 'v3.5.1', 'version' => '3.5.1.0', 'reference' => '74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/filesystem' => array('pretty_version' => 'v6.4.13', 'version' => '6.4.13.0', 'reference' => '4856c9cf585d5a0313d8d35afd681a526f038dd3', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/filesystem', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/finder' => array('pretty_version' => 'v6.4.17', 'version' => '6.4.17.0', 'reference' => '1d0e8266248c5d9ab6a87e3789e6dc482af3c9c7', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/finder', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/polyfill-ctype' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-intl-grapheme' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/polyfill-mbstring' => array('pretty_version' => 'v1.31.0', 'version' => '1.31.0.0', 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/process' => array('pretty_version' => 'v6.4.15', 'version' => '6.4.15.0', 'reference' => '3cb242f059c14ae08591c5c4087d1fe443564392', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/process', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/service-contracts' => array('pretty_version' => 'v3.5.1', 'version' => '3.5.1.0', 'reference' => 'e53260aabf78fb3d63f8d79d69ece59f80d5eda0', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/service-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/string' => array('dev_requirement' => \false, 'replaced' => array(0 => '*')), 'symfony/yaml' => array('pretty_version' => 'v7.2.3', 'version' => '7.2.3.0', 'reference' => 'ac238f173df0c9c1120f862d0f599e17535a87ec', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/yaml', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/easy-parallel' => array('pretty_version' => '11.2.2', 'version' => '11.2.2.0', 'reference' => '8586c18bb8efb31cd192a4e5cc94ae7813f72ed9', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/easy-parallel', 'aliases' => array(), 'dev_requirement' => \false), 'symplify/rule-doc-generator-contracts' => array('pretty_version' => '11.2.0', 'version' => '11.2.0.0', 'reference' => '479cfcfd46047f80624aba931d9789e50475b5c6', 'type' => 'library', 'install_path' => __DIR__ . '/../symplify/rule-doc-generator-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'webmozart/assert' => array('pretty_version' => '1.11.0', 'version' => '1.11.0.0', 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', 'type' => 'library', 'install_path' => __DIR__ . '/../webmozart/assert', 'aliases' => array(), 'dev_requirement' => \false))); diff --git a/vendor/phpstan/phpdoc-parser/README.md b/vendor/phpstan/phpdoc-parser/README.md index ff6e808e1cd..15ac9a97b6f 100644 --- a/vendor/phpstan/phpdoc-parser/README.md +++ b/vendor/phpstan/phpdoc-parser/README.md @@ -13,9 +13,9 @@ For the complete list of supported PHPDoc features check out PHPStan documentati * [PHPDoc Basics](https://phpstan.org/writing-php-code/phpdocs-basics) (list of PHPDoc tags) * [PHPDoc Types](https://phpstan.org/writing-php-code/phpdoc-types) (list of PHPDoc types) -* [phpdoc-parser API Reference](https://phpstan.github.io/phpdoc-parser/2.0.x/namespace-PHPStan.PhpDocParser.html) with all the AST node types etc. +* [phpdoc-parser API Reference](https://phpstan.github.io/phpdoc-parser/2.1.x/namespace-PHPStan.PhpDocParser.html) with all the AST node types etc. -This parser also supports parsing [Doctrine Annotations](https://github.com/doctrine/annotations). The AST nodes live in the [PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine namespace](https://phpstan.github.io/phpdoc-parser/2.0.x/namespace-PHPStan.PhpDocParser.Ast.PhpDoc.Doctrine.html). +This parser also supports parsing [Doctrine Annotations](https://github.com/doctrine/annotations). The AST nodes live in the [PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine namespace](https://phpstan.github.io/phpdoc-parser/2.1.x/namespace-PHPStan.PhpDocParser.Ast.PhpDoc.Doctrine.html). ## Installation @@ -83,7 +83,7 @@ use PHPStan\PhpDocParser\Printer\Printer; // basic setup with enabled required lexer attributes -$config = new ParserConfig(usedAttributes: ['lines' => true, 'indexes' => true]); +$config = new ParserConfig(usedAttributes: ['lines' => true, 'indexes' => true, 'comments' => true]); $lexer = new Lexer($config); $constExprParser = new ConstExprParser($config); $typeParser = new TypeParser($config, $constExprParser); diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Attribute.php b/vendor/phpstan/phpdoc-parser/src/Ast/Attribute.php index 9736d80828e..794a2b7fcdd 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/Attribute.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Attribute.php @@ -10,4 +10,5 @@ final class Attribute public const START_INDEX = 'startIndex'; public const END_INDEX = 'endIndex'; public const ORIGINAL_NODE = 'originalNode'; + public const COMMENTS = 'comments'; } diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/Comment.php b/vendor/phpstan/phpdoc-parser/src/Ast/Comment.php new file mode 100644 index 00000000000..a719c45e8bd --- /dev/null +++ b/vendor/phpstan/phpdoc-parser/src/Ast/Comment.php @@ -0,0 +1,22 @@ +text = $text; + $this->startLine = $startLine; + $this->startIndex = $startIndex; + } + public function getReformattedText() : string + { + return trim($this->text); + } +} diff --git a/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php b/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php index ca8ffccf34d..5f467653fb3 100644 --- a/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php +++ b/vendor/phpstan/phpdoc-parser/src/Ast/NodeAttributes.php @@ -13,6 +13,10 @@ trait NodeAttributes */ public function setAttribute(string $key, $value) : void { + if ($value === null) { + unset($this->attributes[$key]); + return; + } $this->attributes[$key] = $value; } public function hasAttribute(string $key) : bool diff --git a/vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php b/vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php index ed90e8472eb..f77e6b4902a 100644 --- a/vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php +++ b/vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php @@ -49,7 +49,8 @@ class Lexer public const TOKEN_CLOSE_CURLY_BRACKET = 34; public const TOKEN_NEGATED = 35; public const TOKEN_ARROW = 36; - public const TOKEN_LABELS = [self::TOKEN_REFERENCE => '\'&\'', self::TOKEN_UNION => '\'|\'', self::TOKEN_INTERSECTION => '\'&\'', self::TOKEN_NULLABLE => '\'?\'', self::TOKEN_NEGATED => '\'!\'', self::TOKEN_OPEN_PARENTHESES => '\'(\'', self::TOKEN_CLOSE_PARENTHESES => '\')\'', self::TOKEN_OPEN_ANGLE_BRACKET => '\'<\'', self::TOKEN_CLOSE_ANGLE_BRACKET => '\'>\'', self::TOKEN_OPEN_SQUARE_BRACKET => '\'[\'', self::TOKEN_CLOSE_SQUARE_BRACKET => '\']\'', self::TOKEN_OPEN_CURLY_BRACKET => '\'{\'', self::TOKEN_CLOSE_CURLY_BRACKET => '\'}\'', self::TOKEN_COMMA => '\',\'', self::TOKEN_COLON => '\':\'', self::TOKEN_VARIADIC => '\'...\'', self::TOKEN_DOUBLE_COLON => '\'::\'', self::TOKEN_DOUBLE_ARROW => '\'=>\'', self::TOKEN_ARROW => '\'->\'', self::TOKEN_EQUAL => '\'=\'', self::TOKEN_OPEN_PHPDOC => '\'/**\'', self::TOKEN_CLOSE_PHPDOC => '\'*/\'', self::TOKEN_PHPDOC_TAG => 'TOKEN_PHPDOC_TAG', self::TOKEN_DOCTRINE_TAG => 'TOKEN_DOCTRINE_TAG', self::TOKEN_PHPDOC_EOL => 'TOKEN_PHPDOC_EOL', self::TOKEN_FLOAT => 'TOKEN_FLOAT', self::TOKEN_INTEGER => 'TOKEN_INTEGER', self::TOKEN_SINGLE_QUOTED_STRING => 'TOKEN_SINGLE_QUOTED_STRING', self::TOKEN_DOUBLE_QUOTED_STRING => 'TOKEN_DOUBLE_QUOTED_STRING', self::TOKEN_DOCTRINE_ANNOTATION_STRING => 'TOKEN_DOCTRINE_ANNOTATION_STRING', self::TOKEN_IDENTIFIER => 'type', self::TOKEN_THIS_VARIABLE => '\'$this\'', self::TOKEN_VARIABLE => 'variable', self::TOKEN_HORIZONTAL_WS => 'TOKEN_HORIZONTAL_WS', self::TOKEN_OTHER => 'TOKEN_OTHER', self::TOKEN_END => 'TOKEN_END', self::TOKEN_WILDCARD => '*']; + public const TOKEN_COMMENT = 37; + public const TOKEN_LABELS = [self::TOKEN_REFERENCE => '\'&\'', self::TOKEN_UNION => '\'|\'', self::TOKEN_INTERSECTION => '\'&\'', self::TOKEN_NULLABLE => '\'?\'', self::TOKEN_NEGATED => '\'!\'', self::TOKEN_OPEN_PARENTHESES => '\'(\'', self::TOKEN_CLOSE_PARENTHESES => '\')\'', self::TOKEN_OPEN_ANGLE_BRACKET => '\'<\'', self::TOKEN_CLOSE_ANGLE_BRACKET => '\'>\'', self::TOKEN_OPEN_SQUARE_BRACKET => '\'[\'', self::TOKEN_CLOSE_SQUARE_BRACKET => '\']\'', self::TOKEN_OPEN_CURLY_BRACKET => '\'{\'', self::TOKEN_CLOSE_CURLY_BRACKET => '\'}\'', self::TOKEN_COMMA => '\',\'', self::TOKEN_COMMENT => '\'//\'', self::TOKEN_COLON => '\':\'', self::TOKEN_VARIADIC => '\'...\'', self::TOKEN_DOUBLE_COLON => '\'::\'', self::TOKEN_DOUBLE_ARROW => '\'=>\'', self::TOKEN_ARROW => '\'->\'', self::TOKEN_EQUAL => '\'=\'', self::TOKEN_OPEN_PHPDOC => '\'/**\'', self::TOKEN_CLOSE_PHPDOC => '\'*/\'', self::TOKEN_PHPDOC_TAG => 'TOKEN_PHPDOC_TAG', self::TOKEN_DOCTRINE_TAG => 'TOKEN_DOCTRINE_TAG', self::TOKEN_PHPDOC_EOL => 'TOKEN_PHPDOC_EOL', self::TOKEN_FLOAT => 'TOKEN_FLOAT', self::TOKEN_INTEGER => 'TOKEN_INTEGER', self::TOKEN_SINGLE_QUOTED_STRING => 'TOKEN_SINGLE_QUOTED_STRING', self::TOKEN_DOUBLE_QUOTED_STRING => 'TOKEN_DOUBLE_QUOTED_STRING', self::TOKEN_DOCTRINE_ANNOTATION_STRING => 'TOKEN_DOCTRINE_ANNOTATION_STRING', self::TOKEN_IDENTIFIER => 'type', self::TOKEN_THIS_VARIABLE => '\'$this\'', self::TOKEN_VARIABLE => 'variable', self::TOKEN_HORIZONTAL_WS => 'TOKEN_HORIZONTAL_WS', self::TOKEN_OTHER => 'TOKEN_OTHER', self::TOKEN_END => 'TOKEN_END', self::TOKEN_WILDCARD => '*']; public const VALUE_OFFSET = 0; public const TYPE_OFFSET = 1; public const LINE_OFFSET = 2; @@ -104,6 +105,7 @@ class Lexer self::TOKEN_OPEN_CURLY_BRACKET => '\\{', self::TOKEN_CLOSE_CURLY_BRACKET => '\\}', self::TOKEN_COMMA => ',', + self::TOKEN_COMMENT => '\\/\\/[^\\r\\n]*(?=\\n|\\r|\\*/)', self::TOKEN_VARIADIC => '\\.\\.\\.', self::TOKEN_DOUBLE_COLON => '::', self::TOKEN_DOUBLE_ARROW => '=>', diff --git a/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php b/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php index a582094f2e4..07ef845b27f 100644 --- a/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php +++ b/vendor/phpstan/phpdoc-parser/src/Parser/PhpDocParser.php @@ -79,8 +79,16 @@ class PhpDocParser } $tag = new Ast\PhpDoc\PhpDocTagNode($name, $this->enrichWithAttributes($tokens, new Ast\PhpDoc\InvalidTagValueNode($e->getMessage(), $e), $startLine, $startIndex)); $tokens->forwardToTheEnd(); + $comments = $tokens->flushComments(); + if ($comments !== []) { + throw new LogicException('Comments should already be flushed'); + } return $this->enrichWithAttributes($tokens, new Ast\PhpDoc\PhpDocNode([$this->enrichWithAttributes($tokens, $tag, $startLine, $startIndex)]), 1, 0); } + $comments = $tokens->flushComments(); + if ($comments !== []) { + throw new LogicException('Comments should already be flushed'); + } return $this->enrichWithAttributes($tokens, new Ast\PhpDoc\PhpDocNode($children), 1, 0); } /** @phpstan-impure */ diff --git a/vendor/phpstan/phpdoc-parser/src/Parser/TokenIterator.php b/vendor/phpstan/phpdoc-parser/src/Parser/TokenIterator.php index ef1fa387a60..f036a6e7766 100644 --- a/vendor/phpstan/phpdoc-parser/src/Parser/TokenIterator.php +++ b/vendor/phpstan/phpdoc-parser/src/Parser/TokenIterator.php @@ -4,6 +4,7 @@ declare (strict_types=1); namespace PHPStan\PhpDocParser\Parser; use LogicException; +use PHPStan\PhpDocParser\Ast\Comment; use PHPStan\PhpDocParser\Lexer\Lexer; use function array_pop; use function assert; @@ -16,7 +17,9 @@ class TokenIterator /** @var list */ private array $tokens; private int $index; - /** @var int[] */ + /** @var list */ + private array $comments = []; + /** @var list}> */ private array $savePoints = []; /** @var list */ private array $skippedTokenTypes = [Lexer::TOKEN_HORIZONTAL_WS]; @@ -113,8 +116,7 @@ class TokenIterator $this->detectNewline(); } } - $this->index++; - $this->skipIrrelevantTokens(); + $this->next(); } /** * @throws ParserException @@ -124,8 +126,7 @@ class TokenIterator if ($this->tokens[$this->index][Lexer::TYPE_OFFSET] !== $tokenType || $this->tokens[$this->index][Lexer::VALUE_OFFSET] !== $tokenValue) { $this->throwError($tokenType, $tokenValue); } - $this->index++; - $this->skipIrrelevantTokens(); + $this->next(); } /** @phpstan-impure */ public function tryConsumeTokenValue(string $tokenValue) : bool @@ -133,10 +134,18 @@ class TokenIterator if ($this->tokens[$this->index][Lexer::VALUE_OFFSET] !== $tokenValue) { return \false; } - $this->index++; - $this->skipIrrelevantTokens(); + $this->next(); return \true; } + /** + * @return list + */ + public function flushComments() : array + { + $res = $this->comments; + $this->comments = []; + return $res; + } /** @phpstan-impure */ public function tryConsumeTokenType(int $tokenType) : bool { @@ -148,11 +157,12 @@ class TokenIterator $this->detectNewline(); } } - $this->index++; - $this->skipIrrelevantTokens(); + $this->next(); return \true; } - /** @phpstan-impure */ + /** + * @deprecated Use skipNewLineTokensAndConsumeComments instead (when parsing a type) + */ public function skipNewLineTokens() : void { if (!$this->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) { @@ -162,6 +172,24 @@ class TokenIterator $foundNewLine = $this->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); } while ($foundNewLine === \true); } + public function skipNewLineTokensAndConsumeComments() : void + { + if ($this->currentTokenType() === Lexer::TOKEN_COMMENT) { + $this->comments[] = new Comment($this->currentTokenValue(), $this->currentTokenLine(), $this->currentTokenIndex()); + $this->next(); + } + if (!$this->isCurrentTokenType(Lexer::TOKEN_PHPDOC_EOL)) { + return; + } + do { + $foundNewLine = $this->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL); + if ($this->currentTokenType() !== Lexer::TOKEN_COMMENT) { + continue; + } + $this->comments[] = new Comment($this->currentTokenValue(), $this->currentTokenLine(), $this->currentTokenIndex()); + $this->next(); + } while ($foundNewLine === \true); + } private function detectNewline() : void { $value = $this->currentTokenValue(); @@ -220,7 +248,7 @@ class TokenIterator } public function pushSavePoint() : void { - $this->savePoints[] = $this->index; + $this->savePoints[] = [$this->index, $this->comments]; } public function dropSavePoint() : void { @@ -228,9 +256,9 @@ class TokenIterator } public function rollback() : void { - $index = array_pop($this->savePoints); - assert($index !== null); - $this->index = $index; + $savepoint = array_pop($this->savePoints); + assert($savepoint !== null); + [$this->index, $this->comments] = $savepoint; } /** * @throws ParserException diff --git a/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php b/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php index 13ea951b0c7..69eca8a594c 100644 --- a/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php +++ b/vendor/phpstan/phpdoc-parser/src/Parser/TypeParser.php @@ -32,7 +32,7 @@ class TypeParser } else { $type = $this->parseAtomic($tokens); $tokens->pushSavePoint(); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); try { $enrichedType = $this->enrichTypeOnUnionOrIntersection($tokens, $type); } catch (\PHPStan\PhpDocParser\Parser\ParserException $parserException) { @@ -71,6 +71,10 @@ class TypeParser $type->setAttribute(Ast\Attribute::START_LINE, $startLine); $type->setAttribute(Ast\Attribute::END_LINE, $tokens->currentTokenLine()); } + $comments = $tokens->flushComments(); + if ($this->config->useCommentsAttributes) { + $type->setAttribute(Ast\Attribute::COMMENTS, $comments); + } if ($this->config->useIndexAttributes) { $type->setAttribute(Ast\Attribute::START_INDEX, $startIndex); $type->setAttribute(Ast\Attribute::END_INDEX, $tokens->endIndexOfLastRelevantToken()); @@ -91,7 +95,7 @@ class TypeParser if ($tokens->isCurrentTokenValue('is')) { $type = $this->parseConditional($tokens, $type); } else { - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); if ($tokens->isCurrentTokenType(Lexer::TOKEN_UNION)) { $type = $this->subParseUnion($tokens, $type); } elseif ($tokens->isCurrentTokenType(Lexer::TOKEN_INTERSECTION)) { @@ -107,9 +111,9 @@ class TypeParser $startLine = $tokens->currentTokenLine(); $startIndex = $tokens->currentTokenIndex(); if ($tokens->tryConsumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) { - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $type = $this->subParse($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES); if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) { $type = $this->tryParseArrayOrOffsetAccess($tokens, $type); @@ -194,7 +198,7 @@ class TypeParser while ($tokens->tryConsumeTokenType(Lexer::TOKEN_UNION)) { $types[] = $this->parseAtomic($tokens); $tokens->pushSavePoint(); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); if (!$tokens->isCurrentTokenType(Lexer::TOKEN_UNION)) { $tokens->rollback(); break; @@ -208,9 +212,9 @@ class TypeParser { $types = [$type]; while ($tokens->tryConsumeTokenType(Lexer::TOKEN_UNION)) { - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $types[] = $this->parseAtomic($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); } return new Ast\Type\UnionTypeNode($types); } @@ -221,7 +225,7 @@ class TypeParser while ($tokens->tryConsumeTokenType(Lexer::TOKEN_INTERSECTION)) { $types[] = $this->parseAtomic($tokens); $tokens->pushSavePoint(); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); if (!$tokens->isCurrentTokenType(Lexer::TOKEN_INTERSECTION)) { $tokens->rollback(); break; @@ -235,9 +239,9 @@ class TypeParser { $types = [$type]; while ($tokens->tryConsumeTokenType(Lexer::TOKEN_INTERSECTION)) { - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $types[] = $this->parseAtomic($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); } return new Ast\Type\IntersectionTypeNode($types); } @@ -251,13 +255,13 @@ class TypeParser $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); } $targetType = $this->parse($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $tokens->consumeTokenType(Lexer::TOKEN_NULLABLE); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $ifType = $this->parse($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $tokens->consumeTokenType(Lexer::TOKEN_COLON); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $elseType = $this->subParse($tokens); return new Ast\Type\ConditionalTypeNode($subjectType, $targetType, $ifType, $elseType, $negated); } @@ -272,13 +276,13 @@ class TypeParser $tokens->consumeTokenType(Lexer::TOKEN_IDENTIFIER); } $targetType = $this->parse($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $tokens->consumeTokenType(Lexer::TOKEN_NULLABLE); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $ifType = $this->parse($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $tokens->consumeTokenType(Lexer::TOKEN_COLON); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $elseType = $this->subParse($tokens); return new Ast\Type\ConditionalTypeForParameterNode($parameterName, $targetType, $ifType, $elseType, $negated); } @@ -315,20 +319,21 @@ class TypeParser public function parseGeneric(\PHPStan\PhpDocParser\Parser\TokenIterator $tokens, Ast\Type\IdentifierTypeNode $baseType) : Ast\Type\GenericTypeNode { $tokens->consumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET); + $tokens->skipNewLineTokensAndConsumeComments(); $startLine = $baseType->getAttribute(Ast\Attribute::START_LINE); $startIndex = $baseType->getAttribute(Ast\Attribute::START_INDEX); $genericTypes = []; $variances = []; $isFirst = \true; while ($isFirst || $tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); // trailing comma case if (!$isFirst && $tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET)) { break; } $isFirst = \false; [$genericTypes[], $variances[]] = $this->parseGenericTypeArgument($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); } $type = new Ast\Type\GenericTypeNode($baseType, $genericTypes, $variances); if ($startLine !== null && $startIndex !== null) { @@ -393,18 +398,18 @@ class TypeParser { $templates = $hasTemplate ? $this->parseCallableTemplates($tokens) : []; $tokens->consumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $parameters = []; if (!$tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) { $parameters[] = $this->parseCallableParameter($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); if ($tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) { break; } $parameters[] = $this->parseCallableParameter($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); } } $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES); @@ -425,14 +430,14 @@ class TypeParser $templates = []; $isFirst = \true; while ($isFirst || $tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); // trailing comma case if (!$isFirst && $tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET)) { break; } $isFirst = \false; $templates[] = $this->parseCallableTemplateArgument($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); } $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET); return $templates; @@ -587,29 +592,37 @@ class TypeParser $items = []; $sealed = \true; $unsealedType = null; + $done = \false; do { - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { return Ast\Type\ArrayShapeNode::createSealed($items, $kind); } if ($tokens->tryConsumeTokenType(Lexer::TOKEN_VARIADIC)) { $sealed = \false; - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET)) { if ($kind === Ast\Type\ArrayShapeNode::KIND_ARRAY) { $unsealedType = $this->parseArrayShapeUnsealedType($tokens); } else { $unsealedType = $this->parseListShapeUnsealedType($tokens); } - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); } $tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA); break; } $items[] = $this->parseArrayShapeItem($tokens); - $tokens->skipNewLineTokens(); - } while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); + if (!$tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { + $done = \true; + } + if ($tokens->currentTokenType() !== Lexer::TOKEN_COMMENT) { + continue; + } + $tokens->next(); + } while (!$done); + $tokens->skipNewLineTokensAndConsumeComments(); $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET); if ($sealed) { return Ast\Type\ArrayShapeNode::createSealed($items, $kind); @@ -621,6 +634,8 @@ class TypeParser { $startLine = $tokens->currentTokenLine(); $startIndex = $tokens->currentTokenIndex(); + // parse any comments above the item + $tokens->skipNewLineTokensAndConsumeComments(); try { $tokens->pushSavePoint(); $key = $this->parseArrayShapeKey($tokens); @@ -666,15 +681,15 @@ class TypeParser $startLine = $tokens->currentTokenLine(); $startIndex = $tokens->currentTokenIndex(); $tokens->consumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $valueType = $this->parse($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $keyType = null; if ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) { - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $keyType = $valueType; $valueType = $this->parse($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); } $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET); return $this->enrichWithAttributes($tokens, new Ast\Type\ArrayShapeUnsealedTypeNode($valueType, $keyType), $startLine, $startIndex); @@ -687,9 +702,9 @@ class TypeParser $startLine = $tokens->currentTokenLine(); $startIndex = $tokens->currentTokenIndex(); $tokens->consumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $valueType = $this->parse($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET); return $this->enrichWithAttributes($tokens, new Ast\Type\ArrayShapeUnsealedTypeNode($valueType, null), $startLine, $startIndex); } @@ -701,14 +716,14 @@ class TypeParser $tokens->consumeTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET); $items = []; do { - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) { return new Ast\Type\ObjectShapeNode($items); } $items[] = $this->parseObjectShapeItem($tokens); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); } while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)); - $tokens->skipNewLineTokens(); + $tokens->skipNewLineTokensAndConsumeComments(); $tokens->consumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET); return new Ast\Type\ObjectShapeNode($items); } @@ -717,6 +732,7 @@ class TypeParser { $startLine = $tokens->currentTokenLine(); $startIndex = $tokens->currentTokenIndex(); + $tokens->skipNewLineTokensAndConsumeComments(); $key = $this->parseObjectShapeKey($tokens); $optional = $tokens->tryConsumeTokenType(Lexer::TOKEN_NULLABLE); $tokens->consumeTokenType(Lexer::TOKEN_COLON); diff --git a/vendor/phpstan/phpdoc-parser/src/ParserConfig.php b/vendor/phpstan/phpdoc-parser/src/ParserConfig.php index 6369bd6d170..66a9cc8fcca 100644 --- a/vendor/phpstan/phpdoc-parser/src/ParserConfig.php +++ b/vendor/phpstan/phpdoc-parser/src/ParserConfig.php @@ -7,12 +7,14 @@ class ParserConfig { public bool $useLinesAttributes; public bool $useIndexAttributes; + public bool $useCommentsAttributes; /** - * @param array{lines?: bool, indexes?: bool} $usedAttributes + * @param array{lines?: bool, indexes?: bool, comments?: bool} $usedAttributes */ public function __construct(array $usedAttributes) { $this->useLinesAttributes = $usedAttributes['lines'] ?? \false; $this->useIndexAttributes = $usedAttributes['indexes'] ?? \false; + $this->useCommentsAttributes = $usedAttributes['comments'] ?? \false; } } diff --git a/vendor/phpstan/phpdoc-parser/src/Printer/Printer.php b/vendor/phpstan/phpdoc-parser/src/Printer/Printer.php index 692e3ac6342..829ad5ea7cb 100644 --- a/vendor/phpstan/phpdoc-parser/src/Printer/Printer.php +++ b/vendor/phpstan/phpdoc-parser/src/Printer/Printer.php @@ -5,6 +5,7 @@ namespace PHPStan\PhpDocParser\Printer; use LogicException; use PHPStan\PhpDocParser\Ast\Attribute; +use PHPStan\PhpDocParser\Ast\Comment; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprArrayNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; use PHPStan\PhpDocParser\Ast\Node; @@ -67,6 +68,7 @@ use PHPStan\PhpDocParser\Lexer\Lexer; use PHPStan\PhpDocParser\Parser\TokenIterator; use function array_keys; use function array_map; +use function assert; use function count; use function get_class; use function get_object_vars; @@ -75,6 +77,7 @@ use function in_array; use function is_array; use function preg_match_all; use function sprintf; +use function str_replace; use function strlen; use function strpos; use function trim; @@ -415,20 +418,24 @@ final class Printer } foreach ($diff as $i => $diffElem) { $diffType = $diffElem->type; - $newNode = $diffElem->new; - $originalNode = $diffElem->old; + $arrItem = $diffElem->new; + $origArrayItem = $diffElem->old; if ($diffType === \PHPStan\PhpDocParser\Printer\DiffElem::TYPE_KEEP || $diffType === \PHPStan\PhpDocParser\Printer\DiffElem::TYPE_REPLACE) { $beforeFirstKeepOrReplace = \false; - if (!$newNode instanceof Node || !$originalNode instanceof Node) { + if (!$arrItem instanceof Node || !$origArrayItem instanceof Node) { return null; } /** @var int $itemStartPos */ - $itemStartPos = $originalNode->getAttribute(Attribute::START_INDEX); + $itemStartPos = $origArrayItem->getAttribute(Attribute::START_INDEX); /** @var int $itemEndPos */ - $itemEndPos = $originalNode->getAttribute(Attribute::END_INDEX); + $itemEndPos = $origArrayItem->getAttribute(Attribute::END_INDEX); if ($itemStartPos < 0 || $itemEndPos < 0 || $itemStartPos < $tokenIndex) { throw new LogicException(); } + $comments = $arrItem->getAttribute(Attribute::COMMENTS) ?? []; + $origComments = $origArrayItem->getAttribute(Attribute::COMMENTS) ?? []; + $commentStartPos = count($origComments) > 0 ? $origComments[0]->startIndex : $itemStartPos; + assert($commentStartPos >= 0); $result .= $originalTokens->getContentBetween($tokenIndex, $itemStartPos); if (count($delayedAdd) > 0) { foreach ($delayedAdd as $delayedAddNode) { @@ -436,6 +443,13 @@ final class Printer if ($parenthesesNeeded) { $result .= '('; } + if ($insertNewline) { + $delayedAddComments = $delayedAddNode->getAttribute(Attribute::COMMENTS) ?? []; + if (count($delayedAddComments) > 0) { + $result .= $this->printComments($delayedAddComments, $beforeAsteriskIndent, $afterAsteriskIndent); + $result .= sprintf('%s%s*%s', $originalTokens->getDetectedNewline() ?? "\n", $beforeAsteriskIndent, $afterAsteriskIndent); + } + } $result .= $this->printNodeFormatPreserving($delayedAddNode, $originalTokens); if ($parenthesesNeeded) { $result .= ')'; @@ -448,12 +462,18 @@ final class Printer } $delayedAdd = []; } - $parenthesesNeeded = isset($this->parenthesesListMap[$mapKey]) && in_array(get_class($newNode), $this->parenthesesListMap[$mapKey], \true) && !in_array(get_class($originalNode), $this->parenthesesListMap[$mapKey], \true); + $parenthesesNeeded = isset($this->parenthesesListMap[$mapKey]) && in_array(get_class($arrItem), $this->parenthesesListMap[$mapKey], \true) && !in_array(get_class($origArrayItem), $this->parenthesesListMap[$mapKey], \true); $addParentheses = $parenthesesNeeded && !$originalTokens->hasParentheses($itemStartPos, $itemEndPos); if ($addParentheses) { $result .= '('; } - $result .= $this->printNodeFormatPreserving($newNode, $originalTokens); + if ($comments !== $origComments) { + if (count($comments) > 0) { + $result .= $this->printComments($comments, $beforeAsteriskIndent, $afterAsteriskIndent); + $result .= sprintf('%s%s*%s', $originalTokens->getDetectedNewline() ?? "\n", $beforeAsteriskIndent, $afterAsteriskIndent); + } + } + $result .= $this->printNodeFormatPreserving($arrItem, $originalTokens); if ($addParentheses) { $result .= ')'; } @@ -462,42 +482,48 @@ final class Printer if ($insertStr === null) { return null; } - if (!$newNode instanceof Node) { + if (!$arrItem instanceof Node) { return null; } - if ($insertStr === ', ' && $isMultiline) { + if ($insertStr === ', ' && $isMultiline || count($arrItem->getAttribute(Attribute::COMMENTS) ?? []) > 0) { $insertStr = ','; $insertNewline = \true; } if ($beforeFirstKeepOrReplace) { // Will be inserted at the next "replace" or "keep" element - $delayedAdd[] = $newNode; + $delayedAdd[] = $arrItem; continue; } /** @var int $itemEndPos */ $itemEndPos = $tokenIndex - 1; if ($insertNewline) { - $result .= $insertStr . sprintf('%s%s*%s', $originalTokens->getDetectedNewline() ?? "\n", $beforeAsteriskIndent, $afterAsteriskIndent); + $comments = $arrItem->getAttribute(Attribute::COMMENTS) ?? []; + $result .= $insertStr; + if (count($comments) > 0) { + $result .= sprintf('%s%s*%s', $originalTokens->getDetectedNewline() ?? "\n", $beforeAsteriskIndent, $afterAsteriskIndent); + $result .= $this->printComments($comments, $beforeAsteriskIndent, $afterAsteriskIndent); + } + $result .= sprintf('%s%s*%s', $originalTokens->getDetectedNewline() ?? "\n", $beforeAsteriskIndent, $afterAsteriskIndent); } else { $result .= $insertStr; } - $parenthesesNeeded = isset($this->parenthesesListMap[$mapKey]) && in_array(get_class($newNode), $this->parenthesesListMap[$mapKey], \true); + $parenthesesNeeded = isset($this->parenthesesListMap[$mapKey]) && in_array(get_class($arrItem), $this->parenthesesListMap[$mapKey], \true); if ($parenthesesNeeded) { $result .= '('; } - $result .= $this->printNodeFormatPreserving($newNode, $originalTokens); + $result .= $this->printNodeFormatPreserving($arrItem, $originalTokens); if ($parenthesesNeeded) { $result .= ')'; } $tokenIndex = $itemEndPos + 1; } elseif ($diffType === \PHPStan\PhpDocParser\Printer\DiffElem::TYPE_REMOVE) { - if (!$originalNode instanceof Node) { + if (!$origArrayItem instanceof Node) { return null; } /** @var int $itemStartPos */ - $itemStartPos = $originalNode->getAttribute(Attribute::START_INDEX); + $itemStartPos = $origArrayItem->getAttribute(Attribute::START_INDEX); /** @var int $itemEndPos */ - $itemEndPos = $originalNode->getAttribute(Attribute::END_INDEX); + $itemEndPos = $origArrayItem->getAttribute(Attribute::END_INDEX); if ($itemStartPos < 0 || $itemEndPos < 0) { throw new LogicException(); } @@ -547,6 +573,17 @@ final class Printer } return $result; } + /** + * @param list $comments + */ + private function printComments(array $comments, string $beforeAsteriskIndent, string $afterAsteriskIndent) : string + { + $formattedComments = []; + foreach ($comments as $comment) { + $formattedComments[] = str_replace("\n", "\n" . $beforeAsteriskIndent . '*' . $afterAsteriskIndent, $comment->getReformattedText()); + } + return implode("\n{$beforeAsteriskIndent}*{$afterAsteriskIndent}", $formattedComments); + } /** * @param array $nodes * @return array{bool, string, string} @@ -574,7 +611,7 @@ final class Printer } $c = preg_match_all('~\\n(?[\\x09\\x20]*)\\*(?\\x20*)~', $allText, $matches, PREG_SET_ORDER); if ($c === 0) { - return [$isMultiline, '', '']; + return [$isMultiline, ' ', ' ']; } $before = ''; $after = ''; @@ -587,6 +624,8 @@ final class Printer } $after = $match['after']; } + $before = strlen($before) === 0 ? ' ' : $before; + $after = strlen($after) === 0 ? ' ' : $after; return [$isMultiline, $before, $after]; } private function printNodeFormatPreserving(Node $node, TokenIterator $originalTokens) : string diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 43a181f2ab6..8160c8a79bd 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -30,7 +30,7 @@ if (!function_exists('humbug_phpscoper_expose_class')) { } } humbug_phpscoper_expose_class('AutoloadIncluder', 'RectorPrefix202502\AutoloadIncluder'); -humbug_phpscoper_expose_class('ComposerAutoloaderInita9ca9624b9ec3b7183135fb9d7d95d23', 'RectorPrefix202502\ComposerAutoloaderInita9ca9624b9ec3b7183135fb9d7d95d23'); +humbug_phpscoper_expose_class('ComposerAutoloaderInit30bd5d3b9b1d532a1d3e11eb20f91e28', 'RectorPrefix202502\ComposerAutoloaderInit30bd5d3b9b1d532a1d3e11eb20f91e28'); humbug_phpscoper_expose_class('Product', 'RectorPrefix202502\Product'); humbug_phpscoper_expose_class('SomeTest', 'RectorPrefix202502\SomeTest');