mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-26 20:53:31 +00:00
add brackets in case of array of callables in php doc
This commit is contained in:
parent
508954fc74
commit
9135bff8eb
|
@ -5,10 +5,22 @@ declare(strict_types=1);
|
|||
namespace Rector\AttributeAwarePhpDoc\Ast\Type;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode;
|
||||
use Rector\BetterPhpDocParser\Attributes\Attribute\AttributeTrait;
|
||||
use Rector\BetterPhpDocParser\Contract\PhpDocNode\AttributeAwareNodeInterface;
|
||||
|
||||
final class AttributeAwareArrayTypeNode extends ArrayTypeNode implements AttributeAwareNodeInterface
|
||||
{
|
||||
use AttributeTrait;
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$typeAsString = (string) $this->type;
|
||||
|
||||
if ($this->type instanceof CallableTypeNode) {
|
||||
return sprintf('(%s)[]', $typeAsString);
|
||||
}
|
||||
|
||||
return $typeAsString . '[]';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user