@@ -352,10 +352,6 @@ public function addProperty(string $name, array $annotationLines = [], $defaultV
352
352
353
353
$ newPropertyBuilder = (new Builder \Property ($ name ))->makePrivate ();
354
354
355
- // if ($annotationLines && $this->useAnnotations) {
356
- // $newPropertyBuilder->setDocComment($this->createDocBlock($annotationLines));
357
- // }
358
-
359
355
if ($ this ->useAttributesForDoctrineMapping ) {
360
356
foreach ($ attributes as $ attribute ) {
361
357
$ newPropertyBuilder ->addAttribute ($ attribute );
@@ -929,6 +925,31 @@ public function addUseStatementIfNecessary(string $class): string
929
925
return $ shortClassName ;
930
926
}
931
927
928
+ /**
929
+ * Builds a PHPParser attribute node.
930
+ *
931
+ * @param ClassNameDetails $attributeClass The attribute class which should be used for the attribute. If the class has a substitute
932
+ * prefix, the node is built using the prefix. E.g. #[ORM\Column()] Otherwise, the
933
+ * short name is used. E.g. #[Column()]
934
+ * @param array $options the named arguments for the attribute ($key = argument name, $value = argument value)
935
+ */
936
+ public function buildAttributeNode (ClassNameDetails $ attributeClass , array $ options ): Node \Attribute
937
+ {
938
+ $ options = $ this ->sortOptionsByClassConstructorParameters ($ options , $ attributeClass ->getFullName ());
939
+
940
+ $ context = $ this ;
941
+ $ nodeArguments = array_map (static function ($ option , $ value ) use ($ context ) {
942
+ return new Node \Arg ($ context ->buildNodeExprByValue ($ value ), false , false , [], new Node \Identifier ($ option ));
943
+ }, array_keys ($ options ), array_values ($ options ));
944
+
945
+ $ class = $ attributeClass ->hasSubstitutePrefix () ? $ attributeClass ->getShortNameWithSubstitutePrefix () : $ attributeClass ->getShortName ();
946
+
947
+ return new Node \Attribute (
948
+ new Node \Name ($ class ),
949
+ $ nodeArguments
950
+ );
951
+ }
952
+
932
953
private function updateSourceCodeFromNewStmts (): void
933
954
{
934
955
$ newCode = $ this ->printer ->printFormatPreserving (
@@ -1450,29 +1471,6 @@ private function buildNodeExprByValue($value): Node\Expr
1450
1471
return $ nodeValue ;
1451
1472
}
1452
1473
1453
- /**
1454
- * builds an PHPParser attribute node.
1455
- *
1456
- * @param ClassNameDetails $attributeClass the attribute class which should be used for the attribute
1457
- * @param array $options the named arguments for the attribute ($key = argument name, $value = argument value)
1458
- */
1459
- public function buildAttributeNode (ClassNameDetails $ attributeClass , array $ options ): Node \Attribute
1460
- {
1461
- $ options = $ this ->sortOptionsByClassConstructorParameters ($ options , $ attributeClass ->getFullName ());
1462
-
1463
- $ context = $ this ;
1464
- $ nodeArguments = array_map (static function ($ option , $ value ) use ($ context ) {
1465
- return new Node \Arg ($ context ->buildNodeExprByValue ($ value ), false , false , [], new Node \Identifier ($ option ));
1466
- }, array_keys ($ options ), array_values ($ options ));
1467
-
1468
- $ class = $ attributeClass ->hasSubstitutePrefix () ? $ attributeClass ->getShortNameWithSubstitutePrefix () : $ attributeClass ->getShortName ();
1469
-
1470
- return new Node \Attribute (
1471
- new Node \Name ($ class ),
1472
- $ nodeArguments
1473
- );
1474
- }
1475
-
1476
1474
/**
1477
1475
* sort the given options based on the constructor parameters for the given $classString
1478
1476
* this prevents code inspections warnings for IDEs like intellij/phpstorm.
0 commit comments