mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit e42466004ebbbbcfdeff4b7afebdfa8c8b092348
e42466004e
[types] Skip test case in ArrayShapeFromConstantArrayReturnRector (#2568)
This commit is contained in:
parent
fce82edc61
commit
13fb2e3eb1
@ -7,7 +7,9 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Type\Constant\ConstantArrayType;
|
||||
use PHPStan\Type\Constant\ConstantStringType;
|
||||
use PHPStan\Type\NeverType;
|
||||
@ -83,6 +85,9 @@ CODE_SAMPLE
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
if ($this->isInTestCase($node)) {
|
||||
return null;
|
||||
}
|
||||
/** @var Return_[] $returns */
|
||||
$returns = $this->betterNodeFinder->findInstancesOfInFunctionLikeScoped($node, Return_::class);
|
||||
// exact one shape only
|
||||
@ -144,4 +149,20 @@ CODE_SAMPLE
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
/**
|
||||
* Skip test case, as return methods there are usually with test data only.
|
||||
* Those arrays are hand made and return types are getting complex and messy, so this rule should skip it.
|
||||
*/
|
||||
private function isInTestCase(ClassMethod $classMethod) : bool
|
||||
{
|
||||
$scope = $classMethod->getAttribute(AttributeKey::SCOPE);
|
||||
if (!$scope instanceof Scope) {
|
||||
return \false;
|
||||
}
|
||||
$classReflection = $scope->getClassReflection();
|
||||
if (!$classReflection instanceof ClassReflection) {
|
||||
return \false;
|
||||
}
|
||||
return $classReflection->isSubclassOf('PHPUnit\\Framework\\TestCase');
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'f517e29acd09ac6e050c3b9a1ae3a5fe85173f79';
|
||||
public const PACKAGE_VERSION = 'e42466004ebbbbcfdeff4b7afebdfa8c8b092348';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-06-25 21:32:36';
|
||||
public const RELEASE_DATE = '2022-06-25 21:58:25';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInite2afb141509a84b146c1cf0d1a8be9a3::getLoader();
|
||||
return ComposerAutoloaderInit9bd05731d04b20ce3df7ea2849039092::getLoader();
|
||||
|
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 ComposerAutoloaderInite2afb141509a84b146c1cf0d1a8be9a3
|
||||
class ComposerAutoloaderInit9bd05731d04b20ce3df7ea2849039092
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,19 +22,19 @@ class ComposerAutoloaderInite2afb141509a84b146c1cf0d1a8be9a3
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInite2afb141509a84b146c1cf0d1a8be9a3', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit9bd05731d04b20ce3df7ea2849039092', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInite2afb141509a84b146c1cf0d1a8be9a3', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit9bd05731d04b20ce3df7ea2849039092', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInite2afb141509a84b146c1cf0d1a8be9a3::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit9bd05731d04b20ce3df7ea2849039092::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInite2afb141509a84b146c1cf0d1a8be9a3::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit9bd05731d04b20ce3df7ea2849039092::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequiree2afb141509a84b146c1cf0d1a8be9a3($fileIdentifier, $file);
|
||||
composerRequire9bd05731d04b20ce3df7ea2849039092($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
@ -46,7 +46,7 @@ class ComposerAutoloaderInite2afb141509a84b146c1cf0d1a8be9a3
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequiree2afb141509a84b146c1cf0d1a8be9a3($fileIdentifier, $file)
|
||||
function composerRequire9bd05731d04b20ce3df7ea2849039092($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInite2afb141509a84b146c1cf0d1a8be9a3
|
||||
class ComposerStaticInit9bd05731d04b20ce3df7ea2849039092
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
@ -3403,9 +3403,9 @@ class ComposerStaticInite2afb141509a84b146c1cf0d1a8be9a3
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInite2afb141509a84b146c1cf0d1a8be9a3::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInite2afb141509a84b146c1cf0d1a8be9a3::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInite2afb141509a84b146c1cf0d1a8be9a3::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit9bd05731d04b20ce3df7ea2849039092::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit9bd05731d04b20ce3df7ea2849039092::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit9bd05731d04b20ce3df7ea2849039092::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user