mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 11:44:14 +01:00
[DeprecationExtractor] improve fail exception
This commit is contained in:
parent
27adddade6
commit
5b84664fa4
@ -4,10 +4,12 @@ namespace Rector\DeprecationExtractor;
|
||||
|
||||
use PhpParser\NodeTraverser;
|
||||
use Rector\Contract\Parser\ParserInterface;
|
||||
use Rector\DeprecationExtractor\Exception\DeprecationExtractorException;
|
||||
use Rector\DeprecationExtractor\NodeVisitor\DeprecationDetector;
|
||||
use Rector\FileSystem\PhpFilesFinder;
|
||||
use Rector\NodeTraverser\NodeTraverserFactory;
|
||||
use Rector\NodeTraverser\StandaloneTraverseNodeTraverser;
|
||||
use Throwable;
|
||||
|
||||
final class DeprecationExtractor
|
||||
{
|
||||
@ -52,11 +54,20 @@ final class DeprecationExtractor
|
||||
$files = $this->phpFilesFinder->findInDirectoriesAndFiles($source);
|
||||
|
||||
foreach ($files as $file) {
|
||||
$nodes = $this->parser->parseFile($file->getRealPath());
|
||||
// this completes parent & child nodes, types and classses
|
||||
$this->standaloneTraverseNodeTraverser->traverse($nodes);
|
||||
try {
|
||||
$nodes = $this->parser->parseFile($file->getRealPath());
|
||||
// this completes parent & child nodes, types and classses
|
||||
$this->standaloneTraverseNodeTraverser->traverse($nodes);
|
||||
|
||||
$this->deprecationDetectorNodeTraverser->traverse($nodes);
|
||||
$this->deprecationDetectorNodeTraverser->traverse($nodes);
|
||||
} catch (Throwable $throwable) {
|
||||
$message = sprintf(
|
||||
'Extracting deperactions from "%s" file failed.',
|
||||
$file->getRealPath()
|
||||
);
|
||||
|
||||
throw new DeprecationExtractorException($message, 0, $throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\DeprecationExtractor\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
final class DeprecationExtractorException extends Exception
|
||||
{
|
||||
}
|
@ -50,11 +50,7 @@ final class PropertyFetchTypeResolver implements PerNodeTypeResolverInterface, N
|
||||
*/
|
||||
public function resolve(Node $propertyFetchNode): array
|
||||
{
|
||||
if ($propertyFetchNode->name instanceof Variable) {
|
||||
return $this->nodeTypeResolver->resolve($propertyFetchNode->name);
|
||||
}
|
||||
|
||||
if ($propertyFetchNode->name instanceof ArrayDimFetch) {
|
||||
if ($propertyFetchNode->name instanceof Variable || $propertyFetchNode->name instanceof ArrayDimFetch) {
|
||||
return $this->nodeTypeResolver->resolve($propertyFetchNode->name);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user