mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-13 14:42:23 +00:00
fc10fce13d
* re-enable rectify and ecs * [Rectify] [Php81] Enable Rectify on Readonly Property only * comment * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify Co-authored-by: GitHub Action <action@github.com>
40 lines
859 B
PHP
40 lines
859 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Rector\BetterPhpDocParser\ValueObject\Type;
|
|
|
|
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
|
|
use Stringable;
|
|
|
|
final class BracketsAwareUnionTypeNode extends UnionTypeNode implements Stringable
|
|
{
|
|
/**
|
|
* @param TypeNode[] $types
|
|
*/
|
|
public function __construct(
|
|
array $types,
|
|
private readonly bool $isWrappedInBrackets = false
|
|
) {
|
|
parent::__construct($types);
|
|
}
|
|
|
|
/**
|
|
* Preserve common format
|
|
*/
|
|
public function __toString(): string
|
|
{
|
|
if (! $this->isWrappedInBrackets) {
|
|
return implode('|', $this->types);
|
|
}
|
|
|
|
return '(' . implode('|', $this->types) . ')';
|
|
}
|
|
|
|
public function isWrappedInBrackets(): bool
|
|
{
|
|
return $this->isWrappedInBrackets;
|
|
}
|
|
}
|