public function testValidManagerWhenInvalidMethod() { $methods = $this->interfaceManager->getMethods(); $methods->add(new MethodGetterInterfaceManager($this->interfaceManager->getClassManager())); // broken method $this->interfaceManager->setMethods($methods); $errors = $this->getValidator()->validate($this->interfaceManager); $this->assertEquals(1, $errors->count()); }
/** * @param InterfaceManager $interface * @return string * @throws RendererException */ protected function renderInterface(InterfaceManager $interface) { $template = $interface->getTemplate(); $tags = $interface->getTemplateTags(); $methods = []; foreach ($interface->getMethods() as $method) { $methods[] = $this->render($method); } $args[RenderableInterface::TAG_NAMESPACE] = $interface->getNamespaceWithoutNameAndBackslashPrefix(); $args[RenderableInterface::TAG_COMMENT] = $interface->getComment(); $args[RenderableInterface::TAG_NAME] = $interface->getName(); $args[RenderableInterface::TAG_METHODS] = Tools::implodeArrayToTemplate($methods); return $this->addNewLineAfter($this->replace($tags, $args, $template)); }
/** * @param InterfaceManager $item * @param ReflectionClass $reflectionClass * @return InterfaceManager */ protected function resolveInterfaceContent(InterfaceManager $item, ReflectionClass $reflectionClass) { $item->setMethods($this->resolveMethodsToRender($item, $reflectionClass)); return $item; }
/** * Generate methods for interface * * @param InterfaceManager $interface * @return ArrayCollection */ protected function generateAndFillInterfaceMethods(InterfaceManager $interface) { $methodsForInterface = new ArrayCollection(); $classManager = $interface->getClassManager(); foreach ($classManager->getProperties() as $property) { if ($property->isTypeBoolean()) { $methodsForInterface->add((new MethodGetterBooleanInterfaceManager($classManager))->setProperty($property)); } $methodSetterInterfaceManager = new MethodSetterInterfaceManager($classManager); $methodSetterInterfaceManager->setProperty($property); $methodGetterInterfaceManager = new MethodGetterInterfaceManager($classManager); $methodGetterInterfaceManager->setProperty($property); $methodsForInterface->add($methodSetterInterfaceManager); $methodsForInterface->add($methodGetterInterfaceManager); } $interface->setMethods($methodsForInterface); return $interface; }