mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-21 16:02:23 +02:00
Fix travis for Laravel self-run (#1398)
Fix travis for Laravel self-run
This commit is contained in:
commit
fac1503915
3
.gitignore
vendored
3
.gitignore
vendored
@ -12,3 +12,6 @@ composer.lock
|
||||
create-rector.yaml
|
||||
phpstan-dependencies.json
|
||||
phpstan-paths.txt
|
||||
|
||||
# tests - travis
|
||||
/laravel-dir
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace Rector\CodeQuality\Rector\Array_;
|
||||
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
@ -11,8 +9,10 @@ use PhpParser\Node\Expr\Array_;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\ClosureUse;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Param;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use Rector\NodeContainer\ParsedNodesByType;
|
||||
|
@ -100,12 +100,16 @@ final class FileProcessor
|
||||
*/
|
||||
public function printToString(SmartFileInfo $smartFileInfo): string
|
||||
{
|
||||
$this->makeSureFileIsParsed($smartFileInfo);
|
||||
|
||||
[$newStmts, $oldStmts, $oldTokens] = $this->tokensByFilePath[$smartFileInfo->getRealPath()];
|
||||
return $this->formatPerservingPrinter->printToString($newStmts, $oldStmts, $oldTokens);
|
||||
}
|
||||
|
||||
public function refactor(SmartFileInfo $smartFileInfo): void
|
||||
{
|
||||
$this->makeSureFileIsParsed($smartFileInfo);
|
||||
|
||||
[$newStmts, $oldStmts, $oldTokens] = $this->tokensByFilePath[$smartFileInfo->getRealPath()];
|
||||
$newStmts = $this->rectorNodeTraverser->traverse($newStmts);
|
||||
|
||||
@ -121,6 +125,9 @@ final class FileProcessor
|
||||
$oldStmts = $this->parser->parseFile($smartFileInfo->getRealPath());
|
||||
$oldTokens = $this->lexer->getTokens();
|
||||
|
||||
// needed for \Rector\NodeTypeResolver\PHPStan\Scope\NodeScopeResolver
|
||||
$this->tokensByFilePath[$smartFileInfo->getRealPath()] = [$oldStmts, $oldStmts, $oldTokens];
|
||||
|
||||
$newStmts = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile(
|
||||
$oldStmts,
|
||||
$smartFileInfo->getRealPath()
|
||||
@ -128,4 +135,18 @@ final class FileProcessor
|
||||
|
||||
return [$newStmts, $oldStmts, $oldTokens];
|
||||
}
|
||||
|
||||
private function makeSureFileIsParsed(SmartFileInfo $smartFileInfo): void
|
||||
{
|
||||
if (isset($this->tokensByFilePath[$smartFileInfo->getRealPath()])) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new ShouldNotHappenException(sprintf(
|
||||
'File %s was not preparsed, so it cannot be printed.%sCheck "%s" method.',
|
||||
$smartFileInfo->getRealPath(),
|
||||
PHP_EOL,
|
||||
self::class . '::parseFileInfoToLocalCache()'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user