|
@@ -81,7 +81,7 @@ class SchemaSnippetsMaker
|
|
|
|
|
|
|
|
$class->addMember($prop);
|
|
$class->addMember($prop);
|
|
|
|
|
|
|
|
- $methods = [...$methods, ...$this->makeMethodsSnippetForProp($field, $prop) ];
|
|
|
|
|
|
|
+ $methods = [...$methods, ...$this->makeMethodsSnippetForProp($prop)];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
foreach ($methods as $method) {
|
|
foreach ($methods as $method) {
|
|
@@ -108,11 +108,16 @@ class SchemaSnippetsMaker
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- protected function makeMethodsSnippetForProp(string $field, Property $prop): array {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Make the getters / setters for the given property
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param Property $prop
|
|
|
|
|
+ * @return array<Method>
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function makeMethodsSnippetForProp(Property $prop): array {
|
|
|
$methods = [];
|
|
$methods = [];
|
|
|
|
|
|
|
|
- if ($prop->getType() !== 'Collection')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if ($prop->getType() !== 'Collection') {
|
|
|
$methods[] = $this->makeSnippetGetterForProp($prop);
|
|
$methods[] = $this->makeSnippetGetterForProp($prop);
|
|
|
$methods[] = $this->makeSnippetSetterForProp($prop);
|
|
$methods[] = $this->makeSnippetSetterForProp($prop);
|
|
|
} else {
|
|
} else {
|
|
@@ -198,9 +203,13 @@ class SchemaSnippetsMaker
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$printer = new PsrPrinter;
|
|
$printer = new PsrPrinter;
|
|
|
|
|
+
|
|
|
|
|
+ $content = $printer->printFile($phpFile);
|
|
|
|
|
+ $content = $this->postProcessFileContent($content);
|
|
|
|
|
+
|
|
|
$f = fopen($fileName, 'w+');
|
|
$f = fopen($fileName, 'w+');
|
|
|
try {
|
|
try {
|
|
|
- fwrite($f, $printer->printFile($phpFile));
|
|
|
|
|
|
|
+ fwrite($f, $content);
|
|
|
} finally {
|
|
} finally {
|
|
|
fclose($f);
|
|
fclose($f);
|
|
|
}
|
|
}
|
|
@@ -518,4 +527,17 @@ class SchemaSnippetsMaker
|
|
|
);
|
|
);
|
|
|
return $method;
|
|
return $method;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Perform some post-fixes on the file content
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $content
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function postProcessFileContent(string $content): string
|
|
|
|
|
+ {
|
|
|
|
|
+ return preg_replace("/targetEntity: '(\w+)::class'/", "targetEntity: $1::class", $content);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|