Skip to content

Commit

Permalink
Updated Rector to commit 5a0947d
Browse files Browse the repository at this point in the history
rectorphp/rector-src@5a0947d [Renaming] Handle rename template tag of class on RenameClassRector (#1318)
  • Loading branch information
TomasVotruba committed Nov 26, 2021
1 parent b2791fe commit b86475b
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 32 deletions.
3 changes: 2 additions & 1 deletion packages/BetterPhpDocParser/ValueObject/NodeTypes.php
Expand Up @@ -7,14 +7,15 @@
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
final class NodeTypes
{
/**
* @var array<class-string<PhpDocTagValueNode>>
*/
public const TYPE_AWARE_NODES = [\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class];
public const TYPE_AWARE_NODES = [\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode::class];
/**
* @var string[]
*/
Expand Down
4 changes: 2 additions & 2 deletions rules/Php80/NodeAnalyzer/PhpAttributeAnalyzer.php
Expand Up @@ -52,8 +52,8 @@ public function hasInheritedPhpAttribute(\PhpParser\Node\Stmt\ClassLike $classLi
if (!$this->reflectionProvider->hasClass($className)) {
return \false;
}
$reflectionClass = $this->reflectionProvider->getClass($className);
$ancestorClassReflections = $reflectionClass->getAncestors();
$classReflection = $this->reflectionProvider->getClass($className);
$ancestorClassReflections = $classReflection->getAncestors();
foreach ($ancestorClassReflections as $ancestorClassReflection) {
$ancestorClassName = $ancestorClassReflection->getName();
if ($ancestorClassName === $className) {
Expand Down
@@ -1,12 +1,14 @@
<?php

declare (strict_types=1);
namespace Rector\Transform\Rector\Class_;

use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PHPStan\Reflection\ReflectionProvider;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\ValueObject\MethodName;
use Rector\Core\ValueObject\PhpVersionFeature;
use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer;
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
Expand Down Expand Up @@ -63,6 +65,9 @@ class SomeObject {
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Stmt\Class_::class];
Expand All @@ -72,7 +77,7 @@ public function getNodeTypes() : array
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
if ($this->isDescendantOfStdclass($node) || $this->hasNeededAttributeAlready($node) || $this->hasMagicSetMethod($node)) {
if ($this->shouldSkip($node)) {
return null;
}
return $this->addAllowDynamicPropertiesAttribute($node);
Expand All @@ -81,13 +86,13 @@ public function provideMinPhpVersion() : int
{
return \Rector\Core\ValueObject\PhpVersionFeature::DEPRECATE_DYNAMIC_PROPERTIES;
}
private function isDescendantOfStdclass(\PhpParser\Node\Stmt\Class_ $node) : bool
private function isDescendantOfStdclass(\PhpParser\Node\Stmt\Class_ $class) : bool
{
if (!$node->extends instanceof \PhpParser\Node\Name\FullyQualified) {
if (!$class->extends instanceof \PhpParser\Node\Name\FullyQualified) {
return \false;
}
$ancestorClassNames = $this->familyRelationsAnalyzer->getClassLikeAncestorNames($node);
return \in_array('stdClass', $ancestorClassNames);
$ancestorClassNames = $this->familyRelationsAnalyzer->getClassLikeAncestorNames($class);
return \in_array('stdClass', $ancestorClassNames, \true);
}
private function hasNeededAttributeAlready(\PhpParser\Node\Stmt\Class_ $class) : bool
{
Expand All @@ -100,15 +105,26 @@ private function hasNeededAttributeAlready(\PhpParser\Node\Stmt\Class_ $class) :
}
return $this->phpAttributeAnalyzer->hasInheritedPhpAttribute($class, self::ATTRIBUTE);
}
private function hasMagicSetMethod(\PhpParser\Node\Stmt\Class_ $class) : bool
{
$classReflection = $this->reflectionProvider->getClass($class->namespacedName);
return $classReflection->hasMethod('__set');
}
private function addAllowDynamicPropertiesAttribute(\PhpParser\Node\Stmt\Class_ $class) : \PhpParser\Node\Stmt\Class_
{
$attributeGroup = $this->phpAttributeGroupFactory->createFromClass(self::ATTRIBUTE);
$class->attrGroups[] = $attributeGroup;
return $class;
}
private function shouldSkip(\PhpParser\Node\Stmt\Class_ $class) : bool
{
if ($this->isDescendantOfStdclass($class)) {
return \true;
}
if ($this->hasNeededAttributeAlready($class)) {
return \true;
}
return $this->hasMagicSetMethod($class);
}
private function hasMagicSetMethod(\PhpParser\Node\Stmt\Class_ $class) : bool
{
$className = (string) $this->getName($class);
$classReflection = $this->reflectionProvider->getClass($className);
return $classReflection->hasMethod(\Rector\Core\ValueObject\MethodName::__SET);
}
}
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Expand Up @@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '6aeef64c72b3c36a9c34473b0cb746264484b531';
public const PACKAGE_VERSION = '5a0947d9a29d9820246ee0b78efb678e624864f8';
/**
* @var string
*/
public const RELEASE_DATE = '2021-11-26 19:57:10';
public const RELEASE_DATE = '2021-11-26 20:01:30';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211126\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3::getLoader();
return ComposerAutoloaderInited9084c09a2030a1de96f051511e3dfb::getLoader();
14 changes: 7 additions & 7 deletions vendor/composer/autoload_real.php
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3
class ComposerAutoloaderInited9084c09a2030a1de96f051511e3dfb
{
private static $loader;

Expand All @@ -22,15 +22,15 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInited9084c09a2030a1de96f051511e3dfb', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInited9084c09a2030a1de96f051511e3dfb', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInited9084c09a2030a1de96f051511e3dfb::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
Expand All @@ -42,19 +42,19 @@ public static function getLoader()
$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3::$files;
$includeFiles = Composer\Autoload\ComposerStaticInited9084c09a2030a1de96f051511e3dfb::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiref8293da5b79cfa5fdf8db617d80e5ac3($fileIdentifier, $file);
composerRequireed9084c09a2030a1de96f051511e3dfb($fileIdentifier, $file);
}

return $loader;
}
}

function composerRequiref8293da5b79cfa5fdf8db617d80e5ac3($fileIdentifier, $file)
function composerRequireed9084c09a2030a1de96f051511e3dfb($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3
class ComposerStaticInited9084c09a2030a1de96f051511e3dfb
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
Expand Down Expand Up @@ -3768,9 +3768,9 @@ class ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInited9084c09a2030a1de96f051511e3dfb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInited9084c09a2030a1de96f051511e3dfb::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInited9084c09a2030a1de96f051511e3dfb::$classMap;

}, null, ClassLoader::class);
}
Expand Down
10 changes: 5 additions & 5 deletions vendor/scoper-autoload.php
Expand Up @@ -12,8 +12,8 @@
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211126\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3', false) && !interface_exists('ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3', false) && !trait_exists('ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3', false)) {
spl_autoload_call('RectorPrefix20211126\ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3');
if (!class_exists('ComposerAutoloaderInited9084c09a2030a1de96f051511e3dfb', false) && !interface_exists('ComposerAutoloaderInited9084c09a2030a1de96f051511e3dfb', false) && !trait_exists('ComposerAutoloaderInited9084c09a2030a1de96f051511e3dfb', false)) {
spl_autoload_call('RectorPrefix20211126\ComposerAutoloaderInited9084c09a2030a1de96f051511e3dfb');
}
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('RectorPrefix20211126\Helmich\TypoScriptParser\Parser\AST\Statement');
Expand Down Expand Up @@ -81,9 +81,9 @@ function print_node() {
return \RectorPrefix20211126\print_node(...func_get_args());
}
}
if (!function_exists('composerRequiref8293da5b79cfa5fdf8db617d80e5ac3')) {
function composerRequiref8293da5b79cfa5fdf8db617d80e5ac3() {
return \RectorPrefix20211126\composerRequiref8293da5b79cfa5fdf8db617d80e5ac3(...func_get_args());
if (!function_exists('composerRequireed9084c09a2030a1de96f051511e3dfb')) {
function composerRequireed9084c09a2030a1de96f051511e3dfb() {
return \RectorPrefix20211126\composerRequireed9084c09a2030a1de96f051511e3dfb(...func_get_args());
}
}
if (!function_exists('scanPath')) {
Expand Down

0 comments on commit b86475b

Please sign in to comment.