rector/rules/Php80/NodeFactory/AttributeFlagFactory.php
Tomas Votruba e6862d8637 Updated Rector to commit 2fa48d7e59d5a00a6d94b481d85f9965b61e2d30
2fa48d7e59 [PHP 8.0] Allow back compatiblity with DoctrineAnnotationClassToAttributeRector (#124)
2021-05-30 23:19:42 +00:00

27 lines
698 B
PHP

<?php
declare (strict_types=1);
namespace Rector\Php80\NodeFactory;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\BitwiseOr;
use PhpParser\Node\Expr\ClassConstFetch;
final class AttributeFlagFactory
{
/**
* @param ClassConstFetch[] $flags
* @return ClassConstFetch|BitwiseOr|null
*/
public function createFlagCollection(array $flags) : ?\PhpParser\Node\Expr
{
if ($flags === []) {
return null;
}
$flagCollection = \array_shift($flags);
foreach ($flags as $flag) {
$flagCollection = new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($flagCollection, $flag);
}
return $flagCollection;
}
}