mirror of
https://github.com/rectorphp/rector.git
synced 2024-07-03 08:03:30 +00:00
commit
e05ccbef70
|
@ -13,8 +13,7 @@ new class {
|
|||
|
||||
namespace Rector\Php\Tests\Rector\ClassMethod\ParamAndReturnScalarTypehintsRector\Integration\AnonClass;
|
||||
|
||||
new class
|
||||
{
|
||||
new class {
|
||||
/** @param int $a */
|
||||
public function test(int $a) {}
|
||||
};
|
||||
|
|
|
@ -35,7 +35,7 @@ final class TolerantRectorYamlFileLoader extends AbstractParameterMergingYamlFil
|
|||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return array|mixed|mixed[]
|
||||
* @return mixed|mixed[]
|
||||
*/
|
||||
protected function loadFile($file)
|
||||
{
|
||||
|
|
|
@ -93,12 +93,12 @@ final class NodeAddingCommander implements CommanderInterface
|
|||
|
||||
private function createNodeVisitor(): NodeVisitor
|
||||
{
|
||||
return new class($this->nodesToAdd) extends NodeVisitorAbstract
|
||||
{
|
||||
return new class($this->nodesToAdd) extends NodeVisitorAbstract {
|
||||
/**
|
||||
* @var Stmt[][]
|
||||
*/
|
||||
private $nodesToAdd = [];
|
||||
|
||||
/**
|
||||
* @param Stmt[][] $nodesToAdd
|
||||
*/
|
||||
|
@ -106,6 +106,7 @@ final class NodeAddingCommander implements CommanderInterface
|
|||
{
|
||||
$this->nodesToAdd = $nodesToAdd;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Node[]|Node|null
|
||||
*/
|
||||
|
|
|
@ -51,12 +51,12 @@ final class NodeRemovingCommander implements CommanderInterface
|
|||
|
||||
private function createNodeVisitor(): NodeVisitor
|
||||
{
|
||||
return new class($this->nodesToRemove) extends NodeVisitorAbstract
|
||||
{
|
||||
return new class($this->nodesToRemove) extends NodeVisitorAbstract {
|
||||
/**
|
||||
* @var Stmt[]
|
||||
*/
|
||||
private $nodesToRemove = [];
|
||||
|
||||
/**
|
||||
* @param Stmt[] $nodesToRemove
|
||||
*/
|
||||
|
@ -64,6 +64,7 @@ final class NodeRemovingCommander implements CommanderInterface
|
|||
{
|
||||
$this->nodesToRemove = $nodesToRemove;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|Node|Node[]|null
|
||||
*/
|
||||
|
|
|
@ -58,16 +58,17 @@ final class PropertyAddingCommander implements CommanderInterface
|
|||
|
||||
private function createNodeVisitor(): NodeVisitor
|
||||
{
|
||||
return new class($this->classMaintainer, $this->propertiesByClass) extends NodeVisitorAbstract
|
||||
{
|
||||
return new class($this->classMaintainer, $this->propertiesByClass) extends NodeVisitorAbstract {
|
||||
/**
|
||||
* @var ClassMaintainer
|
||||
*/
|
||||
private $classMaintainer;
|
||||
|
||||
/**
|
||||
* @var VariableInfo[][]
|
||||
*/
|
||||
private $propertiesByClass = [];
|
||||
|
||||
/**
|
||||
* @param VariableInfo[][] $propertiesByClass
|
||||
*/
|
||||
|
@ -76,6 +77,7 @@ final class PropertyAddingCommander implements CommanderInterface
|
|||
$this->classMaintainer = $classMaintainer;
|
||||
$this->propertiesByClass = $propertiesByClass;
|
||||
}
|
||||
|
||||
public function enterNode(Node $node): ?Node
|
||||
{
|
||||
if (! $node instanceof Class_ || $node->isAnonymous()) {
|
||||
|
@ -84,6 +86,7 @@ final class PropertyAddingCommander implements CommanderInterface
|
|||
|
||||
return $this->processClassNode($node);
|
||||
}
|
||||
|
||||
private function processClassNode(Class_ $classNode): Class_
|
||||
{
|
||||
$variableInfos = $this->propertiesByClass[spl_object_hash($classNode)] ?? [];
|
||||
|
|
|
@ -23,16 +23,17 @@ final class CallableNodeTraverser
|
|||
|
||||
private function createNodeVisitor(callable $callable): NodeVisitor
|
||||
{
|
||||
return new class($callable) extends NodeVisitorAbstract
|
||||
{
|
||||
return new class($callable) extends NodeVisitorAbstract {
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $callable;
|
||||
|
||||
public function __construct(callable $callable)
|
||||
{
|
||||
$this->callable = $callable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|Node|null
|
||||
*/
|
||||
|
|
|
@ -149,7 +149,11 @@ final class BetterStandardPrinter extends Standard
|
|||
if ($node->class->name instanceof Identifier) {
|
||||
$className = $node->class->name->toString();
|
||||
if (Strings::startsWith($className, 'AnonymousClass')) {
|
||||
$node->setAttribute(Attribute::ORIGINAL_NODE, null);
|
||||
/** @var Class_ $originalNode */
|
||||
$originalNode = $node->class->getAttribute(Attribute::ORIGINAL_NODE);
|
||||
$originalNode->name = null;
|
||||
|
||||
$node->class->setAttribute(Attribute::ORIGINAL_NODE, $originalNode);
|
||||
$node->class->name = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user