Skip to content

Commit 6924ced

Browse files
committed
TASK: Do note generate Annotations when type hints suffice
1 parent 25d1c68 commit 6924ced

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

Classes/Command/NodetypeObjectsCommandController.php

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,43 +123,52 @@ private function buildOne(FlowPackageInterface $package, NodeType $nodeType, str
123123
}
124124
$type = $propertyConfig[ 'type' ];
125125

126-
$annotationType = $type;
126+
$annotationType = null;
127127
$phpType = $type;
128128

129129
if (str_ends_with($type, '[]')) {
130+
$annotationType = $type;
130131
$phpType = 'array';
131132
} elseif (str_starts_with($type, 'array<') && str_ends_with($type, '>')) {
132133
$annotationType = substr($type , 6 ,-1) . '[]';
133134
$phpType = 'array';
134135
} elseif ($type === 'boolean') {
135136
$phpType = 'bool';
136-
$annotationType = 'bool';
137137
} elseif ($type === 'integer') {
138138
$phpType = 'int';
139-
$annotationType = 'int';
140139
} elseif ($type === 'DateTime') {
141140
$phpType = '\DateTime';
142-
$annotationType = '\DateTime';
143141
}
144142

145143
if (str_contains($phpType, '\\') && !str_starts_with($phpType, '\\')) {
146144
$phpType = '\\' . $phpType;
147145
}
148-
if (str_contains($annotationType, '\\') && !str_starts_with($annotationType, '\\')) {
146+
if (is_string($annotationType) && str_contains($annotationType, '\\') && !str_starts_with($annotationType, '\\')) {
149147
$annotationType = '\\' . $annotationType;
150148
}
151149

152-
$propertyAccesssors .= <<<EOL
150+
if ($annotationType) {
151+
$propertyAccesssors .= <<<EOL
153152
154153
155-
/**
156-
* @return $annotationType;
157-
*/
158-
public function $methodName(): ?$phpType
159-
{
160-
return \$this->node->getProperty('$propertyName');
161-
}
162-
EOL;
154+
/**
155+
* @return ?$annotationType;
156+
*/
157+
public function $methodName(): ?$phpType
158+
{
159+
return \$this->node->getProperty('$propertyName');
160+
}
161+
EOL;
162+
} else {
163+
$propertyAccesssors .= <<<EOL
164+
165+
166+
public function $methodName(): ?$phpType
167+
{
168+
return \$this->node->getProperty('$propertyName');
169+
}
170+
EOL;
171+
}
163172
}
164173

165174
$nodeTypeName = $nodeType->getName();

0 commit comments

Comments
 (0)