PHP 8.2.31
Preview: ConstExprNodeAnnotationToAttributeMapper.php Size: 1.58 KB
/opt/cpanel/ea-wappspector/vendor/rector/rector/src/PhpAttribute/AnnotationToAttributeMapper/ConstExprNodeAnnotationToAttributeMapper.php

<?php

declare (strict_types=1);
namespace Rector\PhpAttribute\AnnotationToAttributeMapper;

use PhpParser\BuilderHelpers;
use PhpParser\Node\Expr;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\Constant\ConstantFloatType;
use Rector\Exception\NotImplementedYetException;
use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface;
/**
 * @implements AnnotationToAttributeMapperInterface<ConstExprNode>
 */
final class ConstExprNodeAnnotationToAttributeMapper implements AnnotationToAttributeMapperInterface
{
    /**
     * @param mixed $value
     */
    public function isCandidate($value) : bool
    {
        return $value instanceof ConstExprNode;
    }
    /**
     * @param ConstExprNode $value
     */
    public function map($value) : Expr
    {
        if ($value instanceof ConstExprIntegerNode) {
            return BuilderHelpers::normalizeValue((int) $value->value);
        }
        if ($value instanceof ConstantFloatType || $value instanceof ConstantBooleanType) {
            return BuilderHelpers::normalizeValue($value->getValue());
        }
        if ($value instanceof ConstExprTrueNode) {
            return BuilderHelpers::normalizeValue(\true);
        }
        if ($value instanceof ConstExprFalseNode) {
            return BuilderHelpers::normalizeValue(\false);
        }
        throw new NotImplementedYetException();
    }
}

Directory Contents

Dirs: 0 × Files: 8

Name Size Perms Modified Actions
3.18 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
2.95 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
982 B lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.58 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
2.16 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
2.85 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.67 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
849 B lrw-r--r-- 2024-11-08 13:59:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).