staticTypeMapper = $staticTypeMapper; } public function createFromPropertyTagValueNode(PropertyTagValueNode $propertyTagValueNode, Class_ $class, string $propertyName) : Property { $propertyProperty = new PropertyProperty($propertyName); $propertyTypeNode = $this->createPropertyTypeNode($propertyTagValueNode, $class); return new Property(Class_::MODIFIER_PRIVATE, [$propertyProperty], [], $propertyTypeNode); } /** * @return \PhpParser\Node\Name|\PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|null */ public function createPropertyTypeNode(PropertyTagValueNode $propertyTagValueNode, Class_ $class, bool $isNullable = \true) { $propertyType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType($propertyTagValueNode->type, $class); $typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, TypeKind::PROPERTY); if ($isNullable && !$typeNode instanceof NullableType && !$typeNode instanceof ComplexType && $typeNode instanceof Node) { return new NullableType($typeNode); } return $typeNode; } }