mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 13:28:18 +01:00
Updated Rector to commit 265d627ddf7663fe65bfda2aa4cf32fc4a3ba95d
265d627ddf
Remove IsObjectOnIncompleteClassRector as blindly turns all incomplete checks to negated, better examine manually (#3969)
This commit is contained in:
parent
2a68777a50
commit
eae5c53485
@ -8,7 +8,6 @@ use Rector\Php72\Rector\Assign\ListEachRector;
|
||||
use Rector\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector;
|
||||
use Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector;
|
||||
use Rector\Php72\Rector\FuncCall\GetClassOnNullRector;
|
||||
use Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector;
|
||||
use Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector;
|
||||
use Rector\Php72\Rector\FuncCall\StringifyDefineRector;
|
||||
use Rector\Php72\Rector\FuncCall\StringsAssertNakedRector;
|
||||
@ -16,10 +15,6 @@ use Rector\Php72\Rector\Unset_\UnsetCastRector;
|
||||
use Rector\Php72\Rector\While_\WhileEachToForeachRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->rule(WhileEachToForeachRector::class);
|
||||
$rectorConfig->rule(ListEachRector::class);
|
||||
$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class);
|
||||
$rectorConfig->rule(UnsetCastRector::class);
|
||||
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [
|
||||
# and imagewbmp
|
||||
'jpeg2wbmp' => 'imagecreatefromjpeg',
|
||||
@ -31,10 +26,5 @@ return static function (RectorConfig $rectorConfig) : void {
|
||||
'gmp_random' => 'gmp_random_bits',
|
||||
'read_exif_data' => 'exif_read_data',
|
||||
]);
|
||||
$rectorConfig->rule(GetClassOnNullRector::class);
|
||||
$rectorConfig->rule(IsObjectOnIncompleteClassRector::class);
|
||||
$rectorConfig->rule(ParseStrWithResultArgumentRector::class);
|
||||
$rectorConfig->rule(StringsAssertNakedRector::class);
|
||||
$rectorConfig->rule(CreateFunctionToAnonymousFunctionRector::class);
|
||||
$rectorConfig->rule(StringifyDefineRector::class);
|
||||
$rectorConfig->rules([GetClassOnNullRector::class, ParseStrWithResultArgumentRector::class, StringsAssertNakedRector::class, CreateFunctionToAnonymousFunctionRector::class, StringifyDefineRector::class, WhileEachToForeachRector::class, ListEachRector::class, ReplaceEachAssignmentWithKeyCurrentRector::class, UnsetCastRector::class]);
|
||||
};
|
||||
|
@ -12,10 +12,8 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
|
||||
use Rector\BetterPhpDocParser\Comment\CommentsMerger;
|
||||
use Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\NodeTransformer;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix202305\Webmozart\Assert\Assert;
|
||||
@ -132,11 +130,6 @@ CODE_SAMPLE
|
||||
private function transformArrayToYieldsOnMethodNode(ClassMethod $classMethod, Array_ $array) : void
|
||||
{
|
||||
$yieldNodes = $this->nodeTransformer->transformArrayToYields($array);
|
||||
// remove whole return node
|
||||
$parentNode = $array->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if (!$parentNode instanceof Node) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
$this->removeReturnTag($classMethod);
|
||||
// change return typehint
|
||||
$classMethod->returnType = new FullyQualified('Iterator');
|
||||
|
@ -11,7 +11,6 @@ use PhpParser\Node\Stmt\ClassConst;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Do_;
|
||||
use PhpParser\Node\Stmt\ElseIf_;
|
||||
use PhpParser\Node\Stmt\For_;
|
||||
use PhpParser\Node\Stmt\Foreach_;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
|
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Php72\Rector\FuncCall;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\BooleanNot;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @changelog http://php.net/manual/en/migration72.incompatible.php#migration72.incompatible.is_object-on-incomplete_class https://3v4l.org/SpiE6
|
||||
*
|
||||
* @see \Rector\Tests\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector\IsObjectOnIncompleteClassRectorTest
|
||||
*/
|
||||
final class IsObjectOnIncompleteClassRector extends AbstractRector implements MinPhpVersionInterface
|
||||
{
|
||||
public function provideMinPhpVersion() : int
|
||||
{
|
||||
return PhpVersionFeature::INVERTED_BOOL_IS_OBJECT_INCOMPLETE_CLASS;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
return new RuleDefinition('Incomplete class returns inverted bool on is_object()', [new CodeSample(<<<'CODE_SAMPLE'
|
||||
$incompleteObject = new __PHP_Incomplete_Class;
|
||||
$isObject = is_object($incompleteObject);
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
$incompleteObject = new __PHP_Incomplete_Class;
|
||||
$isObject = ! is_object($incompleteObject);
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [FuncCall::class];
|
||||
}
|
||||
/**
|
||||
* @param FuncCall $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if (!$this->isName($node, 'is_object')) {
|
||||
return null;
|
||||
}
|
||||
$incompleteClassObjectType = new ObjectType('__PHP_Incomplete_Class');
|
||||
if (!isset($node->getArgs()[0])) {
|
||||
return null;
|
||||
}
|
||||
if ($this->shouldSkip($node)) {
|
||||
return null;
|
||||
}
|
||||
$firstArg = $node->getArgs()[0];
|
||||
if (!$this->isObjectType($firstArg->value, $incompleteClassObjectType)) {
|
||||
return null;
|
||||
}
|
||||
return new BooleanNot($node);
|
||||
}
|
||||
private function shouldSkip(FuncCall $funcCall) : bool
|
||||
{
|
||||
$parentNode = $funcCall->getAttribute(AttributeKey::PARENT_NODE);
|
||||
return $parentNode instanceof BooleanNot;
|
||||
}
|
||||
}
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'd99713c7d55f25612440948b8a85b5b99e0b0e11';
|
||||
public const PACKAGE_VERSION = '265d627ddf7663fe65bfda2aa4cf32fc4a3ba95d';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-05-25 15:35:39';
|
||||
public const RELEASE_DATE = '2023-05-25 16:30:45';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit1f089665787b0dbf2a8505138aab450d::getLoader();
|
||||
return ComposerAutoloaderInitcac939f8e7bc0f49a57b3d0f2b1e892c::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -2207,7 +2207,6 @@ return array(
|
||||
'Rector\\Php72\\Rector\\Assign\\ReplaceEachAssignmentWithKeyCurrentRector' => $baseDir . '/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\CreateFunctionToAnonymousFunctionRector' => $baseDir . '/rules/Php72/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\GetClassOnNullRector' => $baseDir . '/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\IsObjectOnIncompleteClassRector' => $baseDir . '/rules/Php72/Rector/FuncCall/IsObjectOnIncompleteClassRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\ParseStrWithResultArgumentRector' => $baseDir . '/rules/Php72/Rector/FuncCall/ParseStrWithResultArgumentRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\StringifyDefineRector' => $baseDir . '/rules/Php72/Rector/FuncCall/StringifyDefineRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\StringsAssertNakedRector' => $baseDir . '/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php',
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit1f089665787b0dbf2a8505138aab450d
|
||||
class ComposerAutoloaderInitcac939f8e7bc0f49a57b3d0f2b1e892c
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit1f089665787b0dbf2a8505138aab450d
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1f089665787b0dbf2a8505138aab450d', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitcac939f8e7bc0f49a57b3d0f2b1e892c', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1f089665787b0dbf2a8505138aab450d', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitcac939f8e7bc0f49a57b3d0f2b1e892c', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1f089665787b0dbf2a8505138aab450d::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitcac939f8e7bc0f49a57b3d0f2b1e892c::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit1f089665787b0dbf2a8505138aab450d::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitcac939f8e7bc0f49a57b3d0f2b1e892c::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit1f089665787b0dbf2a8505138aab450d
|
||||
class ComposerStaticInitcac939f8e7bc0f49a57b3d0f2b1e892c
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2449,7 +2449,6 @@ class ComposerStaticInit1f089665787b0dbf2a8505138aab450d
|
||||
'Rector\\Php72\\Rector\\Assign\\ReplaceEachAssignmentWithKeyCurrentRector' => __DIR__ . '/../..' . '/rules/Php72/Rector/Assign/ReplaceEachAssignmentWithKeyCurrentRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\CreateFunctionToAnonymousFunctionRector' => __DIR__ . '/../..' . '/rules/Php72/Rector/FuncCall/CreateFunctionToAnonymousFunctionRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\GetClassOnNullRector' => __DIR__ . '/../..' . '/rules/Php72/Rector/FuncCall/GetClassOnNullRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\IsObjectOnIncompleteClassRector' => __DIR__ . '/../..' . '/rules/Php72/Rector/FuncCall/IsObjectOnIncompleteClassRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\ParseStrWithResultArgumentRector' => __DIR__ . '/../..' . '/rules/Php72/Rector/FuncCall/ParseStrWithResultArgumentRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\StringifyDefineRector' => __DIR__ . '/../..' . '/rules/Php72/Rector/FuncCall/StringifyDefineRector.php',
|
||||
'Rector\\Php72\\Rector\\FuncCall\\StringsAssertNakedRector' => __DIR__ . '/../..' . '/rules/Php72/Rector/FuncCall/StringsAssertNakedRector.php',
|
||||
@ -3096,9 +3095,9 @@ class ComposerStaticInit1f089665787b0dbf2a8505138aab450d
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1f089665787b0dbf2a8505138aab450d::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1f089665787b0dbf2a8505138aab450d::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1f089665787b0dbf2a8505138aab450d::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitcac939f8e7bc0f49a57b3d0f2b1e892c::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitcac939f8e7bc0f49a57b3d0f2b1e892c::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitcac939f8e7bc0f49a57b3d0f2b1e892c::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user