mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 04:19:44 +01:00
Do not print files with fatal errors as the file format breaks completely (#5967)
This commit is contained in:
parent
27e9ad030a
commit
ae8ead946b
@ -179,4 +179,15 @@ final class ErrorAndDiffCollector
|
||||
$this->errors[] = new RectorError($fileInfo, $throwable->getMessage(), $throwable->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
public function hasErrors(SmartFileInfo $phpFileInfo): bool
|
||||
{
|
||||
foreach ($this->errors as $error) {
|
||||
if ($error->getFileInfo() === $phpFileInfo) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -166,6 +166,12 @@ final class RectorApplication
|
||||
|
||||
// 4. print to file or string
|
||||
foreach ($phpFileInfos as $phpFileInfo) {
|
||||
// cannot print file with errors, as print would break everything to orignal nodes
|
||||
if ($this->errorAndDiffCollector->hasErrors($phpFileInfo)) {
|
||||
$this->advance($phpFileInfo, 'printing');
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->tryCatchWrapper($phpFileInfo, function (SmartFileInfo $smartFileInfo): void {
|
||||
$this->printFileInfo($smartFileInfo);
|
||||
}, 'printing');
|
||||
|
Loading…
x
Reference in New Issue
Block a user