Skip to content

Commit

Permalink
Updated Rector to commit 53e4e9f1e939da3cc6aa9d8c7172cd17e8550d8e
Browse files Browse the repository at this point in the history
rectorphp/rector-src@53e4e9f [CodingStyle] Reduce parent attribute usage on NameImporter (#4344)
  • Loading branch information
TomasVotruba committed Jun 25, 2023
1 parent 9d08d13 commit 46e1669
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 21 deletions.
8 changes: 8 additions & 0 deletions packages/NodeTypeResolver/Node/AttributeKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,12 @@ final class AttributeKey
* @var string
*/
public const IS_STATICCALL_CLASS_NAME = 'is_staticcall_class_name';
/**
* @var string
*/
public const IS_FUNCCALL_NAME = 'is_funccall_name';
/**
* @var string
*/
public const IS_CONSTFETCH_NAME = 'is_constfetch_name';
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor;

use PhpParser\Node;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\Namespace_;
Expand All @@ -24,6 +26,14 @@ public function enterNode(Node $node) : ?Node
$node->name->setAttribute(AttributeKey::IS_USEUSE_NAME, \true);
return null;
}
if ($node instanceof FuncCall && $node->name instanceof Name) {
$node->name->setAttribute(AttributeKey::IS_FUNCCALL_NAME, \true);
return null;
}
if ($node instanceof ConstFetch) {
$node->name->setAttribute(AttributeKey::IS_CONSTFETCH_NAME, \true);
return null;
}
if (!$node instanceof StaticCall) {
return null;
}
Expand Down
14 changes: 5 additions & 9 deletions rules/CodingStyle/Node/NameImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
namespace Rector\CodingStyle\Node;

use PhpParser\Node;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\GroupUse;
use PhpParser\Node\Stmt\Namespace_;
use PhpParser\Node\Stmt\Use_;
use PhpParser\Node\Stmt\UseUse;
use PHPStan\Reflection\ReflectionProvider;
Expand Down Expand Up @@ -141,10 +138,10 @@ private function importNameAndCollectNewUseStatement(File $file, Name $name, Ful
*/
private function isNamespaceOrUseImportName(Name $name) : bool
{
$parentNode = $name->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof Namespace_) {
if ($name->getAttribute(AttributeKey::IS_NAMESPACE_NAME) === \true) {
return \true;
}
$parentNode = $name->getAttribute(AttributeKey::PARENT_NODE);
return $parentNode instanceof UseUse;
}
private function isFunctionOrConstantImportWithSingleName(Name $name) : bool
Expand All @@ -155,10 +152,10 @@ private function isFunctionOrConstantImportWithSingleName(Name $name) : bool
if ($autoImportNames && !$parentNode instanceof Node && \strpos($fullName, '\\') === \false && $this->reflectionProvider->hasFunction(new Name($fullName), null)) {
return \true;
}
if ($parentNode instanceof ConstFetch) {
if ($name->getAttribute(AttributeKey::IS_CONSTFETCH_NAME) === \true) {
return \count($name->getParts()) === 1;
}
if ($parentNode instanceof FuncCall) {
if ($name->getAttribute(AttributeKey::IS_FUNCCALL_NAME) === \true) {
return \count($name->getParts()) === 1;
}
return \false;
Expand All @@ -168,8 +165,7 @@ private function addUseImport(File $file, Name $name, FullyQualifiedObjectType $
if ($this->useNodesToAddCollector->hasImport($file, $name, $fullyQualifiedObjectType)) {
return;
}
$parentNode = $name->getAttribute(AttributeKey::PARENT_NODE);
if ($parentNode instanceof FuncCall) {
if ($name->getAttribute(AttributeKey::IS_FUNCCALL_NAME) === \true) {
$this->useNodesToAddCollector->addFunctionUseImport($fullyQualifiedObjectType);
} else {
$this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType);
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'dfef34df2f634b87afe6940cc4671018fb81e26e';
public const PACKAGE_VERSION = '53e4e9f1e939da3cc6aa9d8c7172cd17e8550d8e';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-06-25 23:14:29';
public const RELEASE_DATE = '2023-06-25 23:18:08';
/**
* @var int
*/
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

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

return ComposerAutoloaderInita0eec1cc51d070e60c18f0bcf971a1a9::getLoader();
return ComposerAutoloaderInitcab863d7095ff613586a7c001c70204c::getLoader();
10 changes: 5 additions & 5 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInita0eec1cc51d070e60c18f0bcf971a1a9
class ComposerAutoloaderInitcab863d7095ff613586a7c001c70204c
{
private static $loader;

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

spl_autoload_register(array('ComposerAutoloaderInita0eec1cc51d070e60c18f0bcf971a1a9', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitcab863d7095ff613586a7c001c70204c', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInita0eec1cc51d070e60c18f0bcf971a1a9', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitcab863d7095ff613586a7c001c70204c', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInita0eec1cc51d070e60c18f0bcf971a1a9::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitcab863d7095ff613586a7c001c70204c::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInita0eec1cc51d070e60c18f0bcf971a1a9::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInitcab863d7095ff613586a7c001c70204c::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInita0eec1cc51d070e60c18f0bcf971a1a9
class ComposerStaticInitcab863d7095ff613586a7c001c70204c
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -3091,9 +3091,9 @@ class ComposerStaticInita0eec1cc51d070e60c18f0bcf971a1a9
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInita0eec1cc51d070e60c18f0bcf971a1a9::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInita0eec1cc51d070e60c18f0bcf971a1a9::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInita0eec1cc51d070e60c18f0bcf971a1a9::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitcab863d7095ff613586a7c001c70204c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitcab863d7095ff613586a7c001c70204c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitcab863d7095ff613586a7c001c70204c::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit 46e1669

Please sign in to comment.