/** * Generates the actual interfaces */ public function generate() { $interfacesData = json_decode($this->json, true); foreach ($interfacesData as $interface) { $filename = $interface['name'] . '.java'; $interfaceObject = new JAVAInterfaceObject(); $interfaceObject->setName($interface['name']); foreach ($interface['methods'] as $method) { $methodObject = new JAVAMethod(); $methodObject->setName($method['name']); $methodObject->setReturnValue($method['returnType']); $methodObject->setScope($method['scope']); $methodObject->setComment($method['comment']); foreach ($method['parameters'] as $parameter) { $parameterObject = new Parameter(); $parameterObject->setName($parameter['name']); $parameterObject->setType($parameter['type']); $methodObject->addParameter($parameterObject); } foreach ($method['annotations'] as $annotation) { $annotationObject = new Annotation(); $annotationObject->setName($annotation['name']); $annotationObject->setValue($annotation['value']); $annotationObject->setInterpreter('@'); $methodObject->addAnnotation($annotationObject); } $interfaceObject->addMethod($methodObject); } file_put_contents($this->folder . DIRECTORY_SEPARATOR . $filename, $interfaceObject->toString()); } }
public function getAnnotations($docComment) { $result = new AnnotationCollection(); if (preg_match_all('/@(.*?)\\n/is', $docComment, $matches)) { array_shift($matches); foreach ($matches[0] as $match) { $parts = explode(' ', $match); $x = new Annotation(); $x->setName($parts[0]); if (count($parts) > 1) { for ($i = 1; $i != count($parts); $i++) { $x->addValue($parts[$i]); } } $result->add($x); } } return $result; }