Skip to content

Commit

Permalink
Updated Rector to commit fa8e3bd
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Aug 9, 2021
1 parent 49e9745 commit b2c929a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 40 deletions.
7 changes: 6 additions & 1 deletion packages/Testing/PHPUnit/Behavior/MovingFilesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,16 @@ protected function assertFilesWereAdded($expectedAddedFileWithContents) : void
private function resolveAddedFilePathsWithContents() : array
{
$addedFilePathsWithContents = $this->removedAndAddedFilesCollector->getAddedFilesWithContent();
$nodesWithFileDestinationPrinter = $this->getService(\Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter::class);
$movedFiles = $this->removedAndAddedFilesCollector->getMovedFiles();
foreach ($movedFiles as $movedFile) {
$fileContent = $nodesWithFileDestinationPrinter->printNodesWithFileDestination($movedFile);
$addedFilePathsWithContents[] = new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($movedFile->getNewFilePath(), $fileContent);
}
$addedFilesWithNodes = $this->removedAndAddedFilesCollector->getAddedFilesWithNodes();
if ($addedFilesWithNodes === []) {
return $addedFilePathsWithContents;
}
$nodesWithFileDestinationPrinter = $this->getService(\Rector\Core\PhpParser\Printer\NodesWithFileDestinationPrinter::class);
foreach ($addedFilesWithNodes as $addedFileWithNode) {
$fileContent = $nodesWithFileDestinationPrinter->printNodesWithFileDestination($addedFileWithNode);
$addedFilePathsWithContents[] = new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($addedFileWithNode->getFilePath(), $fileContent);
Expand Down
24 changes: 8 additions & 16 deletions rules/PhpSpecToPHPUnit/PHPUnitTypeDeclarationDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,33 @@
declare (strict_types=1);
namespace Rector\PhpSpecToPHPUnit;

use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\ClassMethod;
use Rector\Core\Reflection\ReflectionResolver;
use Rector\Core\PhpParser\AstResolver;
use Rector\Core\ValueObject\MethodName;
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
use ReflectionMethod;
use ReflectionNamedType;
/**
* Decorate setUp() and tearDown() with "void" when local TestClass class uses them
*/
final class PHPUnitTypeDeclarationDecorator
{
/**
* @var \Rector\Core\Reflection\ReflectionResolver
* @var \Rector\Core\PhpParser\AstResolver
*/
private $reflectionResolver;
public function __construct(\Rector\Core\Reflection\ReflectionResolver $reflectionResolver)
private $astResolver;
public function __construct(\Rector\Core\PhpParser\AstResolver $astResolver)
{
$this->reflectionResolver = $reflectionResolver;
$this->astResolver = $astResolver;
}
public function decorate(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void
{
// skip test run
if (\Rector\Testing\PHPUnit\StaticPHPUnitEnvironment::isPHPUnitRun()) {
return;
}
$reflectionMethod = $this->reflectionResolver->resolveNativeClassMethodReflection('PHPUnit\\Framework\\TestCase', \Rector\Core\ValueObject\MethodName::SET_UP);
if (!$reflectionMethod instanceof \ReflectionMethod) {
$setUpClassMethod = $this->astResolver->resolveClassMethod('PHPUnit\\Framework\\TestCase', \Rector\Core\ValueObject\MethodName::SET_UP);
if (!$setUpClassMethod instanceof \PhpParser\Node\Stmt\ClassMethod) {
return;
}
if (!$reflectionMethod->hasReturnType()) {
return;
}
$returnType = $reflectionMethod->getReturnType();
$returnTypeName = $returnType instanceof \ReflectionNamedType ? $returnType->getName() : (string) $returnType;
$classMethod->returnType = new \PhpParser\Node\Identifier($returnTypeName);
$classMethod->returnType = $setUpClassMethod->returnType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
use PhpParser\Node;
use PhpParser\Node\Stmt\ClassLike;
use Rector\Core\Rector\AbstractRector;
use Rector\FileSystemRector\ValueObject\AddedFileWithContent;
use Rector\Core\ValueObject\Application\File;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
Expand Down Expand Up @@ -52,11 +53,13 @@ public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
if ($classShortName === $smartFileInfo->getBasenameWithoutSuffix()) {
return null;
}
$file = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::FILE);
if (!$file instanceof \Rector\Core\ValueObject\Application\File) {
return null;
}
// no match → rename file
$newFileLocation = $smartFileInfo->getPath() . \DIRECTORY_SEPARATOR . $classShortName . '.php';
$addedFileWithContent = new \Rector\FileSystemRector\ValueObject\AddedFileWithContent($newFileLocation, $smartFileInfo->getContents());
$this->removedAndAddedFilesCollector->removeFile($smartFileInfo);
$this->removedAndAddedFilesCollector->addAddedFile($addedFileWithContent);
$this->removedAndAddedFilesCollector->addMovedFile($file, $newFileLocation);
return null;
}
}
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'c913346d528a32a8ebdb920a473dc1683ce005c9';
public const PACKAGE_VERSION = 'fa8e3bd295a21fa81f6a613c713dcf161897b0ae';
/**
* @var string
*/
public const RELEASE_DATE = '2021-08-09 13:26:11';
public const RELEASE_DATE = '2021-08-09 11:49:05';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210809\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

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

return ComposerAutoloaderInitef279323264e5d63afc8ec74fa15defb::getLoader();
return ComposerAutoloaderInit86dc8548a081f3138b10285749dfe7b2::getLoader();
14 changes: 7 additions & 7 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 ComposerAutoloaderInitef279323264e5d63afc8ec74fa15defb
class ComposerAutoloaderInit86dc8548a081f3138b10285749dfe7b2
{
private static $loader;

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

spl_autoload_register(array('ComposerAutoloaderInitef279323264e5d63afc8ec74fa15defb', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit86dc8548a081f3138b10285749dfe7b2', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInitef279323264e5d63afc8ec74fa15defb', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit86dc8548a081f3138b10285749dfe7b2', '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\ComposerStaticInitef279323264e5d63afc8ec74fa15defb::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit86dc8548a081f3138b10285749dfe7b2::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
Expand All @@ -42,19 +42,19 @@ public static function getLoader()
$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitef279323264e5d63afc8ec74fa15defb::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit86dc8548a081f3138b10285749dfe7b2::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireef279323264e5d63afc8ec74fa15defb($fileIdentifier, $file);
composerRequire86dc8548a081f3138b10285749dfe7b2($fileIdentifier, $file);
}

return $loader;
}
}

function composerRequireef279323264e5d63afc8ec74fa15defb($fileIdentifier, $file)
function composerRequire86dc8548a081f3138b10285749dfe7b2($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
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 ComposerStaticInitef279323264e5d63afc8ec74fa15defb
class ComposerStaticInit86dc8548a081f3138b10285749dfe7b2
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
Expand Down Expand Up @@ -3848,9 +3848,9 @@ class ComposerStaticInitef279323264e5d63afc8ec74fa15defb
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitef279323264e5d63afc8ec74fa15defb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitef279323264e5d63afc8ec74fa15defb::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitef279323264e5d63afc8ec74fa15defb::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit86dc8548a081f3138b10285749dfe7b2::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit86dc8548a081f3138b10285749dfe7b2::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit86dc8548a081f3138b10285749dfe7b2::$classMap;

}, null, ClassLoader::class);
}
Expand Down
10 changes: 5 additions & 5 deletions vendor/scoper-autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20210809\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInitef279323264e5d63afc8ec74fa15defb', false) && !interface_exists('ComposerAutoloaderInitef279323264e5d63afc8ec74fa15defb', false) && !trait_exists('ComposerAutoloaderInitef279323264e5d63afc8ec74fa15defb', false)) {
spl_autoload_call('RectorPrefix20210809\ComposerAutoloaderInitef279323264e5d63afc8ec74fa15defb');
if (!class_exists('ComposerAutoloaderInit86dc8548a081f3138b10285749dfe7b2', false) && !interface_exists('ComposerAutoloaderInit86dc8548a081f3138b10285749dfe7b2', false) && !trait_exists('ComposerAutoloaderInit86dc8548a081f3138b10285749dfe7b2', false)) {
spl_autoload_call('RectorPrefix20210809\ComposerAutoloaderInit86dc8548a081f3138b10285749dfe7b2');
}
if (!class_exists('AjaxLogin', false) && !interface_exists('AjaxLogin', false) && !trait_exists('AjaxLogin', false)) {
spl_autoload_call('RectorPrefix20210809\AjaxLogin');
Expand Down Expand Up @@ -3305,9 +3305,9 @@ function print_node() {
return \RectorPrefix20210809\print_node(...func_get_args());
}
}
if (!function_exists('composerRequireef279323264e5d63afc8ec74fa15defb')) {
function composerRequireef279323264e5d63afc8ec74fa15defb() {
return \RectorPrefix20210809\composerRequireef279323264e5d63afc8ec74fa15defb(...func_get_args());
if (!function_exists('composerRequire86dc8548a081f3138b10285749dfe7b2')) {
function composerRequire86dc8548a081f3138b10285749dfe7b2() {
return \RectorPrefix20210809\composerRequire86dc8548a081f3138b10285749dfe7b2(...func_get_args());
}
}
if (!function_exists('parseArgs')) {
Expand Down

0 comments on commit b2c929a

Please sign in to comment.