mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit e06a3c5213b9faf2992e9df5aa8490607de8c6b6
e06a3c5213
[Visibility] Remove ChangePropertyVisibilityRector, not used and rather refactoring scope (#366)
This commit is contained in:
parent
3d37eb7f17
commit
82f821474a
@ -1,89 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Visibility\Rector\Property;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\Visibility;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\Visibility\Rector\Property\ChangePropertyVisibilityRector\ChangePropertyVisibilityRectorTest
|
||||
*/
|
||||
final class ChangePropertyVisibilityRector extends \Rector\Core\Rector\AbstractRector implements \Rector\Core\Contract\Rector\ConfigurableRectorInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PROPERTY_TO_VISIBILITY_BY_CLASS = 'property_to_visibility_by_class';
|
||||
/**
|
||||
* @var array<string, array<string, int>>
|
||||
*/
|
||||
private $propertyToVisibilityByClass = [];
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Change visibility of property from parent class.', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample(<<<'CODE_SAMPLE'
|
||||
class FrameworkClass
|
||||
{
|
||||
protected $someProperty;
|
||||
}
|
||||
|
||||
class MyClass extends FrameworkClass
|
||||
{
|
||||
public $someProperty;
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
class FrameworkClass
|
||||
{
|
||||
protected $someProperty;
|
||||
}
|
||||
|
||||
class MyClass extends FrameworkClass
|
||||
{
|
||||
protected $someProperty;
|
||||
}
|
||||
CODE_SAMPLE
|
||||
, [self::PROPERTY_TO_VISIBILITY_BY_CLASS => ['FrameworkClass' => ['someProperty' => \Rector\Core\ValueObject\Visibility::PROTECTED]]])]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [\PhpParser\Node\Stmt\Property::class];
|
||||
}
|
||||
/**
|
||||
* @param Property $node
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
$classLike = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NODE);
|
||||
if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) {
|
||||
return null;
|
||||
}
|
||||
foreach ($this->propertyToVisibilityByClass as $type => $propertyToVisibility) {
|
||||
if (!$this->isObjectType($classLike, new \PHPStan\Type\ObjectType($type))) {
|
||||
continue;
|
||||
}
|
||||
foreach ($propertyToVisibility as $property => $visibility) {
|
||||
if (!$this->isName($node, $property)) {
|
||||
continue;
|
||||
}
|
||||
$this->visibilityManipulator->changeNodeVisibility($node, $visibility);
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$this->propertyToVisibilityByClass = $configuration[self::PROPERTY_TO_VISIBILITY_BY_CLASS] ?? [];
|
||||
}
|
||||
}
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'ba2888f66784a9898ccd53feae4facadc6302f13';
|
||||
public const PACKAGE_VERSION = 'e06a3c5213b9faf2992e9df5aa8490607de8c6b6';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-07-02 23:15:46';
|
||||
public const RELEASE_DATE = '2021-07-02 23:31:50';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20210702\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit3fdfa6bca686bb37b70e1d60bcfc21a8::getLoader();
|
||||
return ComposerAutoloaderInit972662b421f57f3ae62f5a2e27c071e3::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -3196,7 +3196,6 @@ return array(
|
||||
'Rector\\VendorLocker\\VendorLockResolver' => $baseDir . '/packages/VendorLocker/VendorLockResolver.php',
|
||||
'Rector\\Visibility\\Rector\\ClassConst\\ChangeConstantVisibilityRector' => $baseDir . '/rules/Visibility/Rector/ClassConst/ChangeConstantVisibilityRector.php',
|
||||
'Rector\\Visibility\\Rector\\ClassMethod\\ChangeMethodVisibilityRector' => $baseDir . '/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php',
|
||||
'Rector\\Visibility\\Rector\\Property\\ChangePropertyVisibilityRector' => $baseDir . '/rules/Visibility/Rector/Property/ChangePropertyVisibilityRector.php',
|
||||
'Rector\\Visibility\\ValueObject\\ChangeConstantVisibility' => $baseDir . '/rules/Visibility/ValueObject/ChangeConstantVisibility.php',
|
||||
'Rector\\Visibility\\ValueObject\\ChangeMethodVisibility' => $baseDir . '/rules/Visibility/ValueObject/ChangeMethodVisibility.php',
|
||||
'ReturnTypeWillChange' => $vendorDir . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php',
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit3fdfa6bca686bb37b70e1d60bcfc21a8
|
||||
class ComposerAutoloaderInit972662b421f57f3ae62f5a2e27c071e3
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInit3fdfa6bca686bb37b70e1d60bcfc21a8
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit3fdfa6bca686bb37b70e1d60bcfc21a8', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit972662b421f57f3ae62f5a2e27c071e3', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit3fdfa6bca686bb37b70e1d60bcfc21a8', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit972662b421f57f3ae62f5a2e27c071e3', '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\ComposerStaticInit3fdfa6bca686bb37b70e1d60bcfc21a8::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit972662b421f57f3ae62f5a2e27c071e3::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,19 +42,19 @@ class ComposerAutoloaderInit3fdfa6bca686bb37b70e1d60bcfc21a8
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit3fdfa6bca686bb37b70e1d60bcfc21a8::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit972662b421f57f3ae62f5a2e27c071e3::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire3fdfa6bca686bb37b70e1d60bcfc21a8($fileIdentifier, $file);
|
||||
composerRequire972662b421f57f3ae62f5a2e27c071e3($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire3fdfa6bca686bb37b70e1d60bcfc21a8($fileIdentifier, $file)
|
||||
function composerRequire972662b421f57f3ae62f5a2e27c071e3($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit3fdfa6bca686bb37b70e1d60bcfc21a8
|
||||
class ComposerStaticInit972662b421f57f3ae62f5a2e27c071e3
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
@ -3551,7 +3551,6 @@ class ComposerStaticInit3fdfa6bca686bb37b70e1d60bcfc21a8
|
||||
'Rector\\VendorLocker\\VendorLockResolver' => __DIR__ . '/../..' . '/packages/VendorLocker/VendorLockResolver.php',
|
||||
'Rector\\Visibility\\Rector\\ClassConst\\ChangeConstantVisibilityRector' => __DIR__ . '/../..' . '/rules/Visibility/Rector/ClassConst/ChangeConstantVisibilityRector.php',
|
||||
'Rector\\Visibility\\Rector\\ClassMethod\\ChangeMethodVisibilityRector' => __DIR__ . '/../..' . '/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php',
|
||||
'Rector\\Visibility\\Rector\\Property\\ChangePropertyVisibilityRector' => __DIR__ . '/../..' . '/rules/Visibility/Rector/Property/ChangePropertyVisibilityRector.php',
|
||||
'Rector\\Visibility\\ValueObject\\ChangeConstantVisibility' => __DIR__ . '/../..' . '/rules/Visibility/ValueObject/ChangeConstantVisibility.php',
|
||||
'Rector\\Visibility\\ValueObject\\ChangeMethodVisibility' => __DIR__ . '/../..' . '/rules/Visibility/ValueObject/ChangeMethodVisibility.php',
|
||||
'ReturnTypeWillChange' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/ReturnTypeWillChange.php',
|
||||
@ -3846,9 +3845,9 @@ class ComposerStaticInit3fdfa6bca686bb37b70e1d60bcfc21a8
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit3fdfa6bca686bb37b70e1d60bcfc21a8::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit3fdfa6bca686bb37b70e1d60bcfc21a8::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit3fdfa6bca686bb37b70e1d60bcfc21a8::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit972662b421f57f3ae62f5a2e27c071e3::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit972662b421f57f3ae62f5a2e27c071e3::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit972662b421f57f3ae62f5a2e27c071e3::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -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('RectorPrefix20210702\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit3fdfa6bca686bb37b70e1d60bcfc21a8', false) && !interface_exists('ComposerAutoloaderInit3fdfa6bca686bb37b70e1d60bcfc21a8', false) && !trait_exists('ComposerAutoloaderInit3fdfa6bca686bb37b70e1d60bcfc21a8', false)) {
|
||||
spl_autoload_call('RectorPrefix20210702\ComposerAutoloaderInit3fdfa6bca686bb37b70e1d60bcfc21a8');
|
||||
if (!class_exists('ComposerAutoloaderInit972662b421f57f3ae62f5a2e27c071e3', false) && !interface_exists('ComposerAutoloaderInit972662b421f57f3ae62f5a2e27c071e3', false) && !trait_exists('ComposerAutoloaderInit972662b421f57f3ae62f5a2e27c071e3', false)) {
|
||||
spl_autoload_call('RectorPrefix20210702\ComposerAutoloaderInit972662b421f57f3ae62f5a2e27c071e3');
|
||||
}
|
||||
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
|
||||
spl_autoload_call('RectorPrefix20210702\Doctrine\Inflector\Inflector');
|
||||
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20210702\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire3fdfa6bca686bb37b70e1d60bcfc21a8')) {
|
||||
function composerRequire3fdfa6bca686bb37b70e1d60bcfc21a8() {
|
||||
return \RectorPrefix20210702\composerRequire3fdfa6bca686bb37b70e1d60bcfc21a8(...func_get_args());
|
||||
if (!function_exists('composerRequire972662b421f57f3ae62f5a2e27c071e3')) {
|
||||
function composerRequire972662b421f57f3ae62f5a2e27c071e3() {
|
||||
return \RectorPrefix20210702\composerRequire972662b421f57f3ae62f5a2e27c071e3(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('parseArgs')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user