Updated Rector to commit 2d91dd0a11debbf3cedb0b0ccf56824c10ef255f

2d91dd0a11 Add deprecations to Option constants and refer to RectorConfig (#2110)
This commit is contained in:
Tomas Votruba 2022-04-20 19:25:22 +00:00
parent fbc225b532
commit 4ee46cc02c
33 changed files with 276 additions and 206 deletions

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '40e09ab2810dec7659f71cfb91853a023e4dff70';
public const PACKAGE_VERSION = '2d91dd0a11debbf3cedb0b0ccf56824c10ef255f';
/**
* @var string
*/
public const RELEASE_DATE = '2022-04-20 21:00:15';
public const RELEASE_DATE = '2022-04-20 19:19:18';
/**
* @var string
*/

View File

@ -19,6 +19,7 @@ final class Option
*/
public const AUTOLOAD_FILE = 'autoload-file';
/**
* @deprecated Use @see \Rector\Config\RectorConfig::bootstrapFiles() instead
* @var string
*/
public const BOOTSTRAP_FILES = 'bootstrap_files';
@ -39,10 +40,12 @@ final class Option
*/
public const NO_PROGRESS_BAR = 'no-progress-bar';
/**
* @deprecated Use @see \Rector\Config\RectorConfig::phpVersion() instead
* @var string
*/
public const PHP_VERSION_FEATURES = 'php_version_features';
/**
* @deprecated Use @see \Rector\Config\RectorConfig::importNames() instead
* @var string
*/
public const AUTO_IMPORT_NAMES = 'auto_import_names';
@ -51,6 +54,7 @@ final class Option
*/
public const IMPORT_SHORT_CLASSES = 'import_short_classes';
/**
* @deprecated Use @see \Rector\Config\RectorConfig::symfonyContainerXml() instead
* @var string
*/
public const SYMFONY_CONTAINER_XML_PATH_PARAMETER = 'symfony_container_xml_path';
@ -59,18 +63,22 @@ final class Option
*/
public const CLEAR_CACHE = 'clear-cache';
/**
* @deprecated Use @see \Rector\Config\RectorConfig::parallel() instead
* @var string
*/
public const PARALLEL = 'parallel';
/**
* @deprecated Use @see \Rector\Config\RectorConfig::paths() instead
* @var string
*/
public const PATHS = 'paths';
/**
* @deprecated Use @see \Rector\Config\RectorConfig::autoloadPaths() instead
* @var string
*/
public const AUTOLOAD_PATHS = 'autoload_paths';
/**
* @deprecated Use @see \Rector\Config\RectorConfig::skip() instead
* @var string
*/
public const SKIP = \RectorPrefix20220420\Symplify\Skipper\ValueObject\Option::SKIP;
@ -106,6 +114,7 @@ final class Option
*/
public const CONFIG = 'config';
/**
* @deprecated Use @see \Rector\Config\RectorConfig::phpstanConfig() instead
* @var string
*/
public const PHPSTAN_FOR_RECTOR_PATH = 'phpstan_for_rector_path';

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitb6b917d28b8573d48cfb6e801e2a4cc9
class ComposerAutoloaderInitb4d900ca0960e14cd017d258ffc26626
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInitb6b917d28b8573d48cfb6e801e2a4cc9
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitb6b917d28b8573d48cfb6e801e2a4cc9', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitb4d900ca0960e14cd017d258ffc26626', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitb6b917d28b8573d48cfb6e801e2a4cc9', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitb4d900ca0960e14cd017d258ffc26626', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitb6b917d28b8573d48cfb6e801e2a4cc9::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitb4d900ca0960e14cd017d258ffc26626::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitb6b917d28b8573d48cfb6e801e2a4cc9::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInitb4d900ca0960e14cd017d258ffc26626::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireb6b917d28b8573d48cfb6e801e2a4cc9($fileIdentifier, $file);
composerRequireb4d900ca0960e14cd017d258ffc26626($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInitb6b917d28b8573d48cfb6e801e2a4cc9
* @param string $file
* @return void
*/
function composerRequireb6b917d28b8573d48cfb6e801e2a4cc9($fileIdentifier, $file)
function composerRequireb4d900ca0960e14cd017d258ffc26626($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 ComposerStaticInitb6b917d28b8573d48cfb6e801e2a4cc9
class ComposerStaticInitb4d900ca0960e14cd017d258ffc26626
{
public static $files = array (
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@ -3869,9 +3869,9 @@ class ComposerStaticInitb6b917d28b8573d48cfb6e801e2a4cc9
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitb6b917d28b8573d48cfb6e801e2a4cc9::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb6b917d28b8573d48cfb6e801e2a4cc9::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb6b917d28b8573d48cfb6e801e2a4cc9::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitb4d900ca0960e14cd017d258ffc26626::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb4d900ca0960e14cd017d258ffc26626::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitb4d900ca0960e14cd017d258ffc26626::$classMap;
}, null, ClassLoader::class);
}

View File

@ -737,17 +737,17 @@
},
{
"name": "nette\/neon",
"version": "v3.3.2",
"version_normalized": "3.3.2.0",
"version": "v3.3.3",
"version_normalized": "3.3.3.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/nette\/neon.git",
"reference": "54b287d8c2cdbe577b02e28ca1713e275b05ece2"
"reference": "22e384da162fab42961d48eb06c06d3ad0c11b95"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/nette\/neon\/zipball\/54b287d8c2cdbe577b02e28ca1713e275b05ece2",
"reference": "54b287d8c2cdbe577b02e28ca1713e275b05ece2",
"url": "https:\/\/api.github.com\/repos\/nette\/neon\/zipball\/22e384da162fab42961d48eb06c06d3ad0c11b95",
"reference": "22e384da162fab42961d48eb06c06d3ad0c11b95",
"shasum": ""
},
"require": {
@ -759,7 +759,7 @@
"phpstan\/phpstan": "^0.12",
"tracy\/tracy": "^2.7"
},
"time": "2021-11-25T15:57:41+00:00",
"time": "2022-03-10T02:04:26+00:00",
"bin": [
"bin\/neon-lint"
],
@ -802,7 +802,7 @@
],
"support": {
"issues": "https:\/\/github.com\/nette\/neon\/issues",
"source": "https:\/\/github.com\/nette\/neon\/tree\/v3.3.2"
"source": "https:\/\/github.com\/nette\/neon\/tree\/v3.3.3"
},
"install-path": "..\/nette\/neon"
},
@ -2415,21 +2415,21 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-nette.git",
"reference": "2fc8a27a25adaf00169b85347dedd9d0efcb6e10"
"reference": "0b5a94c5611aa3130b6dc0cce4028f7ad0184923"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-nette\/zipball\/2fc8a27a25adaf00169b85347dedd9d0efcb6e10",
"reference": "2fc8a27a25adaf00169b85347dedd9d0efcb6e10",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-nette\/zipball\/0b5a94c5611aa3130b6dc0cce4028f7ad0184923",
"reference": "0b5a94c5611aa3130b6dc0cce4028f7ad0184923",
"shasum": ""
},
"require": {
"ext-xml": "*",
"nette\/neon": "3.3.2",
"nette\/neon": "^3.3.3",
"php": ">=8.1",
"rector\/rector-phpunit": "^0.11.15",
"symfony\/string": "^6.0",
"symplify\/vendor-patches": "^10.0"
"symplify\/vendor-patches": "^10.2"
},
"conflict": {
"rector\/rector": "<0.11"
@ -2443,16 +2443,16 @@
"phpstan\/phpstan-strict-rules": "^1.1",
"phpstan\/phpstan-webmozart-assert": "^1.0",
"phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.4.7",
"rector\/phpstan-rules": "^0.4.24",
"rector\/rector-src": "dev-main",
"symplify\/easy-coding-standard": "^10.0",
"symplify\/monorepo-builder": "^10.0",
"symplify\/phpstan-extensions": "^10.0",
"symplify\/phpstan-rules": "^10.0",
"symplify\/rule-doc-generator": "^10.0",
"symplify\/vendor-patches": "^10.0"
"symplify\/easy-coding-standard": "^10.2",
"symplify\/monorepo-builder": "^10.2",
"symplify\/phpstan-extensions": "^10.2",
"symplify\/phpstan-rules": "^10.2",
"symplify\/rule-doc-generator": "^10.2",
"symplify\/vendor-patches": "^10.2"
},
"time": "2022-04-18T13:39:53+00:00",
"time": "2022-04-20T19:02:05+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -2481,7 +2481,7 @@
],
"description": "Rector upgrades rules for Nette Framework",
"support": {
"source": "https:\/\/github.com\/rectorphp\/rector-nette\/tree\/main"
"source": "https:\/\/github.com\/rectorphp\/rector-nette\/tree\/0.11.58"
},
"install-path": "..\/rector\/rector-nette"
},
@ -2627,12 +2627,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "7dd7cdf3850ff4b0a7839fcf24bb4c26138044de"
"reference": "d554e4e242f165bf71c07b5ac7bff895d987ebc4"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/7dd7cdf3850ff4b0a7839fcf24bb4c26138044de",
"reference": "7dd7cdf3850ff4b0a7839fcf24bb4c26138044de",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/d554e4e242f165bf71c07b5ac7bff895d987ebc4",
"reference": "d554e4e242f165bf71c07b5ac7bff895d987ebc4",
"shasum": ""
},
"require": {
@ -2660,7 +2660,7 @@
"symplify\/rule-doc-generator": "^10.0",
"symplify\/vendor-patches": "^10.0"
},
"time": "2022-04-20T14:22:36+00:00",
"time": "2022-04-20T19:12:09+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -362,7 +362,7 @@ Which is parsed in PHP as follows:
```php
// PHP
new Nette\Neon\Entity(Nette\Neon\Neon::CHAIN, [
new Nette\Neon\Entity(Nette\Neon\Neon::Chain, [
new Nette\Neon\Entity('Column', ['type' => 'int', 'nulls' => true]),
new Nette\Neon\Entity('Field', ['id' => 1]),
])

View File

@ -31,7 +31,7 @@ final class Encoder
{
if ($val instanceof \DateTimeInterface) {
return new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode($val);
} elseif ($val instanceof \RectorPrefix20220420\Nette\Neon\Entity && $val->value === \RectorPrefix20220420\Nette\Neon\Neon::CHAIN) {
} elseif ($val instanceof \RectorPrefix20220420\Nette\Neon\Entity && $val->value === \RectorPrefix20220420\Nette\Neon\Neon::Chain) {
$node = new \RectorPrefix20220420\Nette\Neon\Node\EntityChainNode();
foreach ($val->attributes as $entity) {
$node->chain[] = $this->valueToNode($entity);
@ -54,6 +54,7 @@ final class Encoder
return new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode($val);
}
}
/** @return Node\ArrayItemNode[] */
private function arrayToNodes($val, bool $blockMode = \false) : array
{
$res = [];

View File

@ -14,13 +14,14 @@ final class Entity extends \stdClass
{
/** @var mixed */
public $value;
/** @var array */
/** @var mixed[] */
public $attributes;
public function __construct($value, array $attrs = [])
{
$this->value = $value;
$this->attributes = $attrs;
}
/** @param mixed[] $properties */
public static function __set_state(array $properties)
{
return new self($properties['value'], $properties['attributes']);

View File

@ -10,16 +10,16 @@ namespace RectorPrefix20220420\Nette\Neon;
/** @internal */
final class Lexer
{
public const PATTERNS = [
public const Patterns = [
// strings
\RectorPrefix20220420\Nette\Neon\Token::STRING => '
\RectorPrefix20220420\Nette\Neon\Token::String => '
\'\'\'\\n (?:(?: [^\\n] | \\n(?![\\t\\ ]*+\'\'\') )*+ \\n)?[\\t\\ ]*+\'\'\' |
"""\\n (?:(?: [^\\n] | \\n(?![\\t\\ ]*+""") )*+ \\n)?[\\t\\ ]*+""" |
\' (?: \'\' | [^\'\\n] )*+ \' |
" (?: \\\\. | [^"\\\\\\n] )*+ "
',
// literal / boolean / integer / float
\RectorPrefix20220420\Nette\Neon\Token::LITERAL => '
\RectorPrefix20220420\Nette\Neon\Token::Literal => '
(?: [^#"\',:=[\\]{}()\\n\\t\\ `-] | (?<!["\']) [:-] [^"\',=[\\]{}()\\n\\t\\ ] )
(?:
[^,:=\\]})(\\n\\t\\ ]++ |
@ -28,23 +28,23 @@ final class Lexer
)*+
',
// punctuation
\RectorPrefix20220420\Nette\Neon\Token::CHAR => '[,:=[\\]{}()-]',
\RectorPrefix20220420\Nette\Neon\Token::Char => '[,:=[\\]{}()-]',
// comment
\RectorPrefix20220420\Nette\Neon\Token::COMMENT => '\\#.*+',
\RectorPrefix20220420\Nette\Neon\Token::Comment => '\\#.*+',
// new line
\RectorPrefix20220420\Nette\Neon\Token::NEWLINE => '\\n++',
\RectorPrefix20220420\Nette\Neon\Token::Newline => '\\n++',
// whitespace
\RectorPrefix20220420\Nette\Neon\Token::WHITESPACE => '[\\t\\ ]++',
\RectorPrefix20220420\Nette\Neon\Token::Whitespace => '[\\t\\ ]++',
];
public function tokenize(string $input) : \RectorPrefix20220420\Nette\Neon\TokenStream
{
$input = \str_replace("\r", '', $input);
$pattern = '~(' . \implode(')|(', self::PATTERNS) . ')~Amixu';
$pattern = '~(' . \implode(')|(', self::Patterns) . ')~Amixu';
$res = \preg_match_all($pattern, $input, $tokens, \PREG_SET_ORDER);
if ($res === \false) {
throw new \RectorPrefix20220420\Nette\Neon\Exception('Invalid UTF-8 sequence.');
}
$types = \array_keys(self::PATTERNS);
$types = \array_keys(self::Patterns);
$offset = 0;
foreach ($tokens as &$token) {
$type = null;
@ -53,13 +53,13 @@ final class Lexer
break;
} elseif ($token[$i] !== '') {
$type = $types[$i - 1];
if ($type === \RectorPrefix20220420\Nette\Neon\Token::CHAR) {
if ($type === \RectorPrefix20220420\Nette\Neon\Token::Char) {
$type = $token[0];
}
break;
}
}
$token = new \RectorPrefix20220420\Nette\Neon\Token($token[0], $offset, $type);
$token = new \RectorPrefix20220420\Nette\Neon\Token($token[0], $type);
$offset += \strlen($token->value);
}
$stream = new \RectorPrefix20220420\Nette\Neon\TokenStream($tokens);
@ -71,6 +71,6 @@ final class Lexer
}
public static function requiresDelimiters(string $s) : bool
{
return \preg_match('~[\\x00-\\x1F]|^[+-.]?\\d|^(true|false|yes|no|on|off|null)$~Di', $s) || !\preg_match('~^' . self::PATTERNS[\RectorPrefix20220420\Nette\Neon\Token::LITERAL] . '$~Dx', $s);
return \preg_match('~[\\x00-\\x1F]|^[+-.]?\\d|^(true|false|yes|no|on|off|null)$~Di', $s) || !\preg_match('~^' . self::Patterns[\RectorPrefix20220420\Nette\Neon\Token::Literal] . '$~Dx', $s);
}
}

View File

@ -14,7 +14,8 @@ namespace RectorPrefix20220420\Nette\Neon;
final class Neon
{
public const BLOCK = \RectorPrefix20220420\Nette\Neon\Encoder::BLOCK;
public const CHAIN = '!!chain';
public const Chain = '!!chain';
public const CHAIN = self::Chain;
/**
* Returns value converted to NEON.
*/

View File

@ -7,19 +7,25 @@
declare (strict_types=1);
namespace RectorPrefix20220420\Nette\Neon;
/** @internal */
abstract class Node
/**
* @implements \IteratorAggregate<Node>
*/
abstract class Node implements \IteratorAggregate
{
/** @var ?int */
public $startPos;
public $startTokenPos;
/** @var ?int */
public $endPos;
public $endTokenPos;
/** @var ?int */
public $startLine;
/** @var ?int */
public $endLine;
/** @return mixed */
public abstract function toValue();
public abstract function toString() : string;
/** @return self[] */
public function getSubNodes() : array
public function &getIterator() : \Generator
{
return [];
return;
yield;
}
}

View File

@ -15,11 +15,10 @@ final class ArrayItemNode extends \RectorPrefix20220420\Nette\Neon\Node
public $key;
/** @var Node */
public $value;
public function __construct(int $pos = null)
{
$this->startPos = $this->endPos = $pos;
}
/** @param self[] $items */
/**
* @param self[] $items
* @return mixed[]
*/
public static function itemsToArray(array $items) : array
{
$res = [];
@ -59,8 +58,11 @@ final class ArrayItemNode extends \RectorPrefix20220420\Nette\Neon\Node
{
throw new \LogicException();
}
public function getSubNodes() : array
public function &getIterator() : \Generator
{
return $this->key ? [&$this->key, &$this->value] : [&$this->value];
if ($this->key) {
(yield $this->key);
}
(yield $this->value);
}
}

View File

@ -13,16 +13,15 @@ abstract class ArrayNode extends \RectorPrefix20220420\Nette\Neon\Node
{
/** @var ArrayItemNode[] */
public $items = [];
/** @return mixed[] */
public function toValue() : array
{
return \RectorPrefix20220420\Nette\Neon\Node\ArrayItemNode::itemsToArray($this->items);
}
public function getSubNodes() : array
public function &getIterator() : \Generator
{
$res = [];
foreach ($this->items as &$item) {
$res[] =& $item;
(yield $item);
}
return $res;
}
}

View File

@ -12,10 +12,9 @@ final class BlockArrayNode extends \RectorPrefix20220420\Nette\Neon\Node\ArrayNo
{
/** @var string */
public $indentation;
public function __construct(string $indentation = '', int $pos = null)
public function __construct(string $indentation = '')
{
$this->indentation = $indentation;
$this->startPos = $this->endPos = $pos;
}
public function toString() : string
{

View File

@ -14,11 +14,9 @@ final class EntityChainNode extends \RectorPrefix20220420\Nette\Neon\Node
{
/** @var EntityNode[] */
public $chain = [];
public function __construct(array $chain = [], int $startPos = null, int $endPos = null)
public function __construct(array $chain = [])
{
$this->chain = $chain;
$this->startPos = $startPos;
$this->endPos = $endPos ?? $startPos;
}
public function toValue() : \RectorPrefix20220420\Nette\Neon\Entity
{
@ -26,7 +24,7 @@ final class EntityChainNode extends \RectorPrefix20220420\Nette\Neon\Node
foreach ($this->chain as $item) {
$entities[] = $item->toValue();
}
return new \RectorPrefix20220420\Nette\Neon\Entity(\RectorPrefix20220420\Nette\Neon\Neon::CHAIN, $entities);
return new \RectorPrefix20220420\Nette\Neon\Entity(\RectorPrefix20220420\Nette\Neon\Neon::Chain, $entities);
}
public function toString() : string
{
@ -34,12 +32,10 @@ final class EntityChainNode extends \RectorPrefix20220420\Nette\Neon\Node
return $entity->toString();
}, $this->chain));
}
public function getSubNodes() : array
public function &getIterator() : \Generator
{
$res = [];
foreach ($this->chain as &$item) {
$res[] =& $item;
(yield $item);
}
return $res;
}
}

View File

@ -15,13 +15,11 @@ final class EntityNode extends \RectorPrefix20220420\Nette\Neon\Node
/** @var Node */
public $value;
/** @var ArrayItemNode[] */
public $attributes = [];
public function __construct(\RectorPrefix20220420\Nette\Neon\Node $value, array $attributes, int $startPos = null, int $endPos = null)
public $attributes;
public function __construct(\RectorPrefix20220420\Nette\Neon\Node $value, array $attributes = [])
{
$this->value = $value;
$this->attributes = $attributes;
$this->startPos = $startPos;
$this->endPos = $endPos ?? $startPos;
}
public function toValue() : \RectorPrefix20220420\Nette\Neon\Entity
{
@ -31,12 +29,11 @@ final class EntityNode extends \RectorPrefix20220420\Nette\Neon\Node
{
return $this->value->toString() . '(' . ($this->attributes ? \RectorPrefix20220420\Nette\Neon\Node\ArrayItemNode::itemsToInlineString($this->attributes) : '') . ')';
}
public function getSubNodes() : array
public function &getIterator() : \Generator
{
$res = [&$this->value];
(yield $this->value);
foreach ($this->attributes as &$item) {
$res[] =& $item;
(yield $item);
}
return $res;
}
}

View File

@ -12,10 +12,9 @@ final class InlineArrayNode extends \RectorPrefix20220420\Nette\Neon\Node\ArrayN
{
/** @var string */
public $bracket;
public function __construct(string $bracket, int $pos = null)
public function __construct(string $bracket)
{
$this->bracket = $bracket;
$this->startPos = $this->endPos = $pos;
}
public function toString() : string
{

View File

@ -11,18 +11,17 @@ use RectorPrefix20220420\Nette\Neon\Node;
/** @internal */
final class LiteralNode extends \RectorPrefix20220420\Nette\Neon\Node
{
private const SIMPLE_TYPES = ['true' => \true, 'True' => \true, 'TRUE' => \true, 'yes' => \true, 'Yes' => \true, 'YES' => \true, 'on' => \true, 'On' => \true, 'ON' => \true, 'false' => \false, 'False' => \false, 'FALSE' => \false, 'no' => \false, 'No' => \false, 'NO' => \false, 'off' => \false, 'Off' => \false, 'OFF' => \false, 'null' => null, 'Null' => null, 'NULL' => null];
private const DEPRECATED_TYPES = ['on' => 1, 'On' => 1, 'ON' => 1, 'off' => 1, 'Off' => 1, 'OFF' => 1];
private const PATTERN_DATETIME = '#\\d\\d\\d\\d-\\d\\d?-\\d\\d?(?:(?:[Tt]| ++)\\d\\d?:\\d\\d:\\d\\d(?:\\.\\d*+)? *+(?:Z|[-+]\\d\\d?(?::?\\d\\d)?)?)?$#DA';
private const PATTERN_HEX = '#0x[0-9a-fA-F]++$#DA';
private const PATTERN_OCTAL = '#0o[0-7]++$#DA';
private const PATTERN_BINARY = '#0b[0-1]++$#DA';
private const SimpleTypes = ['true' => \true, 'True' => \true, 'TRUE' => \true, 'yes' => \true, 'Yes' => \true, 'YES' => \true, 'on' => \true, 'On' => \true, 'ON' => \true, 'false' => \false, 'False' => \false, 'FALSE' => \false, 'no' => \false, 'No' => \false, 'NO' => \false, 'off' => \false, 'Off' => \false, 'OFF' => \false, 'null' => null, 'Null' => null, 'NULL' => null];
private const DeprecatedTypes = ['on' => 1, 'On' => 1, 'ON' => 1, 'off' => 1, 'Off' => 1, 'OFF' => 1];
private const PatternDatetime = '#\\d\\d\\d\\d-\\d\\d?-\\d\\d?(?:(?:[Tt]| ++)\\d\\d?:\\d\\d:\\d\\d(?:\\.\\d*+)? *+(?:Z|[-+]\\d\\d?(?::?\\d\\d)?)?)?$#DA';
private const PatternHex = '#0x[0-9a-fA-F]++$#DA';
private const PatternOctal = '#0o[0-7]++$#DA';
private const PatternBinary = '#0b[0-1]++$#DA';
/** @var mixed */
public $value;
public function __construct($value, int $pos = null)
public function __construct($value)
{
$this->value = $value;
$this->startPos = $this->endPos = $pos;
}
public function toValue()
{
@ -31,20 +30,20 @@ final class LiteralNode extends \RectorPrefix20220420\Nette\Neon\Node
/** @return mixed */
public static function parse(string $value, bool $isKey = \false)
{
if (!$isKey && \array_key_exists($value, self::SIMPLE_TYPES)) {
if (isset(self::DEPRECATED_TYPES[$value])) {
if (!$isKey && \array_key_exists($value, self::SimpleTypes)) {
if (isset(self::DeprecatedTypes[$value])) {
\trigger_error("Neon: keyword '{$value}' is deprecated, use true/yes or false/no.", \E_USER_DEPRECATED);
}
return self::SIMPLE_TYPES[$value];
return self::SimpleTypes[$value];
} elseif (\is_numeric($value)) {
return $value * 1;
} elseif (\preg_match(self::PATTERN_HEX, $value)) {
} elseif (\preg_match(self::PatternHex, $value)) {
return \hexdec($value);
} elseif (\preg_match(self::PATTERN_OCTAL, $value)) {
} elseif (\preg_match(self::PatternOctal, $value)) {
return \octdec($value);
} elseif (\preg_match(self::PATTERN_BINARY, $value)) {
} elseif (\preg_match(self::PatternBinary, $value)) {
return \bindec($value);
} elseif (!$isKey && \preg_match(self::PATTERN_DATETIME, $value)) {
} elseif (!$isKey && \preg_match(self::PatternDatetime, $value)) {
return new \DateTimeImmutable($value);
} else {
return $value;

View File

@ -12,13 +12,12 @@ use RectorPrefix20220420\Nette\Neon\Node;
/** @internal */
final class StringNode extends \RectorPrefix20220420\Nette\Neon\Node
{
private const ESCAPE_SEQUENCES = ['t' => "\t", 'n' => "\n", 'r' => "\r", 'f' => "\f", 'b' => "\10", '"' => '"', '\\' => '\\', '/' => '/', '_' => " "];
private const EscapeSequences = ['t' => "\t", 'n' => "\n", 'r' => "\r", 'f' => "\f", 'b' => "\10", '"' => '"', '\\' => '\\', '/' => '/', '_' => " "];
/** @var string */
public $value;
public function __construct(string $value, int $pos = null)
public function __construct(string $value)
{
$this->value = $value;
$this->startPos = $this->endPos = $pos;
}
public function toValue() : string
{
@ -42,8 +41,8 @@ final class StringNode extends \RectorPrefix20220420\Nette\Neon\Node
}
return \preg_replace_callback('#\\\\(?:ud[89ab][0-9a-f]{2}\\\\ud[c-f][0-9a-f]{2}|u[0-9a-f]{4}|x[0-9a-f]{2}|.)#i', function (array $m) : string {
$sq = $m[0];
if (isset(self::ESCAPE_SEQUENCES[$sq[1]])) {
return self::ESCAPE_SEQUENCES[$sq[1]];
if (isset(self::EscapeSequences[$sq[1]])) {
return self::EscapeSequences[$sq[1]];
} elseif ($sq[1] === 'u' && \strlen($sq) >= 6) {
if (($res = \json_decode('"' . $sq . '"')) !== null) {
return $res;
@ -59,16 +58,20 @@ final class StringNode extends \RectorPrefix20220420\Nette\Neon\Node
}
public function toString() : string
{
$res = \json_encode($this->value, \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES);
if ($res === \false) {
throw new \RectorPrefix20220420\Nette\Neon\Exception('Invalid UTF-8 sequence: ' . $this->value);
if (\strpos($this->value, "\n") === \false) {
return "'" . \str_replace("'", "''", $this->value) . "'";
} elseif (\preg_match('~\\n[\\t ]+\'{3}~', $this->value)) {
$s = \json_encode($this->value, \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES);
$s = \preg_replace_callback('#[^\\\\]|\\\\(.)#s', function ($m) {
return ['n' => "\n", 't' => "\t", '"' => '"'][$m[1] ?? ''] ?? $m[0];
}, \substr($s, 1, -1));
$s = \str_replace('"""', '""\\"', $s);
$delim = '"""';
} else {
$s = $this->value;
$delim = "'''";
}
if (\strpos($this->value, "\n") !== \false) {
$res = \preg_replace_callback('#[^\\\\]|\\\\(.)#s', function ($m) {
return ['n' => "\n\t", 't' => "\t", '"' => '"'][$m[1] ?? ''] ?? $m[0];
}, $res);
$res = '"""' . "\n\t" . \substr($res, 1, -1) . "\n" . '"""';
}
return $res;
$s = \preg_replace('#^(?=.)#m', "\t", $s);
return $delim . "\n" . $s . "\n" . $delim;
}
}

View File

@ -12,13 +12,16 @@ final class Parser
{
/** @var TokenStream */
private $tokens;
/** @var int[] */
private $posToLine = [];
public function parse(\RectorPrefix20220420\Nette\Neon\TokenStream $tokens) : \RectorPrefix20220420\Nette\Neon\Node
{
$this->tokens = $tokens;
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::NEWLINE)) {
$this->initLines();
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::Newline)) {
}
$node = $this->parseBlock($this->tokens->getIndentation());
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::NEWLINE)) {
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::Newline)) {
}
if ($this->tokens->isNext()) {
$this->tokens->error();
@ -27,14 +30,16 @@ final class Parser
}
private function parseBlock(string $indent, bool $onlyBullets = \false) : \RectorPrefix20220420\Nette\Neon\Node
{
$res = new \RectorPrefix20220420\Nette\Neon\Node\BlockArrayNode($indent, $this->tokens->getPos());
$res = new \RectorPrefix20220420\Nette\Neon\Node\BlockArrayNode($indent);
$this->injectPos($res);
$keyCheck = [];
loop:
$item = new \RectorPrefix20220420\Nette\Neon\Node\ArrayItemNode($this->tokens->getPos());
$item = new \RectorPrefix20220420\Nette\Neon\Node\ArrayItemNode();
$this->injectPos($item);
if ($this->tokens->consume('-')) {
// continue
} elseif (!$this->tokens->isNext() || $onlyBullets) {
return $res->items ? $res : new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode(null, $this->tokens->getPos());
return $res->items ? $res : $this->injectPos(new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode(null));
} else {
$value = $this->parseValue();
if ($this->tokens->consume(':', '=')) {
@ -48,9 +53,10 @@ final class Parser
}
}
$res->items[] = $item;
$item->value = new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode(null, $this->tokens->getPos());
if ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::NEWLINE)) {
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::NEWLINE)) {
$item->value = new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode(null);
$this->injectPos($item->value);
if ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::Newline)) {
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::Newline)) {
}
$nextIndent = $this->tokens->getIndentation();
if (\strncmp($nextIndent, $indent, \min(\strlen($nextIndent), \strlen($indent)))) {
@ -70,15 +76,16 @@ final class Parser
// open new block after dash
} elseif ($this->tokens->isNext()) {
$item->value = $this->parseValue();
if ($this->tokens->isNext() && !$this->tokens->isNext(\RectorPrefix20220420\Nette\Neon\Token::NEWLINE)) {
if ($this->tokens->isNext() && !$this->tokens->isNext(\RectorPrefix20220420\Nette\Neon\Token::Newline)) {
$this->tokens->error();
}
}
if ($item->value instanceof \RectorPrefix20220420\Nette\Neon\Node\BlockArrayNode) {
$item->value->indentation = \substr($item->value->indentation, \strlen($indent));
}
$res->endPos = $item->endPos = $item->value->endPos;
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::NEWLINE)) {
$this->injectPos($res, $res->startTokenPos, $item->value->endTokenPos);
$this->injectPos($item, $item->startTokenPos, $item->value->endTokenPos);
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::Newline)) {
}
if (!$this->tokens->isNext()) {
return $res;
@ -96,15 +103,17 @@ final class Parser
}
private function parseValue() : \RectorPrefix20220420\Nette\Neon\Node
{
if ($token = $this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::STRING)) {
if ($token = $this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::String)) {
try {
$node = new \RectorPrefix20220420\Nette\Neon\Node\StringNode(\RectorPrefix20220420\Nette\Neon\Node\StringNode::parse($token->value), $this->tokens->getPos() - 1);
$node = new \RectorPrefix20220420\Nette\Neon\Node\StringNode(\RectorPrefix20220420\Nette\Neon\Node\StringNode::parse($token->value));
$this->injectPos($node, $this->tokens->getPos() - 1);
} catch (\RectorPrefix20220420\Nette\Neon\Exception $e) {
$this->tokens->error($e->getMessage(), $this->tokens->getPos() - 1);
}
} elseif ($token = $this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::LITERAL)) {
} elseif ($token = $this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::Literal)) {
$pos = $this->tokens->getPos() - 1;
$node = new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode(\RectorPrefix20220420\Nette\Neon\Node\LiteralNode::parse($token->value, $this->tokens->isNext(':', '=')), $pos);
$node = new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode(\RectorPrefix20220420\Nette\Neon\Node\LiteralNode::parse($token->value, $this->tokens->isNext(':', '=')));
$this->injectPos($node, $pos);
} elseif ($this->tokens->isNext('[', '(', '{')) {
$node = $this->parseBraces();
} else {
@ -118,61 +127,83 @@ final class Parser
return $node;
}
$attributes = $this->parseBraces();
$entities[] = new \RectorPrefix20220420\Nette\Neon\Node\EntityNode($node, $attributes->items, $node->startPos, $attributes->endPos);
while ($token = $this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::LITERAL)) {
$valueNode = new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode(\RectorPrefix20220420\Nette\Neon\Node\LiteralNode::parse($token->value), $this->tokens->getPos() - 1);
$entities[] = $this->injectPos(new \RectorPrefix20220420\Nette\Neon\Node\EntityNode($node, $attributes->items), $node->startTokenPos, $attributes->endTokenPos);
while ($token = $this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::Literal)) {
$valueNode = new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode(\RectorPrefix20220420\Nette\Neon\Node\LiteralNode::parse($token->value));
$this->injectPos($valueNode, $this->tokens->getPos() - 1);
if ($this->tokens->isNext('(')) {
$attributes = $this->parseBraces();
$entities[] = new \RectorPrefix20220420\Nette\Neon\Node\EntityNode($valueNode, $attributes->items, $valueNode->startPos, $attributes->endPos);
$entities[] = $this->injectPos(new \RectorPrefix20220420\Nette\Neon\Node\EntityNode($valueNode, $attributes->items), $valueNode->startTokenPos, $attributes->endTokenPos);
} else {
$entities[] = new \RectorPrefix20220420\Nette\Neon\Node\EntityNode($valueNode, [], $valueNode->startPos);
$entities[] = $this->injectPos(new \RectorPrefix20220420\Nette\Neon\Node\EntityNode($valueNode), $valueNode->startTokenPos);
break;
}
}
return \count($entities) === 1 ? $entities[0] : new \RectorPrefix20220420\Nette\Neon\Node\EntityChainNode($entities, $node->startPos, \end($entities)->endPos);
return \count($entities) === 1 ? $entities[0] : $this->injectPos(new \RectorPrefix20220420\Nette\Neon\Node\EntityChainNode($entities), $node->startTokenPos, \end($entities)->endTokenPos);
}
private function parseBraces() : \RectorPrefix20220420\Nette\Neon\Node\InlineArrayNode
{
$token = $this->tokens->consume();
$endBrace = ['[' => ']', '{' => '}', '(' => ')'][$token->value];
$res = new \RectorPrefix20220420\Nette\Neon\Node\InlineArrayNode($token->value, $this->tokens->getPos() - 1);
$res = new \RectorPrefix20220420\Nette\Neon\Node\InlineArrayNode($token->value);
$this->injectPos($res, $this->tokens->getPos() - 1);
$keyCheck = [];
loop:
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::NEWLINE)) {
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::Newline)) {
}
if ($this->tokens->consume($endBrace)) {
$res->endPos = $this->tokens->getPos() - 1;
$this->injectPos($res, $res->startTokenPos, $this->tokens->getPos() - 1);
return $res;
}
$res->items[] = $item = new \RectorPrefix20220420\Nette\Neon\Node\ArrayItemNode($this->tokens->getPos());
$res->items[] = $item = new \RectorPrefix20220420\Nette\Neon\Node\ArrayItemNode();
$this->injectPos($item, $this->tokens->getPos());
$value = $this->parseValue();
if ($this->tokens->consume(':', '=')) {
$this->checkArrayKey($value, $keyCheck);
$item->key = $value;
$item->value = $this->tokens->isNext(\RectorPrefix20220420\Nette\Neon\Token::NEWLINE, ',', $endBrace) ? new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode(null, $this->tokens->getPos()) : $this->parseValue();
$item->value = $this->tokens->isNext(\RectorPrefix20220420\Nette\Neon\Token::Newline, ',', $endBrace) ? $this->injectPos(new \RectorPrefix20220420\Nette\Neon\Node\LiteralNode(null), $this->tokens->getPos()) : $this->parseValue();
} else {
$item->value = $value;
}
$item->endPos = $item->value->endPos;
if ($this->tokens->consume(',', \RectorPrefix20220420\Nette\Neon\Token::NEWLINE)) {
$this->injectPos($item, $item->startTokenPos, $item->value->endTokenPos);
if ($this->tokens->consume(',', \RectorPrefix20220420\Nette\Neon\Token::Newline)) {
goto loop;
}
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::NEWLINE)) {
while ($this->tokens->consume(\RectorPrefix20220420\Nette\Neon\Token::Newline)) {
}
if (!$this->tokens->isNext($endBrace)) {
$this->tokens->error();
}
goto loop;
}
/** @param true[] $arr */
private function checkArrayKey(\RectorPrefix20220420\Nette\Neon\Node $key, array &$arr) : void
{
if (!$key instanceof \RectorPrefix20220420\Nette\Neon\Node\StringNode && !$key instanceof \RectorPrefix20220420\Nette\Neon\Node\LiteralNode || !\is_scalar($key->value)) {
$this->tokens->error('Unacceptable key', $key->startPos);
$this->tokens->error('Unacceptable key', $key->startTokenPos);
}
$k = (string) $key->value;
if (\array_key_exists($k, $arr)) {
$this->tokens->error("Duplicated key '{$k}'", $key->startPos);
$this->tokens->error("Duplicated key '{$k}'", $key->startTokenPos);
}
$arr[$k] = \true;
}
private function injectPos(\RectorPrefix20220420\Nette\Neon\Node $node, int $start = null, int $end = null) : \RectorPrefix20220420\Nette\Neon\Node
{
$node->startTokenPos = $start ?? $this->tokens->getPos();
$node->startLine = $this->posToLine[$node->startTokenPos];
$node->endTokenPos = $end ?? $node->startTokenPos;
$node->endLine = $this->posToLine[$node->endTokenPos + 1] ?? \end($this->posToLine);
return $node;
}
private function initLines() : void
{
$this->posToLine = [];
$line = 1;
foreach ($this->tokens->getTokens() as $token) {
$this->posToLine[] = $line;
$line += \substr_count($token->value, "\n");
}
$this->posToLine[] = $line;
}
}

View File

@ -10,22 +10,19 @@ namespace RectorPrefix20220420\Nette\Neon;
/** @internal */
final class Token
{
public const STRING = 1;
public const LITERAL = 2;
public const CHAR = 0;
public const COMMENT = 3;
public const NEWLINE = 4;
public const WHITESPACE = 5;
public const String = 1;
public const Literal = 2;
public const Char = 0;
public const Comment = 3;
public const Newline = 4;
public const Whitespace = 5;
/** @var string */
public $value;
/** @var int */
public $offset;
/** @var int|string */
public $type;
public function __construct(string $value, int $offset, $type)
public function __construct(string $value, $type)
{
$this->value = $value;
$this->offset = $offset;
$this->type = $type;
}
}

View File

@ -29,7 +29,7 @@ final class TokenStream
}
public function isNext(...$types) : bool
{
while (\in_array($this->tokens[$this->pos]->type ?? null, [\RectorPrefix20220420\Nette\Neon\Token::COMMENT, \RectorPrefix20220420\Nette\Neon\Token::WHITESPACE], \true)) {
while (\in_array($this->tokens[$this->pos]->type ?? null, [\RectorPrefix20220420\Nette\Neon\Token::Comment, \RectorPrefix20220420\Nette\Neon\Token::Whitespace], \true)) {
$this->pos++;
}
return $types ? \in_array($this->tokens[$this->pos]->type ?? null, $types, \true) : isset($this->tokens[$this->pos]);
@ -40,10 +40,10 @@ final class TokenStream
}
public function getIndentation() : string
{
return \in_array($this->tokens[$this->pos - 2]->type ?? null, [\RectorPrefix20220420\Nette\Neon\Token::NEWLINE, null], \true) && ($this->tokens[$this->pos - 1]->type ?? null) === \RectorPrefix20220420\Nette\Neon\Token::WHITESPACE ? $this->tokens[$this->pos - 1]->value : '';
return \in_array($this->tokens[$this->pos - 2]->type ?? null, [\RectorPrefix20220420\Nette\Neon\Token::Newline, null], \true) && ($this->tokens[$this->pos - 1]->type ?? null) === \RectorPrefix20220420\Nette\Neon\Token::Whitespace ? $this->tokens[$this->pos - 1]->value : '';
}
/** @return never */
public function error(string $message = null, int $pos = null) : void
public function error(?string $message = null, ?int $pos = null) : void
{
$pos = $pos ?? $this->pos;
$input = '';

View File

@ -10,19 +10,54 @@ namespace RectorPrefix20220420\Nette\Neon;
/** @internal */
final class Traverser
{
/** @var callable(Node): ?Node */
private $callback;
/** @param callable(Node): ?Node $callback */
public function traverse(\RectorPrefix20220420\Nette\Neon\Node $node, callable $callback) : \RectorPrefix20220420\Nette\Neon\Node
public const DontTraverseChildren = 1;
public const StopTraversal = 2;
/** @var callable(Node): (Node|int|null)|null */
private $enter;
/** @var callable(Node): (Node|int|null)|null */
private $leave;
/** @var bool */
private $stop;
/**
* @param callable(Node): (Node|int|null)|null $enter
* @param callable(Node): (Node|int|null)|null $leave
*/
public function traverse(\RectorPrefix20220420\Nette\Neon\Node $node, ?callable $enter = null, ?callable $leave = null) : \RectorPrefix20220420\Nette\Neon\Node
{
$this->callback = $callback;
$this->enter = $enter;
$this->leave = $leave;
$this->stop = \false;
return $this->traverseNode($node);
}
private function traverseNode(\RectorPrefix20220420\Nette\Neon\Node $node) : \RectorPrefix20220420\Nette\Neon\Node
{
$node = ($this->callback)($node) ?? $node;
foreach ($node->getSubNodes() as &$subnode) {
$subnode = $this->traverseNode($subnode);
$children = \true;
if ($this->enter) {
$res = ($this->enter)($node);
if ($res instanceof \RectorPrefix20220420\Nette\Neon\Node) {
$node = $res;
} elseif ($res === self::DontTraverseChildren) {
$children = \false;
} elseif ($res === self::StopTraversal) {
$this->stop = \true;
$children = \false;
}
}
if ($children) {
foreach ($node as &$subnode) {
$subnode = $this->traverseNode($subnode);
if ($this->stop) {
break;
}
}
}
if (!$this->stop && $this->leave) {
$res = ($this->leave)($node);
if ($res instanceof \RectorPrefix20220420\Nette\Neon\Node) {
$node = $res;
} elseif ($res === self::StopTraversal) {
$this->stop = \true;
}
}
return $node;
}

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main dc4fbb8'), '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 3f5c267'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5d945fb'), '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 b794171'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 2fc8a27'), '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 236ccc2'), '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 c61751f'), '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 7dd7cdf'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7b11cdd'));
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main dc4fbb8'), '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 3f5c267'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5d945fb'), '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 b794171'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 0b5a94c'), '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 236ccc2'), '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 c61751f'), '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 d554e4e'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 7b11cdd'));
private function __construct()
{
}

View File

@ -6,28 +6,28 @@
"require": {
"php": ">=8.1",
"ext-xml": "*",
"nette\/neon": "3.3.2",
"nette\/neon": "^3.3.3",
"rector\/rector-phpunit": "^0.11.15",
"symplify\/vendor-patches": "^10.0",
"symplify\/vendor-patches": "^10.2",
"symfony\/string": "^6.0"
},
"require-dev": {
"rector\/rector-src": "dev-main",
"phpunit\/phpunit": "^9.5",
"symplify\/phpstan-extensions": "^10.0",
"symplify\/phpstan-rules": "^10.0",
"symplify\/easy-coding-standard": "^10.0",
"symplify\/monorepo-builder": "^10.0",
"symplify\/phpstan-extensions": "^10.2",
"symplify\/phpstan-rules": "^10.2",
"symplify\/easy-coding-standard": "^10.2",
"symplify\/monorepo-builder": "^10.2",
"phpstan\/phpstan-nette": "^1.0",
"nette\/application": "^3.1",
"nette\/di": "^3.0",
"nette\/forms": "3.0.*",
"symplify\/rule-doc-generator": "^10.0",
"symplify\/rule-doc-generator": "^10.2",
"phpstan\/extension-installer": "^1.1",
"rector\/phpstan-rules": "^0.4.7",
"rector\/phpstan-rules": "^0.4.24",
"phpstan\/phpstan-webmozart-assert": "^1.0",
"phpstan\/phpstan-strict-rules": "^1.1",
"symplify\/vendor-patches": "^10.0"
"symplify\/vendor-patches": "^10.2"
},
"autoload": {
"psr-4": {

View File

@ -54,7 +54,7 @@ final class NeonNodeTraverser
$neonRector->enterNode($node);
}
// traverse all children
foreach ($node->getSubNodes() as $subnode) {
foreach ($node->getIterator() as $subnode) {
$this->traverse($subnode);
}
}

View File

@ -60,15 +60,16 @@ final class Service_ extends \Rector\Nette\NeonParser\Node\AbstractVirtualNode
/**
* @return Node[]
*/
public function getSubNodes() : array
public function &getIterator() : \Generator
{
$subNodes = [];
if ($this->classLiteralNode instanceof \RectorPrefix20220420\Nette\Neon\Node\LiteralNode) {
$subNodes[] = $this->classLiteralNode;
(yield $this->classLiteralNode);
}
if ($this->factoryLiteralNode instanceof \RectorPrefix20220420\Nette\Neon\Node\LiteralNode) {
$subNodes[] = $this->factoryLiteralNode;
(yield $this->factoryLiteralNode);
}
foreach ($this->setupMethodCalls as $setupMethodCall) {
(yield $setupMethodCall);
}
return \array_merge($subNodes, $this->setupMethodCalls);
}
}

View File

@ -4,12 +4,9 @@ declare (strict_types=1);
namespace RectorPrefix20220420;
use Rector\Config\RectorConfig;
use Rector\Core\Configuration\Option;
use Rector\Core\NonPhpFile\Rector\RenameClassNonPhpRector;
use RectorPrefix20220420\Symplify\SmartFileSystem\SmartFileSystem;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$parameters = $rectorConfig->parameters();
$parameters->set(\Rector\Core\Configuration\Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER, null);
$services = $rectorConfig->services();
$services->defaults()->public()->autowire()->autoconfigure();
$services->load('Rector\\Symfony\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/{Rector,ValueObject}']);

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace Rector\Symfony\DataProvider;
use Rector\Core\Configuration\Option;
use Rector\Symfony\ValueObject\ServiceMap\ServiceMap;
use Rector\Symfony\ValueObjectFactory\ServiceMapFactory;
use RectorPrefix20220420\Symplify\PackageBuilder\Parameter\ParameterProvider;
@ -11,10 +12,6 @@ use RectorPrefix20220420\Symplify\PackageBuilder\Parameter\ParameterProvider;
*/
final class ServiceMapProvider
{
/**
* @var string
*/
private const SYMFONY_CONTAINER_XML_PATH_PARAMETER = 'symfony_container_xml_path';
/**
* @readonly
* @var \Symplify\PackageBuilder\Parameter\ParameterProvider
@ -32,7 +29,7 @@ final class ServiceMapProvider
}
public function provide() : \Rector\Symfony\ValueObject\ServiceMap\ServiceMap
{
$symfonyContainerXmlPath = (string) $this->parameterProvider->provideParameter(self::SYMFONY_CONTAINER_XML_PATH_PARAMETER);
$symfonyContainerXmlPath = (string) $this->parameterProvider->provideParameter(\Rector\Core\Configuration\Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER);
if ($symfonyContainerXmlPath === '') {
return $this->serviceMapFactory->createEmpty();
}

View File

@ -22,7 +22,7 @@ final class StringFormTypeToClassRector extends \Rector\Core\Rector\AbstractRect
/**
* @var string
*/
private const DESCRIPTION = 'Turns string Form Type references to their CONSTANT alternatives in FormTypes in Form in Symfony. To enable custom types, add link to your container XML dump in "$parameters->set(Option::SYMFONY_CONTAINER_XML_PATH_PARAMETER, ...);"';
private const DESCRIPTION = 'Turns string Form Type references to their CONSTANT alternatives in FormTypes in Form in Symfony. To enable custom types, add link to your container XML dump in "$rectorConfig->symfonyContainerXml(...)"';
/**
* @readonly
* @var \Rector\Symfony\NodeAnalyzer\FormAddMethodCallAnalyzer

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220420\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitb6b917d28b8573d48cfb6e801e2a4cc9', false) && !interface_exists('ComposerAutoloaderInitb6b917d28b8573d48cfb6e801e2a4cc9', false) && !trait_exists('ComposerAutoloaderInitb6b917d28b8573d48cfb6e801e2a4cc9', false)) {
spl_autoload_call('RectorPrefix20220420\ComposerAutoloaderInitb6b917d28b8573d48cfb6e801e2a4cc9');
if (!class_exists('ComposerAutoloaderInitb4d900ca0960e14cd017d258ffc26626', false) && !interface_exists('ComposerAutoloaderInitb4d900ca0960e14cd017d258ffc26626', false) && !trait_exists('ComposerAutoloaderInitb4d900ca0960e14cd017d258ffc26626', false)) {
spl_autoload_call('RectorPrefix20220420\ComposerAutoloaderInitb4d900ca0960e14cd017d258ffc26626');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20220420\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220420\print_node(...func_get_args());
}
}
if (!function_exists('composerRequireb6b917d28b8573d48cfb6e801e2a4cc9')) {
function composerRequireb6b917d28b8573d48cfb6e801e2a4cc9() {
return \RectorPrefix20220420\composerRequireb6b917d28b8573d48cfb6e801e2a4cc9(...func_get_args());
if (!function_exists('composerRequireb4d900ca0960e14cd017d258ffc26626')) {
function composerRequireb4d900ca0960e14cd017d258ffc26626() {
return \RectorPrefix20220420\composerRequireb4d900ca0960e14cd017d258ffc26626(...func_get_args());
}
}
if (!function_exists('scanPath')) {