?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/PhpDoc.tar
???????
VarTagValueNodeRenamer.php 0000644 00000001531 15126515050 0011556 0 ustar 00 <?php declare (strict_types=1); namespace Rector\Naming\PhpDoc; use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; final class VarTagValueNodeRenamer { public function renameAssignVarTagVariableName(PhpDocInfo $phpDocInfo, string $originalName, string $expectedName) : void { $varTagValueNode = $phpDocInfo->getVarTagValueNode(); if (!$varTagValueNode instanceof VarTagValueNode) { return; } if ($varTagValueNode->variableName !== '$' . $originalName) { return; } $varTagValueNode->variableName = '$' . $expectedName; // invoke node reprint - same as in php-parser $varTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null); } } DeadVarTagValueNodeAnalyzer.php 0000644 00000004754 15127535031 0012544 0 ustar 00 <?php declare (strict_types=1); namespace Rector\DeadCode\PhpDoc; use PhpParser\Node\Stmt\Property; use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; use PHPStan\Type\IntersectionType; use PHPStan\Type\ObjectType; use PHPStan\Type\TypeCombinator; use PHPStan\Type\UnionType; use Rector\DeadCode\PhpDoc\Guard\TemplateTypeRemovalGuard; use Rector\NodeTypeResolver\TypeComparator\TypeComparator; use Rector\StaticTypeMapper\StaticTypeMapper; final class DeadVarTagValueNodeAnalyzer { /** * @readonly * @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator */ private $typeComparator; /** * @readonly * @var \Rector\StaticTypeMapper\StaticTypeMapper */ private $staticTypeMapper; /** * @readonly * @var \Rector\DeadCode\PhpDoc\Guard\TemplateTypeRemovalGuard */ private $templateTypeRemovalGuard; public function __construct(TypeComparator $typeComparator, StaticTypeMapper $staticTypeMapper, TemplateTypeRemovalGuard $templateTypeRemovalGuard) { $this->typeComparator = $typeComparator; $this->staticTypeMapper = $staticTypeMapper; $this->templateTypeRemovalGuard = $templateTypeRemovalGuard; } public function isDead(VarTagValueNode $varTagValueNode, Property $property) : bool { if ($property->type === null) { return \false; } if ($varTagValueNode->description !== '') { return \false; } // is strict type superior to doc type? keep strict type only $propertyType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($property->type); $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($varTagValueNode->type, $property); if (!$this->templateTypeRemovalGuard->isLegal($docType)) { return \false; } if ($propertyType instanceof UnionType && !$docType instanceof UnionType) { return !$docType instanceof IntersectionType; } if ($propertyType instanceof ObjectType && $docType instanceof ObjectType) { // more specific type is already in the property return $docType->isSuperTypeOf($propertyType)->yes(); } if ($this->typeComparator->arePhpParserAndPhpStanPhpDocTypesEqual($property->type, $varTagValueNode->type, $property)) { return \true; } return $docType instanceof UnionType && $this->typeComparator->areTypesEqual(TypeCombinator::removeNull($docType), $propertyType); } } DeadParamTagValueNodeAnalyzer.php 0000644 00000011441 15127535031 0013043 0 ustar 00 <?php declare (strict_types=1); namespace Rector\DeadCode\PhpDoc; use PhpParser\Node\FunctionLike; use PhpParser\Node\Name; use PhpParser\Node\Param; use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode; use Rector\DeadCode\PhpDoc\Guard\StandaloneTypeRemovalGuard; use Rector\DeadCode\PhpDoc\Guard\TemplateTypeRemovalGuard; use Rector\DeadCode\TypeNodeAnalyzer\GenericTypeNodeAnalyzer; use Rector\DeadCode\TypeNodeAnalyzer\MixedArrayTypeNodeAnalyzer; use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeTypeResolver\TypeComparator\TypeComparator; use Rector\StaticTypeMapper\StaticTypeMapper; use Rector\TypeDeclaration\NodeAnalyzer\ParamAnalyzer; final class DeadParamTagValueNodeAnalyzer { /** * @readonly * @var \Rector\NodeNameResolver\NodeNameResolver */ private $nodeNameResolver; /** * @readonly * @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator */ private $typeComparator; /** * @readonly * @var \Rector\DeadCode\TypeNodeAnalyzer\GenericTypeNodeAnalyzer */ private $genericTypeNodeAnalyzer; /** * @readonly * @var \Rector\DeadCode\TypeNodeAnalyzer\MixedArrayTypeNodeAnalyzer */ private $mixedArrayTypeNodeAnalyzer; /** * @readonly * @var \Rector\TypeDeclaration\NodeAnalyzer\ParamAnalyzer */ private $paramAnalyzer; /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger */ private $phpDocTypeChanger; /** * @readonly * @var \Rector\DeadCode\PhpDoc\Guard\StandaloneTypeRemovalGuard */ private $standaloneTypeRemovalGuard; /** * @readonly * @var \Rector\StaticTypeMapper\StaticTypeMapper */ private $staticTypeMapper; /** * @readonly * @var \Rector\DeadCode\PhpDoc\Guard\TemplateTypeRemovalGuard */ private $templateTypeRemovalGuard; public function __construct(NodeNameResolver $nodeNameResolver, TypeComparator $typeComparator, GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer, ParamAnalyzer $paramAnalyzer, PhpDocTypeChanger $phpDocTypeChanger, StandaloneTypeRemovalGuard $standaloneTypeRemovalGuard, StaticTypeMapper $staticTypeMapper, TemplateTypeRemovalGuard $templateTypeRemovalGuard) { $this->nodeNameResolver = $nodeNameResolver; $this->typeComparator = $typeComparator; $this->genericTypeNodeAnalyzer = $genericTypeNodeAnalyzer; $this->mixedArrayTypeNodeAnalyzer = $mixedArrayTypeNodeAnalyzer; $this->paramAnalyzer = $paramAnalyzer; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->standaloneTypeRemovalGuard = $standaloneTypeRemovalGuard; $this->staticTypeMapper = $staticTypeMapper; $this->templateTypeRemovalGuard = $templateTypeRemovalGuard; } public function isDead(ParamTagValueNode $paramTagValueNode, FunctionLike $functionLike) : bool { $param = $this->paramAnalyzer->getParamByName($paramTagValueNode->parameterName, $functionLike); if (!$param instanceof Param) { return \false; } if ($param->type === null) { return \false; } if ($paramTagValueNode->description !== '') { return \false; } $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($paramTagValueNode->type, $functionLike); if (!$this->templateTypeRemovalGuard->isLegal($docType)) { return \false; } if ($param->type instanceof Name && $this->nodeNameResolver->isName($param->type, 'object')) { return $paramTagValueNode->type instanceof IdentifierTypeNode && (string) $paramTagValueNode->type === 'object'; } if (!$this->typeComparator->arePhpParserAndPhpStanPhpDocTypesEqual($param->type, $paramTagValueNode->type, $functionLike)) { return \false; } if ($this->phpDocTypeChanger->isAllowed($paramTagValueNode->type)) { return \false; } if (!$paramTagValueNode->type instanceof BracketsAwareUnionTypeNode) { return $this->standaloneTypeRemovalGuard->isLegal($paramTagValueNode->type, $param->type); } return $this->isAllowedBracketAwareUnion($paramTagValueNode->type); } private function isAllowedBracketAwareUnion(BracketsAwareUnionTypeNode $bracketsAwareUnionTypeNode) : bool { if ($this->mixedArrayTypeNodeAnalyzer->hasMixedArrayType($bracketsAwareUnionTypeNode)) { return \false; } return !$this->genericTypeNodeAnalyzer->hasGenericType($bracketsAwareUnionTypeNode); } } Guard/TemplateTypeRemovalGuard.php 0000644 00000001340 15127535031 0013245 0 ustar 00 <?php declare (strict_types=1); namespace Rector\DeadCode\PhpDoc\Guard; use PHPStan\Type\Type; use PHPStan\Type\UnionType; use PHPStan\Type\Generic\TemplateType; final class TemplateTypeRemovalGuard { public function isLegal(Type $docType) : bool { // cover direct \PHPStan\Type\Generic\TemplateUnionType if ($docType instanceof TemplateType) { return \false; } // cover mixed template with mix from @template and non @template $types = $docType instanceof UnionType ? $docType->getTypes() : [$docType]; foreach ($types as $type) { if ($type instanceof TemplateType) { return \false; } } return \true; } } Guard/StandaloneTypeRemovalGuard.php 0000644 00000001367 15127535031 0013573 0 ustar 00 <?php declare (strict_types=1); namespace Rector\DeadCode\PhpDoc\Guard; use PhpParser\Node; use PhpParser\Node\Identifier; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use PHPStan\PhpDocParser\Ast\Type\TypeNode; final class StandaloneTypeRemovalGuard { /** * @var string[] */ private const ALLOWED_TYPES = ['false', 'true']; public function isLegal(TypeNode $typeNode, Node $node) : bool { if (!$typeNode instanceof IdentifierTypeNode) { return \true; } if (!$node instanceof Identifier) { return \true; } if ($node->toString() !== 'bool') { return \true; } return !\in_array($typeNode->name, self::ALLOWED_TYPES, \true); } } DeadReturnTagValueNodeAnalyzer.php 0000644 00000015355 15127535032 0013273 0 ustar 00 <?php declare (strict_types=1); namespace Rector\DeadCode\PhpDoc; use PhpParser\Node; use PhpParser\Node\Identifier; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Function_; use PHPStan\Analyser\Scope; use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use PHPStan\PhpDocParser\Ast\Type\ThisTypeNode; use PHPStan\Type\TypeCombinator; use PHPStan\Type\UnionType; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode; use Rector\DeadCode\PhpDoc\Guard\StandaloneTypeRemovalGuard; use Rector\DeadCode\PhpDoc\Guard\TemplateTypeRemovalGuard; use Rector\DeadCode\TypeNodeAnalyzer\GenericTypeNodeAnalyzer; use Rector\DeadCode\TypeNodeAnalyzer\MixedArrayTypeNodeAnalyzer; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\TypeComparator\TypeComparator; use Rector\StaticTypeMapper\StaticTypeMapper; final class DeadReturnTagValueNodeAnalyzer { /** * @readonly * @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator */ private $typeComparator; /** * @readonly * @var \Rector\DeadCode\TypeNodeAnalyzer\GenericTypeNodeAnalyzer */ private $genericTypeNodeAnalyzer; /** * @readonly * @var \Rector\DeadCode\TypeNodeAnalyzer\MixedArrayTypeNodeAnalyzer */ private $mixedArrayTypeNodeAnalyzer; /** * @readonly * @var \Rector\DeadCode\PhpDoc\Guard\StandaloneTypeRemovalGuard */ private $standaloneTypeRemovalGuard; /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger */ private $phpDocTypeChanger; /** * @readonly * @var \Rector\StaticTypeMapper\StaticTypeMapper */ private $staticTypeMapper; /** * @readonly * @var \Rector\DeadCode\PhpDoc\Guard\TemplateTypeRemovalGuard */ private $templateTypeRemovalGuard; public function __construct(TypeComparator $typeComparator, GenericTypeNodeAnalyzer $genericTypeNodeAnalyzer, MixedArrayTypeNodeAnalyzer $mixedArrayTypeNodeAnalyzer, StandaloneTypeRemovalGuard $standaloneTypeRemovalGuard, PhpDocTypeChanger $phpDocTypeChanger, StaticTypeMapper $staticTypeMapper, TemplateTypeRemovalGuard $templateTypeRemovalGuard) { $this->typeComparator = $typeComparator; $this->genericTypeNodeAnalyzer = $genericTypeNodeAnalyzer; $this->mixedArrayTypeNodeAnalyzer = $mixedArrayTypeNodeAnalyzer; $this->standaloneTypeRemovalGuard = $standaloneTypeRemovalGuard; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->staticTypeMapper = $staticTypeMapper; $this->templateTypeRemovalGuard = $templateTypeRemovalGuard; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ public function isDead(ReturnTagValueNode $returnTagValueNode, $functionLike) : bool { $returnType = $functionLike->getReturnType(); if ($returnType === null) { return \false; } if ($returnTagValueNode->description !== '') { return \false; } $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($returnTagValueNode->type, $functionLike); if (!$this->templateTypeRemovalGuard->isLegal($docType)) { return \false; } $scope = $functionLike->getAttribute(AttributeKey::SCOPE); if ($scope instanceof Scope && $scope->isInTrait() && $returnTagValueNode->type instanceof ThisTypeNode) { return \false; } if (!$this->typeComparator->arePhpParserAndPhpStanPhpDocTypesEqual($returnType, $returnTagValueNode->type, $functionLike)) { return $this->isDeadNotEqual($returnTagValueNode, $returnType, $functionLike); } if ($this->phpDocTypeChanger->isAllowed($returnTagValueNode->type)) { return \false; } if (!$returnTagValueNode->type instanceof BracketsAwareUnionTypeNode) { return $this->standaloneTypeRemovalGuard->isLegal($returnTagValueNode->type, $returnType); } if ($this->genericTypeNodeAnalyzer->hasGenericType($returnTagValueNode->type)) { return \false; } if ($this->mixedArrayTypeNodeAnalyzer->hasMixedArrayType($returnTagValueNode->type)) { return \false; } return !$this->hasTrueFalsePseudoType($returnTagValueNode->type); } private function isVoidReturnType(Node $node) : bool { return $node instanceof Identifier && $node->toString() === 'void'; } private function isNeverReturnType(Node $node) : bool { return $node instanceof Identifier && $node->toString() === 'never'; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ private function isDeadNotEqual(ReturnTagValueNode $returnTagValueNode, Node $node, $functionLike) : bool { if ($returnTagValueNode->type instanceof IdentifierTypeNode && (string) $returnTagValueNode->type === 'void') { return \true; } if (!$this->hasUsefullPhpdocType($returnTagValueNode, $node)) { return \true; } $nodeType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($node); $docType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($returnTagValueNode->type, $functionLike); return $docType instanceof UnionType && $this->typeComparator->areTypesEqual(TypeCombinator::removeNull($docType), $nodeType); } private function hasTrueFalsePseudoType(BracketsAwareUnionTypeNode $bracketsAwareUnionTypeNode) : bool { $unionTypes = $bracketsAwareUnionTypeNode->types; foreach ($unionTypes as $unionType) { if (!$unionType instanceof IdentifierTypeNode) { continue; } $name = \strtolower((string) $unionType); if (\in_array($name, ['true', 'false'], \true)) { return \true; } } return \false; } /** * exact different between @return and node return type * @param mixed $returnType */ private function hasUsefullPhpdocType(ReturnTagValueNode $returnTagValueNode, $returnType) : bool { if ($returnTagValueNode->type instanceof IdentifierTypeNode && $returnTagValueNode->type->name === 'mixed') { return \false; } if (!$this->isVoidReturnType($returnType)) { return !$this->isNeverReturnType($returnType); } if (!$returnTagValueNode->type instanceof IdentifierTypeNode || (string) $returnTagValueNode->type !== 'never') { return \false; } return !$this->isNeverReturnType($returnType); } } TagRemover/ReturnTagRemover.php 0000644 00000002532 15127535032 0012610 0 ustar 00 <?php declare (strict_types=1); namespace Rector\DeadCode\PhpDoc\TagRemover; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Function_; use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\DeadCode\PhpDoc\DeadReturnTagValueNodeAnalyzer; final class ReturnTagRemover { /** * @readonly * @var \Rector\DeadCode\PhpDoc\DeadReturnTagValueNodeAnalyzer */ private $deadReturnTagValueNodeAnalyzer; public function __construct(DeadReturnTagValueNodeAnalyzer $deadReturnTagValueNodeAnalyzer) { $this->deadReturnTagValueNodeAnalyzer = $deadReturnTagValueNodeAnalyzer; } /** * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike */ public function removeReturnTagIfUseless(PhpDocInfo $phpDocInfo, $functionLike) : bool { // remove existing type $returnTagValueNode = $phpDocInfo->getReturnTagValue(); if (!$returnTagValueNode instanceof ReturnTagValueNode) { return \false; } $isReturnTagValueDead = $this->deadReturnTagValueNodeAnalyzer->isDead($returnTagValueNode, $functionLike); if (!$isReturnTagValueDead) { return \false; } $phpDocInfo->removeByType(ReturnTagValueNode::class); return \true; } } TagRemover/ParamTagRemover.php 0000644 00000004631 15127535032 0012373 0 ustar 00 <?php declare (strict_types=1); namespace Rector\DeadCode\PhpDoc\TagRemover; use PhpParser\Node\FunctionLike; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; use PHPStan\Type\Type; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\DeadCode\PhpDoc\DeadParamTagValueNodeAnalyzer; use Rector\PhpDocParser\PhpDocParser\PhpDocNodeTraverser; final class ParamTagRemover { /** * @readonly * @var \Rector\DeadCode\PhpDoc\DeadParamTagValueNodeAnalyzer */ private $deadParamTagValueNodeAnalyzer; /** * @readonly * @var \Rector\Comments\NodeDocBlock\DocBlockUpdater */ private $docBlockUpdater; public function __construct(DeadParamTagValueNodeAnalyzer $deadParamTagValueNodeAnalyzer, DocBlockUpdater $docBlockUpdater) { $this->deadParamTagValueNodeAnalyzer = $deadParamTagValueNodeAnalyzer; $this->docBlockUpdater = $docBlockUpdater; } public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike, ?Type $type = null) : bool { $hasChanged = \false; $phpDocNodeTraverser = new PhpDocNodeTraverser(); $phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (Node $docNode) use($functionLike, &$hasChanged, $type, $phpDocInfo) : ?int { if (!$docNode instanceof PhpDocTagNode) { return null; } if (!$docNode->value instanceof ParamTagValueNode) { return null; } // handle only basic types, keep phpstan/psalm helper ones if ($docNode->name !== '@param') { return null; } if ($type instanceof Type) { $paramType = $phpDocInfo->getParamType($docNode->value->parameterName); if (!$type->equals($paramType)) { return null; } } if (!$this->deadParamTagValueNodeAnalyzer->isDead($docNode->value, $functionLike)) { return null; } $hasChanged = \true; return PhpDocNodeTraverser::NODE_REMOVE; }); if ($hasChanged) { $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($functionLike); } return $hasChanged; } } TagRemover/VarTagRemover.php 0000644 00000011356 15127535032 0012065 0 ustar 00 <?php declare (strict_types=1); namespace Rector\DeadCode\PhpDoc\TagRemover; use PhpParser\Node; use PhpParser\Node\Param; use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Property; use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode; use PHPStan\Type\Generic\TemplateObjectWithoutClassType; use PHPStan\Type\Type; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; use Rector\Comments\NodeDocBlock\DocBlockUpdater; use Rector\DeadCode\PhpDoc\DeadVarTagValueNodeAnalyzer; use Rector\NodeTypeResolver\TypeComparator\TypeComparator; use Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer; final class VarTagRemover { /** * @readonly * @var \Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer */ private $doctrineTypeAnalyzer; /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory */ private $phpDocInfoFactory; /** * @readonly * @var \Rector\DeadCode\PhpDoc\DeadVarTagValueNodeAnalyzer */ private $deadVarTagValueNodeAnalyzer; /** * @readonly * @var \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger */ private $phpDocTypeChanger; /** * @readonly * @var \Rector\Comments\NodeDocBlock\DocBlockUpdater */ private $docBlockUpdater; /** * @readonly * @var \Rector\NodeTypeResolver\TypeComparator\TypeComparator */ private $typeComparator; public function __construct(DoctrineTypeAnalyzer $doctrineTypeAnalyzer, PhpDocInfoFactory $phpDocInfoFactory, DeadVarTagValueNodeAnalyzer $deadVarTagValueNodeAnalyzer, PhpDocTypeChanger $phpDocTypeChanger, DocBlockUpdater $docBlockUpdater, TypeComparator $typeComparator) { $this->doctrineTypeAnalyzer = $doctrineTypeAnalyzer; $this->phpDocInfoFactory = $phpDocInfoFactory; $this->deadVarTagValueNodeAnalyzer = $deadVarTagValueNodeAnalyzer; $this->phpDocTypeChanger = $phpDocTypeChanger; $this->docBlockUpdater = $docBlockUpdater; $this->typeComparator = $typeComparator; } public function removeVarTagIfUseless(PhpDocInfo $phpDocInfo, Property $property) : bool { $varTagValueNode = $phpDocInfo->getVarTagValueNode(); if (!$varTagValueNode instanceof VarTagValueNode) { return \false; } $isVarTagValueDead = $this->deadVarTagValueNodeAnalyzer->isDead($varTagValueNode, $property); if (!$isVarTagValueDead) { return \false; } if ($this->phpDocTypeChanger->isAllowed($varTagValueNode->type)) { return \false; } $phpDocInfo->removeByType(VarTagValueNode::class); $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($property); return \true; } /** * @api generic */ public function removeVarTag(Node $node) : bool { $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $varTagValueNode = $phpDocInfo->getVarTagValueNode(); if (!$varTagValueNode instanceof VarTagValueNode) { return \false; } $phpDocInfo->removeByType(VarTagValueNode::class); $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); return \true; } /** * @param \PhpParser\Node\Stmt\Expression|\PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $node */ public function removeVarPhpTagValueNodeIfNotComment($node, Type $type) : void { if ($type instanceof TemplateObjectWithoutClassType) { return; } // keep doctrine collection narrow type if ($this->doctrineTypeAnalyzer->isDoctrineCollectionWithIterableUnionType($type)) { return; } $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $varTagValueNode = $phpDocInfo->getVarTagValueNode(); if (!$varTagValueNode instanceof VarTagValueNode) { return; } // has description? keep it if ($varTagValueNode->description !== '') { return; } // keep string[] etc. if ($this->phpDocTypeChanger->isAllowed($varTagValueNode->type)) { return; } // keep subtypes like positive-int if ($this->shouldKeepSubtypes($type, $phpDocInfo->getVarType())) { return; } $phpDocInfo->removeByType(VarTagValueNode::class); $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node); } private function shouldKeepSubtypes(Type $type, Type $varType) : bool { return !$this->typeComparator->areTypesEqual($type, $varType) && $this->typeComparator->isSubtype($varType, $type); } } TypelessParamTagValueNode.php 0000644 00000001552 15127755417 0012326 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use function trim; class TypelessParamTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public bool $isReference; public bool $isVariadic; public string $parameterName; /** @var string (may be empty) */ public string $description; public function __construct(bool $isVariadic, string $parameterName, string $description, bool $isReference) { $this->isReference = $isReference; $this->isVariadic = $isVariadic; $this->parameterName = $parameterName; $this->description = $description; } public function __toString(): string { $reference = $this->isReference ? '&' : ''; $variadic = $this->isVariadic ? '...' : ''; return trim("{$reference}{$variadic}{$this->parameterName} {$this->description}"); } } TypeAliasImportTagValueNode.php 0000644 00000001461 15127755417 0012622 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; use function trim; class TypeAliasImportTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public string $importedAlias; public IdentifierTypeNode $importedFrom; public ?string $importedAs = null; public function __construct(string $importedAlias, IdentifierTypeNode $importedFrom, ?string $importedAs) { $this->importedAlias = $importedAlias; $this->importedFrom = $importedFrom; $this->importedAs = $importedAs; } public function __toString(): string { return trim( "{$this->importedAlias} from {$this->importedFrom}" . ($this->importedAs !== null ? " as {$this->importedAs}" : ''), ); } } PhpDocNode.php 0000644 00000024255 15127755417 0007266 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\NodeAttributes; use function array_column; use function array_filter; use function array_map; use function implode; class PhpDocNode implements Node { use NodeAttributes; /** @var PhpDocChildNode[] */ public array $children; /** * @param PhpDocChildNode[] $children */ public function __construct(array $children) { $this->children = $children; } /** * @return PhpDocTagNode[] */ public function getTags(): array { return array_filter($this->children, static fn (PhpDocChildNode $child): bool => $child instanceof PhpDocTagNode); } /** * @return PhpDocTagNode[] */ public function getTagsByName(string $tagName): array { return array_filter($this->getTags(), static fn (PhpDocTagNode $tag): bool => $tag->name === $tagName); } /** * @return VarTagValueNode[] */ public function getVarTagValues(string $tagName = '@var'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof VarTagValueNode, ); } /** * @return ParamTagValueNode[] */ public function getParamTagValues(string $tagName = '@param'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof ParamTagValueNode, ); } /** * @return TypelessParamTagValueNode[] */ public function getTypelessParamTagValues(string $tagName = '@param'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof TypelessParamTagValueNode, ); } /** * @return ParamImmediatelyInvokedCallableTagValueNode[] */ public function getParamImmediatelyInvokedCallableTagValues(string $tagName = '@param-immediately-invoked-callable'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof ParamImmediatelyInvokedCallableTagValueNode, ); } /** * @return ParamLaterInvokedCallableTagValueNode[] */ public function getParamLaterInvokedCallableTagValues(string $tagName = '@param-later-invoked-callable'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof ParamLaterInvokedCallableTagValueNode, ); } /** * @return ParamClosureThisTagValueNode[] */ public function getParamClosureThisTagValues(string $tagName = '@param-closure-this'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof ParamClosureThisTagValueNode, ); } /** * @return PureUnlessCallableIsImpureTagValueNode[] */ public function getPureUnlessCallableIsImpureTagValues(string $tagName = '@pure-unless-callable-is-impure'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof PureUnlessCallableIsImpureTagValueNode, ); } /** * @return TemplateTagValueNode[] */ public function getTemplateTagValues(string $tagName = '@template'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof TemplateTagValueNode, ); } /** * @return ExtendsTagValueNode[] */ public function getExtendsTagValues(string $tagName = '@extends'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof ExtendsTagValueNode, ); } /** * @return ImplementsTagValueNode[] */ public function getImplementsTagValues(string $tagName = '@implements'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof ImplementsTagValueNode, ); } /** * @return UsesTagValueNode[] */ public function getUsesTagValues(string $tagName = '@use'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof UsesTagValueNode, ); } /** * @return ReturnTagValueNode[] */ public function getReturnTagValues(string $tagName = '@return'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof ReturnTagValueNode, ); } /** * @return ThrowsTagValueNode[] */ public function getThrowsTagValues(string $tagName = '@throws'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof ThrowsTagValueNode, ); } /** * @return MixinTagValueNode[] */ public function getMixinTagValues(string $tagName = '@mixin'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof MixinTagValueNode, ); } /** * @return RequireExtendsTagValueNode[] */ public function getRequireExtendsTagValues(string $tagName = '@phpstan-require-extends'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof RequireExtendsTagValueNode, ); } /** * @return RequireImplementsTagValueNode[] */ public function getRequireImplementsTagValues(string $tagName = '@phpstan-require-implements'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof RequireImplementsTagValueNode, ); } /** * @return SealedTagValueNode[] */ public function getSealedTagValues(string $tagName = '@phpstan-sealed'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof SealedTagValueNode, ); } /** * @return DeprecatedTagValueNode[] */ public function getDeprecatedTagValues(): array { return array_filter( array_column($this->getTagsByName('@deprecated'), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof DeprecatedTagValueNode, ); } /** * @return PropertyTagValueNode[] */ public function getPropertyTagValues(string $tagName = '@property'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof PropertyTagValueNode, ); } /** * @return PropertyTagValueNode[] */ public function getPropertyReadTagValues(string $tagName = '@property-read'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof PropertyTagValueNode, ); } /** * @return PropertyTagValueNode[] */ public function getPropertyWriteTagValues(string $tagName = '@property-write'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof PropertyTagValueNode, ); } /** * @return MethodTagValueNode[] */ public function getMethodTagValues(string $tagName = '@method'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof MethodTagValueNode, ); } /** * @return TypeAliasTagValueNode[] */ public function getTypeAliasTagValues(string $tagName = '@phpstan-type'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof TypeAliasTagValueNode, ); } /** * @return TypeAliasImportTagValueNode[] */ public function getTypeAliasImportTagValues(string $tagName = '@phpstan-import-type'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof TypeAliasImportTagValueNode, ); } /** * @return AssertTagValueNode[] */ public function getAssertTagValues(string $tagName = '@phpstan-assert'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof AssertTagValueNode, ); } /** * @return AssertTagPropertyValueNode[] */ public function getAssertPropertyTagValues(string $tagName = '@phpstan-assert'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof AssertTagPropertyValueNode, ); } /** * @return AssertTagMethodValueNode[] */ public function getAssertMethodTagValues(string $tagName = '@phpstan-assert'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof AssertTagMethodValueNode, ); } /** * @return SelfOutTagValueNode[] */ public function getSelfOutTypeTagValues(string $tagName = '@phpstan-this-out'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof SelfOutTagValueNode, ); } /** * @return ParamOutTagValueNode[] */ public function getParamOutTypeTagValues(string $tagName = '@param-out'): array { return array_filter( array_column($this->getTagsByName($tagName), 'value'), static fn (PhpDocTagValueNode $value): bool => $value instanceof ParamOutTagValueNode, ); } public function __toString(): string { $children = array_map( static function (PhpDocChildNode $child): string { $s = (string) $child; return $s === '' ? '' : ' ' . $s; }, $this->children, ); return "/**\n *" . implode("\n *", $children) . "\n */"; } } MethodTagValueNode.php 0000644 00000003040 15127755417 0010747 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function count; use function implode; class MethodTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public bool $isStatic; public ?TypeNode $returnType = null; public string $methodName; /** @var TemplateTagValueNode[] */ public array $templateTypes; /** @var MethodTagValueParameterNode[] */ public array $parameters; /** @var string (may be empty) */ public string $description; /** * @param MethodTagValueParameterNode[] $parameters * @param TemplateTagValueNode[] $templateTypes */ public function __construct(bool $isStatic, ?TypeNode $returnType, string $methodName, array $parameters, string $description, array $templateTypes) { $this->isStatic = $isStatic; $this->returnType = $returnType; $this->methodName = $methodName; $this->parameters = $parameters; $this->description = $description; $this->templateTypes = $templateTypes; } public function __toString(): string { $static = $this->isStatic ? 'static ' : ''; $returnType = $this->returnType !== null ? "{$this->returnType} " : ''; $parameters = implode(', ', $this->parameters); $description = $this->description !== '' ? " {$this->description}" : ''; $templateTypes = count($this->templateTypes) > 0 ? '<' . implode(', ', $this->templateTypes) . '>' : ''; return "{$static}{$returnType}{$this->methodName}{$templateTypes}({$parameters}){$description}"; } } Doctrine/DoctrineAnnotation.php 0000644 00000001227 15127755417 0012646 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\NodeAttributes; use function implode; class DoctrineAnnotation implements Node { use NodeAttributes; public string $name; /** @var list<DoctrineArgument> */ public array $arguments; /** * @param list<DoctrineArgument> $arguments */ public function __construct(string $name, array $arguments) { $this->name = $name; $this->arguments = $arguments; } public function __toString(): string { $arguments = implode(', ', $this->arguments); return $this->name . '(' . $arguments . ')'; } } Doctrine/DoctrineArrayItem.php 0000644 00000002001 15127755417 0012420 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprStringNode; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; /** * @phpstan-import-type ValueType from DoctrineArgument * @phpstan-type KeyType = ConstExprIntegerNode|ConstExprStringNode|IdentifierTypeNode|ConstFetchNode|null */ class DoctrineArrayItem implements Node { use NodeAttributes; /** @var KeyType */ public $key; /** @var ValueType */ public $value; /** * @param KeyType $key * @param ValueType $value */ public function __construct($key, $value) { $this->key = $key; $this->value = $value; } public function __toString(): string { if ($this->key === null) { return (string) $this->value; } return $this->key . '=' . $this->value; } } Doctrine/DoctrineTagValueNode.php 0000644 00000001240 15127755417 0013045 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode; use function trim; class DoctrineTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public DoctrineAnnotation $annotation; /** @var string (may be empty) */ public string $description; public function __construct( DoctrineAnnotation $annotation, string $description ) { $this->annotation = $annotation; $this->description = $description; } public function __toString(): string { return trim("{$this->annotation} {$this->description}"); } } Doctrine/DoctrineArray.php 0000644 00000001053 15127755417 0011607 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\NodeAttributes; use function implode; class DoctrineArray implements Node { use NodeAttributes; /** @var list<DoctrineArrayItem> */ public array $items; /** * @param list<DoctrineArrayItem> $items */ public function __construct(array $items) { $this->items = $items; } public function __toString(): string { $items = implode(', ', $this->items); return '{' . $items . '}'; } } Doctrine/DoctrineArgument.php 0000644 00000001504 15127755417 0012314 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; /** * @phpstan-type ValueType = DoctrineAnnotation|IdentifierTypeNode|DoctrineArray|ConstExprNode */ class DoctrineArgument implements Node { use NodeAttributes; public ?IdentifierTypeNode $key = null; /** @var ValueType */ public $value; /** * @param ValueType $value */ public function __construct(?IdentifierTypeNode $key, $value) { $this->key = $key; $this->value = $value; } public function __toString(): string { if ($this->key === null) { return (string) $this->value; } return $this->key . '=' . $this->value; } } GenericTagValueNode.php 0000644 00000000633 15127755417 0011110 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; class GenericTagValueNode implements PhpDocTagValueNode { use NodeAttributes; /** @var string (may be empty) */ public string $value; public function __construct(string $value) { $this->value = $value; } public function __toString(): string { return $this->value; } } ParamLaterInvokedCallableTagValueNode.php 0000644 00000001136 15127755417 0014523 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use function trim; class ParamLaterInvokedCallableTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public string $parameterName; /** @var string (may be empty) */ public string $description; public function __construct(string $parameterName, string $description) { $this->parameterName = $parameterName; $this->description = $description; } public function __toString(): string { return trim("{$this->parameterName} {$this->description}"); } } AssertTagPropertyValueNode.php 0000644 00000002050 15127755417 0012535 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class AssertTagPropertyValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; public string $parameter; public string $property; public bool $isNegated; public bool $isEquality; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $parameter, string $property, bool $isNegated, string $description, bool $isEquality) { $this->type = $type; $this->parameter = $parameter; $this->property = $property; $this->isNegated = $isNegated; $this->isEquality = $isEquality; $this->description = $description; } public function __toString(): string { $isNegated = $this->isNegated ? '!' : ''; $isEquality = $this->isEquality ? '=' : ''; return trim("{$isNegated}{$isEquality}{$this->type} {$this->parameter}->{$this->property} {$this->description}"); } } RequireImplementsTagValueNode.php 0000644 00000001132 15127755417 0013201 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class RequireImplementsTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->description}"); } } ThrowsTagValueNode.php 0000644 00000001117 15127755417 0011020 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class ThrowsTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->description}"); } } ParamClosureThisTagValueNode.php 0000644 00000001317 15127755417 0012761 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class ParamClosureThisTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; public string $parameterName; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $parameterName, string $description) { $this->type = $type; $this->parameterName = $parameterName; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->parameterName} {$this->description}"); } } PureUnlessCallableIsImpureTagValueNode.php 0000644 00000001137 15127755417 0014737 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use function trim; class PureUnlessCallableIsImpureTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public string $parameterName; /** @var string (may be empty) */ public string $description; public function __construct(string $parameterName, string $description) { $this->parameterName = $parameterName; $this->description = $description; } public function __toString(): string { return trim("{$this->parameterName} {$this->description}"); } } VarTagValueNode.php 0000644 00000001352 15127755417 0010263 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class VarTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; /** @var string (may be empty) */ public string $variableName; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $variableName, string $description) { $this->type = $type; $this->variableName = $variableName; $this->description = $description; } public function __toString(): string { return trim("$this->type " . trim("{$this->variableName} {$this->description}")); } } PhpDocTagNode.php 0000644 00000001215 15127755417 0007711 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\PhpDoc\Doctrine\DoctrineTagValueNode; use function trim; class PhpDocTagNode implements PhpDocChildNode { use NodeAttributes; public string $name; public PhpDocTagValueNode $value; public function __construct(string $name, PhpDocTagValueNode $value) { $this->name = $name; $this->value = $value; } public function __toString(): string { if ($this->value instanceof DoctrineTagValueNode) { return (string) $this->value; } return trim("{$this->name} {$this->value}"); } } PhpDocChildNode.php 0000644 00000000236 15127755417 0010223 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\Node; interface PhpDocChildNode extends Node { } ExtendsTagValueNode.php 0000644 00000001145 15127755417 0011145 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; use function trim; class ExtendsTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public GenericTypeNode $type; /** @var string (may be empty) */ public string $description; public function __construct(GenericTypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->description}"); } } ParamImmediatelyInvokedCallableTagValueNode.php 0000644 00000001144 15127755417 0015716 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use function trim; class ParamImmediatelyInvokedCallableTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public string $parameterName; /** @var string (may be empty) */ public string $description; public function __construct(string $parameterName, string $description) { $this->parameterName = $parameterName; $this->description = $description; } public function __toString(): string { return trim("{$this->parameterName} {$this->description}"); } } AssertTagMethodValueNode.php 0000644 00000002036 15127755417 0012135 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class AssertTagMethodValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; public string $parameter; public string $method; public bool $isNegated; public bool $isEquality; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $parameter, string $method, bool $isNegated, string $description, bool $isEquality) { $this->type = $type; $this->parameter = $parameter; $this->method = $method; $this->isNegated = $isNegated; $this->isEquality = $isEquality; $this->description = $description; } public function __toString(): string { $isNegated = $this->isNegated ? '!' : ''; $isEquality = $this->isEquality ? '=' : ''; return trim("{$isNegated}{$isEquality}{$this->type} {$this->parameter}->{$this->method}() {$this->description}"); } } ReturnTagValueNode.php 0000644 00000001117 15127755417 0011011 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class ReturnTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->description}"); } } AssertTagValueNode.php 0000644 00000001701 15127755417 0010772 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class AssertTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; public string $parameter; public bool $isNegated; public bool $isEquality; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $parameter, bool $isNegated, string $description, bool $isEquality) { $this->type = $type; $this->parameter = $parameter; $this->isNegated = $isNegated; $this->isEquality = $isEquality; $this->description = $description; } public function __toString(): string { $isNegated = $this->isNegated ? '!' : ''; $isEquality = $this->isEquality ? '=' : ''; return trim("{$isNegated}{$isEquality}{$this->type} {$this->parameter} {$this->description}"); } } PhpDocTagValueNode.php 0000644 00000000241 15127755417 0010704 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\Node; interface PhpDocTagValueNode extends Node { } TypeAliasTagValueNode.php 0000644 00000001021 15127755417 0011417 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class TypeAliasTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public string $alias; public TypeNode $type; public function __construct(string $alias, TypeNode $type) { $this->alias = $alias; $this->type = $type; } public function __toString(): string { return trim("{$this->alias} {$this->type}"); } } ParamOutTagValueNode.php 0000644 00000001307 15127755417 0011263 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class ParamOutTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; public string $parameterName; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $parameterName, string $description) { $this->type = $type; $this->parameterName = $parameterName; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->parameterName} {$this->description}"); } } SelfOutTagValueNode.php 0000644 00000001122 15127755417 0011107 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class SelfOutTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString(): string { return trim($this->type . ' ' . $this->description); } } MethodTagValueParameterNode.php 0000644 00000002224 15127755417 0012613 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode; use PHPStan\PhpDocParser\Ast\Node; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; class MethodTagValueParameterNode implements Node { use NodeAttributes; public ?TypeNode $type = null; public bool $isReference; public bool $isVariadic; public string $parameterName; public ?ConstExprNode $defaultValue = null; public function __construct(?TypeNode $type, bool $isReference, bool $isVariadic, string $parameterName, ?ConstExprNode $defaultValue) { $this->type = $type; $this->isReference = $isReference; $this->isVariadic = $isVariadic; $this->parameterName = $parameterName; $this->defaultValue = $defaultValue; } public function __toString(): string { $type = $this->type !== null ? "{$this->type} " : ''; $isReference = $this->isReference ? '&' : ''; $isVariadic = $this->isVariadic ? '...' : ''; $default = $this->defaultValue !== null ? " = {$this->defaultValue}" : ''; return "{$type}{$isReference}{$isVariadic}{$this->parameterName}{$default}"; } } ParamTagValueNode.php 0000644 00000001734 15127755417 0010577 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class ParamTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; public bool $isReference; public bool $isVariadic; public string $parameterName; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, bool $isVariadic, string $parameterName, string $description, bool $isReference) { $this->type = $type; $this->isReference = $isReference; $this->isVariadic = $isVariadic; $this->parameterName = $parameterName; $this->description = $description; } public function __toString(): string { $reference = $this->isReference ? '&' : ''; $variadic = $this->isVariadic ? '...' : ''; return trim("{$this->type} {$reference}{$variadic}{$this->parameterName} {$this->description}"); } } UsesTagValueNode.php 0000644 00000001142 15127755417 0010447 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; use function trim; class UsesTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public GenericTypeNode $type; /** @var string (may be empty) */ public string $description; public function __construct(GenericTypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->description}"); } } PhpDocTextNode.php 0000644 00000000553 15127755417 0010126 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; class PhpDocTextNode implements PhpDocChildNode { use NodeAttributes; public string $text; public function __construct(string $text) { $this->text = $text; } public function __toString(): string { return $this->text; } } TemplateTagValueNode.php 0000644 00000002215 15127755417 0011305 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class TemplateTagValueNode implements PhpDocTagValueNode { use NodeAttributes; /** @var non-empty-string */ public string $name; public ?TypeNode $bound; public ?TypeNode $default; public ?TypeNode $lowerBound; /** @var string (may be empty) */ public string $description; /** * @param non-empty-string $name */ public function __construct(string $name, ?TypeNode $bound, string $description, ?TypeNode $default = null, ?TypeNode $lowerBound = null) { $this->name = $name; $this->bound = $bound; $this->lowerBound = $lowerBound; $this->default = $default; $this->description = $description; } public function __toString(): string { $upperBound = $this->bound !== null ? " of {$this->bound}" : ''; $lowerBound = $this->lowerBound !== null ? " super {$this->lowerBound}" : ''; $default = $this->default !== null ? " = {$this->default}" : ''; return trim("{$this->name}{$upperBound}{$lowerBound}{$default} {$this->description}"); } } PropertyTagValueNode.php 0000644 00000001303 15127755417 0011353 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class PropertyTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; public string $propertyName; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $propertyName, string $description) { $this->type = $type; $this->propertyName = $propertyName; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->propertyName} {$this->description}"); } } DeprecatedTagValueNode.php 0000644 00000000725 15127755417 0011576 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use function trim; class DeprecatedTagValueNode implements PhpDocTagValueNode { use NodeAttributes; /** @var string (may be empty) */ public string $description; public function __construct(string $description) { $this->description = $description; } public function __toString(): string { return trim($this->description); } } InvalidTagValueNode.php 0000644 00000002244 15127755417 0011122 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Parser\ParserException; use function sprintf; use function trigger_error; use const E_USER_WARNING; /** * @property ParserException $exception */ class InvalidTagValueNode implements PhpDocTagValueNode { use NodeAttributes; /** @var string (may be empty) */ public string $value; /** @var mixed[] */ private array $exceptionArgs; public function __construct(string $value, ParserException $exception) { $this->value = $value; $this->exceptionArgs = [ $exception->getCurrentTokenValue(), $exception->getCurrentTokenType(), $exception->getCurrentOffset(), $exception->getExpectedTokenType(), $exception->getExpectedTokenValue(), $exception->getCurrentTokenLine(), ]; } public function __get(string $name): ?ParserException { if ($name !== 'exception') { trigger_error(sprintf('Undefined property: %s::$%s', self::class, $name), E_USER_WARNING); return null; } return new ParserException(...$this->exceptionArgs); } public function __toString(): string { return $this->value; } } RequireExtendsTagValueNode.php 0000644 00000001127 15127755417 0012502 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class RequireExtendsTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->description}"); } } MixinTagValueNode.php 0000644 00000001116 15127755417 0010615 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class MixinTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->description}"); } } SealedTagValueNode.php 0000644 00000001117 15127755417 0010727 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use function trim; class SealedTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public TypeNode $type; /** @var string (may be empty) */ public string $description; public function __construct(TypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->description}"); } } ImplementsTagValueNode.php 0000644 00000001150 15127755417 0011644 0 ustar 00 <?php declare(strict_types = 1); namespace PHPStan\PhpDocParser\Ast\PhpDoc; use PHPStan\PhpDocParser\Ast\NodeAttributes; use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode; use function trim; class ImplementsTagValueNode implements PhpDocTagValueNode { use NodeAttributes; public GenericTypeNode $type; /** @var string (may be empty) */ public string $description; public function __construct(GenericTypeNode $type, string $description) { $this->type = $type; $this->description = $description; } public function __toString(): string { return trim("{$this->type} {$this->description}"); } }
| ver. 1.6 |
Github
|
.
| PHP 8.2.30 | ??????????? ?????????: 0 |
proxy
|
phpinfo
|
???????????