mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-11 19:11:57 +02:00
Updated Rector to commit 7433ffeb07507632659635152b35af66320d1e07
7433ffeb07
[Printer] Reduce regex for end with \n detection on BetterStandardPrinter (#4957)
This commit is contained in:
parent
96a2988a43
commit
8a3c738dcd
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 ComposerAutoloaderInitb7a2a13fd9b0c6bc282aa539d784649d::getLoader();
|
||||
return ComposerAutoloaderInitfbe60bacb74a262cac6f1ce20f958bdb::getLoader();
|
||||
|
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 ComposerAutoloaderInitb7a2a13fd9b0c6bc282aa539d784649d
|
||||
class ComposerAutoloaderInitfbe60bacb74a262cac6f1ce20f958bdb
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInitb7a2a13fd9b0c6bc282aa539d784649d
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitb7a2a13fd9b0c6bc282aa539d784649d', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitfbe60bacb74a262cac6f1ce20f958bdb', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitb7a2a13fd9b0c6bc282aa539d784649d', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitfbe60bacb74a262cac6f1ce20f958bdb', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitb7a2a13fd9b0c6bc282aa539d784649d::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitfbe60bacb74a262cac6f1ce20f958bdb::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitb7a2a13fd9b0c6bc282aa539d784649d::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitfbe60bacb74a262cac6f1ce20f958bdb::$files;
|
||||
$requireFile = \Closure::bind(static function ($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 ComposerStaticInitb7a2a13fd9b0c6bc282aa539d784649d
|
||||
class ComposerStaticInitfbe60bacb74a262cac6f1ce20f958bdb
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2599,9 +2599,9 @@ class ComposerStaticInitb7a2a13fd9b0c6bc282aa539d784649d
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitb7a2a13fd9b0c6bc282aa539d784649d::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitb7a2a13fd9b0c6bc282aa539d784649d::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitb7a2a13fd9b0c6bc282aa539d784649d::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitfbe60bacb74a262cac6f1ce20f958bdb::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitfbe60bacb74a262cac6f1ce20f958bdb::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitfbe60bacb74a262cac6f1ce20f958bdb::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -1872,12 +1872,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
|
||||
"reference": "2800f5c374cffc20cbdfb221ce033b46a3a8003d"
|
||||
"reference": "fde1cef6981bd2b43bc97ac30a9edb922ab2a620"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/2800f5c374cffc20cbdfb221ce033b46a3a8003d",
|
||||
"reference": "2800f5c374cffc20cbdfb221ce033b46a3a8003d",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/fde1cef6981bd2b43bc97ac30a9edb922ab2a620",
|
||||
"reference": "fde1cef6981bd2b43bc97ac30a9edb922ab2a620",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1907,7 +1907,7 @@
|
||||
"tomasvotruba\/unused-public": "^0.3",
|
||||
"tracy\/tracy": "^2.10"
|
||||
},
|
||||
"time": "2023-09-10T01:16:20+00:00",
|
||||
"time": "2023-09-10T03:12:22+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
||||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main aecc9c7'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main fa41cc7'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 2800f5c'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main d4f8c9d'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main aecc9c7'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main fa41cc7'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main fde1cef'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main d4f8c9d'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
1
vendor/rector/rector-phpunit/rector.php
vendored
1
vendor/rector/rector-phpunit/rector.php
vendored
@ -10,6 +10,7 @@ use Rector\Set\ValueObject\LevelSetList;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
return static function (RectorConfig $rectorConfig) : void {
|
||||
$rectorConfig->importNames();
|
||||
$rectorConfig->removeUnusedImports();
|
||||
$rectorConfig->paths([__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/rules', __DIR__ . '/rules-tests']);
|
||||
$rectorConfig->skip([
|
||||
// for tests
|
||||
|
@ -5,9 +5,6 @@ namespace Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod;
|
||||
|
||||
use RectorPrefix202309\Nette\Utils\Json;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Attribute;
|
||||
use PhpParser\Node\AttributeGroup;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
|
@ -16,10 +16,8 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use RectorPrefix202309\PHPUnit\Framework\Attributes\Ticket;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTagRemover;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
|
||||
use Rector\PHPUnit\ValueObject\AnnotationWithValueToAttribute;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
|
@ -61,7 +61,7 @@ CODE_SAMPLE
|
||||
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'test*')) {
|
||||
if (!\fnmatch('test*', $node->name->toString(), \FNM_NOESCAPE)) {
|
||||
return null;
|
||||
}
|
||||
if ($node->stmts === null) {
|
||||
|
@ -71,7 +71,7 @@ CODE_SAMPLE
|
||||
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->isName($node->name, 'test*')) {
|
||||
if (\fnmatch('test*', $node->name->toString(), \FNM_NOESCAPE)) {
|
||||
return null;
|
||||
}
|
||||
$docComment = $node->getDocComment();
|
||||
|
@ -6,13 +6,17 @@ namespace Rector\PHPUnit\CodeQuality\Rector\Class_;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use Rector\Core\NodeAnalyzer\ClassAnalyzer;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPUnit\NodeAnalyzer\SetUpMethodDecorator;
|
||||
@ -47,12 +51,18 @@ final class ConstructClassMethodToSetUpTestCaseRector extends AbstractRector
|
||||
* @var \Rector\PHPUnit\NodeAnalyzer\SetUpMethodDecorator
|
||||
*/
|
||||
private $setUpMethodDecorator;
|
||||
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, ClassAnalyzer $classAnalyzer, VisibilityManipulator $visibilityManipulator, SetUpMethodDecorator $setUpMethodDecorator)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\Reflection\ReflectionResolver
|
||||
*/
|
||||
private $reflectionResolver;
|
||||
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer, ClassAnalyzer $classAnalyzer, VisibilityManipulator $visibilityManipulator, SetUpMethodDecorator $setUpMethodDecorator, ReflectionResolver $reflectionResolver)
|
||||
{
|
||||
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
|
||||
$this->classAnalyzer = $classAnalyzer;
|
||||
$this->visibilityManipulator = $visibilityManipulator;
|
||||
$this->setUpMethodDecorator = $setUpMethodDecorator;
|
||||
$this->reflectionResolver = $reflectionResolver;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
@ -109,6 +119,9 @@ CODE_SAMPLE
|
||||
if ($this->classAnalyzer->isAnonymousClass($node)) {
|
||||
return null;
|
||||
}
|
||||
if ($this->shouldSkip($node, $constructClassMethod)) {
|
||||
return null;
|
||||
}
|
||||
$addedStmts = $this->resolveStmtsToAddToSetUp($constructClassMethod);
|
||||
$setUpClassMethod = $node->getMethod(MethodName::SET_UP);
|
||||
if (!$setUpClassMethod instanceof ClassMethod) {
|
||||
@ -125,6 +138,36 @@ CODE_SAMPLE
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
private function shouldSkip(Class_ $class, ClassMethod $classMethod) : bool
|
||||
{
|
||||
$classReflection = $this->reflectionResolver->resolveClassReflection($class);
|
||||
if (!$classReflection instanceof ClassReflection) {
|
||||
return \true;
|
||||
}
|
||||
$currentParent = \current($classReflection->getParents());
|
||||
if (!$currentParent instanceof ClassReflection) {
|
||||
return \true;
|
||||
}
|
||||
if ($currentParent->getName() !== 'PHPUnit\\Framework\\TestCase') {
|
||||
return \true;
|
||||
}
|
||||
$paramNames = [];
|
||||
foreach ($classMethod->params as $param) {
|
||||
$paramNames[] = $this->getName($param);
|
||||
}
|
||||
$isFoundParamUsed = \false;
|
||||
$this->traverseNodesWithCallable((array) $classMethod->stmts, function (Node $subNode) use($paramNames, &$isFoundParamUsed) : ?int {
|
||||
if ($subNode instanceof StaticCall && $this->isName($subNode->name, MethodName::CONSTRUCT)) {
|
||||
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
|
||||
}
|
||||
if ($subNode instanceof Variable && $this->isNames($subNode, $paramNames)) {
|
||||
$isFoundParamUsed = \true;
|
||||
return NodeTraverser::STOP_TRAVERSAL;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
return $isFoundParamUsed;
|
||||
}
|
||||
/**
|
||||
* @return Stmt[]
|
||||
*/
|
||||
|
@ -85,7 +85,7 @@ CODE_SAMPLE
|
||||
if (!$this->isNames($node->class, ['static', 'self'])) {
|
||||
return null;
|
||||
}
|
||||
if (!$this->isName($node->name, 'assert*')) {
|
||||
if (!\fnmatch('assert*', $methodName, \FNM_NOESCAPE)) {
|
||||
return null;
|
||||
}
|
||||
$hasChanged = \true;
|
||||
|
@ -64,7 +64,7 @@ final class AssertTrueFalseToSpecificMethodRector extends AbstractRector
|
||||
if (!$firstArgumentValue instanceof FuncCall && !$firstArgumentValue instanceof Empty_) {
|
||||
return null;
|
||||
}
|
||||
$firstArgumentName = $this->getName($firstArgumentValue);
|
||||
$firstArgumentName = $this->resolveFirstArgument($firstArgumentValue);
|
||||
if ($firstArgumentName === null || !\array_key_exists($firstArgumentName, self::FUNCTION_NAME_WITH_ASSERT_METHOD_NAMES)) {
|
||||
return null;
|
||||
}
|
||||
@ -88,6 +88,13 @@ final class AssertTrueFalseToSpecificMethodRector extends AbstractRector
|
||||
$this->moveFunctionArgumentsUp($node);
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\Empty_ $firstArgumentValue
|
||||
*/
|
||||
private function resolveFirstArgument($firstArgumentValue) : ?string
|
||||
{
|
||||
return $firstArgumentValue instanceof Empty_ ? 'empty' : $this->getName($firstArgumentValue);
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node
|
||||
*/
|
||||
|
@ -8,7 +8,6 @@ use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\TraitUse;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use Rector\Core\NodeManipulator\ClassManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
|
||||
|
@ -6,7 +6,6 @@ namespace Rector\PHPUnit\PHPUnit60\Rector\MethodCall;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\TypeWithClassName;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -97,7 +97,7 @@ CODE_SAMPLE
|
||||
$hasChanged = \false;
|
||||
$dataProviderClassMethods = $this->dataProviderClassMethodFinder->find($node);
|
||||
foreach ($dataProviderClassMethods as $dataProviderClassMethod) {
|
||||
if (!$this->isName($dataProviderClassMethod, 'test*')) {
|
||||
if (!\fnmatch('test*', $dataProviderClassMethod->name->toString(), \FNM_NOESCAPE)) {
|
||||
continue;
|
||||
}
|
||||
$shortMethodName = Strings::substring($dataProviderClassMethod->name->toString(), 4);
|
||||
|
@ -6,6 +6,7 @@ namespace Rector\PHPUnit\NodeAnalyzer;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PHPStan\Type\TypeWithClassName;
|
||||
use Rector\Core\PhpParser\AstResolver;
|
||||
@ -156,16 +157,20 @@ final class AssertCallAnalyzer
|
||||
*/
|
||||
private function isAssertMethodName($call) : bool
|
||||
{
|
||||
return $this->nodeNameResolver->isNames($call->name, [
|
||||
// phpunit
|
||||
'*assert',
|
||||
'assert*',
|
||||
'expectException*',
|
||||
'setExpectedException*',
|
||||
'expectOutput*',
|
||||
'should*',
|
||||
'doTestFileInfo',
|
||||
'expectNotToPerformAssertions',
|
||||
]);
|
||||
if (!$call->name instanceof Identifier) {
|
||||
return \false;
|
||||
}
|
||||
$callname = $call->name->toString();
|
||||
foreach (['doTestFileInfo', 'expectNotToPerformAssertions'] as $methodCallName) {
|
||||
if ($callname === $methodCallName) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
foreach (['*assert', 'assert*', 'expectException*', 'setExpectedException*', 'expectOutput*', 'should*'] as $methodCallNamePattern) {
|
||||
if (\fnmatch($methodCallNamePattern, $callname, \FNM_NOESCAPE)) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ final class TestsNodeAnalyzer
|
||||
if (!$classMethod->isPublic()) {
|
||||
return \false;
|
||||
}
|
||||
if ($this->nodeNameResolver->isName($classMethod, 'test*')) {
|
||||
if (\fnmatch('test*', $classMethod->name->toString(), \FNM_NOESCAPE)) {
|
||||
return \true;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
|
||||
|
Loading…
x
Reference in New Issue
Block a user