mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 17:00:51 +00:00
add PR annotate workflow
This commit is contained in:
parent
97f5ff545c
commit
eca4d54f58
22
.github/workflows/annotated_checkstyle.yaml
vendored
Normal file
22
.github/workflows/annotated_checkstyle.yaml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
# see https://github.com/staabm/annotate-pull-request-from-checkstyle
|
||||
name: Anotate Checkstyle
|
||||
|
||||
on:
|
||||
pull_request: null
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
check_fixtures:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: shivammathur/setup-php@v1
|
||||
with:
|
||||
php-version: 7.2
|
||||
coverage: none # disable xdebug, pcov
|
||||
tools: cs2pr
|
||||
- run: composer install --no-progress
|
||||
- run: |
|
||||
bin/rector p abz/DeadCode.php --set dead-code -n --autoload-file abz/DeadCode.php --output-format=checkstyle | cs2pr
|
|
@ -124,10 +124,13 @@ PHP
|
|||
/** @var PhpDocInfo|null $phpDocInfo */
|
||||
$phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO);
|
||||
if ($phpDocInfo === null) {
|
||||
return $node;
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->docBlockNameImporter->importNames($phpDocInfo, $node);
|
||||
$hasChanged = $this->docBlockNameImporter->importNames($phpDocInfo, $node);
|
||||
if (! $hasChanged) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
|
|
@ -66,8 +66,6 @@ PHP
|
|||
}
|
||||
|
||||
$isDeadAfterReturn = false;
|
||||
$isDeadAfterReturnRemoved = false;
|
||||
|
||||
foreach ($node->stmts as $key => $stmt) {
|
||||
if ($isDeadAfterReturn) {
|
||||
// keep comment
|
||||
|
@ -75,8 +73,7 @@ PHP
|
|||
continue;
|
||||
}
|
||||
|
||||
unset($node->stmts[$key]);
|
||||
$isDeadAfterReturnRemoved = true;
|
||||
$this->removeStmt($node, $key);
|
||||
}
|
||||
|
||||
if ($stmt instanceof Return_) {
|
||||
|
@ -85,10 +82,6 @@ PHP
|
|||
}
|
||||
}
|
||||
|
||||
if (! $isDeadAfterReturnRemoved) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $node;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ PHP
|
|||
continue;
|
||||
}
|
||||
|
||||
unset($node->stmts[$key]);
|
||||
$this->removeStmt($node, $key);
|
||||
}
|
||||
|
||||
$node->stmts = array_merge((array) $node->stmts, (array) $proccesed);
|
||||
|
|
|
@ -140,7 +140,7 @@ final class Application extends SymfonyApplication
|
|||
$input->getParameterOption('--output-format') === CheckstyleOutputFormatter::NAME ||
|
||||
$input->getParameterOption('-o') === CheckstyleOutputFormatter::NAME
|
||||
);
|
||||
return !$hasCheckstyleOutput;
|
||||
return ! $hasCheckstyleOutput;
|
||||
}
|
||||
|
||||
private function removeUnusedOptions(InputDefinition $inputDefinition): void
|
||||
|
|
|
@ -6,8 +6,12 @@ namespace Rector\Core\Rector\AbstractRector;
|
|||
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use Rector\ChangesReporting\Rector\AbstractRector\RectorChangeCollectorTrait;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Doctrine\AbstractRector\DoctrineTrait;
|
||||
|
||||
trait AbstractRectorTrait
|
||||
|
@ -43,4 +47,19 @@ trait AbstractRectorTrait
|
|||
|
||||
return ! Strings::contains($name, 'AnonymousClass');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Closure|ClassMethod|Function_ $node
|
||||
*/
|
||||
protected function removeStmt(Node $node, $key): void
|
||||
{
|
||||
if ($node->stmts === null) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
|
||||
// notify about remove node
|
||||
$this->notifyNodeChangeFileInfo($node->stmts[$key]);
|
||||
|
||||
unset($node->stmts[$key]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user