REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.95 KB
Close
//opt/cpanel/ea-wappspector/vendor/rector/rector/src/PhpAttribute/AnnotationToAttributeMapper/ArrayItemNodeAnnotationToAttributeMapper.php
Text
Base64
<?php declare (strict_types=1); namespace Rector\PhpAttribute\AnnotationToAttributeMapper; use PhpParser\Node\Expr; use PhpParser\Node\Expr\ArrayItem; use PhpParser\Node\Scalar\String_; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use Rector\BetterPhpDocParser\PhpDoc\ArrayItemNode; use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode; use Rector\BetterPhpDocParser\PhpDoc\StringNode; use Rector\PhpAttribute\AnnotationToAttributeMapper; use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface; use Rector\PhpAttribute\Enum\DocTagNodeState; use Rector\Validation\RectorAssert; use RectorPrefix202411\Webmozart\Assert\InvalidArgumentException; /** * @implements AnnotationToAttributeMapperInterface<ArrayItemNode> */ final class ArrayItemNodeAnnotationToAttributeMapper implements AnnotationToAttributeMapperInterface { /** * @var \Rector\PhpAttribute\AnnotationToAttributeMapper */ private $annotationToAttributeMapper; /** * Avoid circular reference */ public function autowire(AnnotationToAttributeMapper $annotationToAttributeMapper) : void { $this->annotationToAttributeMapper = $annotationToAttributeMapper; } /** * @param mixed $value */ public function isCandidate($value) : bool { return $value instanceof ArrayItemNode; } /** * @param ArrayItemNode $arrayItemNode */ public function map($arrayItemNode) : Expr { $valueExpr = $this->annotationToAttributeMapper->map($arrayItemNode->value); if ($valueExpr === DocTagNodeState::REMOVE_ARRAY) { return new ArrayItem(new String_($valueExpr), null); } if ($arrayItemNode->key !== null) { /** @var Expr $keyExpr */ $keyExpr = $this->annotationToAttributeMapper->map($arrayItemNode->key); } else { if ($this->hasNoParenthesesAnnotation($arrayItemNode)) { try { RectorAssert::className(\ltrim((string) $arrayItemNode->value, '@')); $identifierTypeNode = new IdentifierTypeNode($arrayItemNode->value); $arrayItemNode->value = new DoctrineAnnotationTagValueNode($identifierTypeNode); return $this->map($arrayItemNode); } catch (InvalidArgumentException $exception) { } } $keyExpr = null; } // @todo how to skip natural integer keys? return new ArrayItem($valueExpr, $keyExpr); } private function hasNoParenthesesAnnotation(ArrayItemNode $arrayItemNode) : bool { if ($arrayItemNode->value instanceof StringNode) { return \false; } if (!\is_string($arrayItemNode->value)) { return \false; } if (\strncmp($arrayItemNode->value, '@', \strlen('@')) !== 0) { return \false; } return \substr_compare($arrayItemNode->value, ')', -\strlen(')')) !== 0; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 8
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
ArrayAnnotationToAttributeMapper.php
3.18 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ArrayItemNodeAnnotationToAttributeMapper.php
2.95 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ClassConstFetchAnnotationToAttributeMapper.php
982 B
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ConstExprNodeAnnotationToAttributeMapper.php
1.58 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CurlyListNodeAnnotationToAttributeMapper.php
2.16 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DoctrineAnnotationAnnotationToAttributeMapper.php
2.85 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
StringAnnotationToAttributeMapper.php
1.67 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
StringNodeAnnotationToAttributeMapper.php
849 B
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).