public function compile(GClass $gClass, $flags = 0) { $this->createClassBuilder($gClass); // collectionProperty $collection = $this->createPropertyIfNotExists($this->propertyPlural, $this->collectionType); if ($this->collectionType->hasScalarDefaultValue()) { $collection->setDefaultValue($this->collectionType->getDefaultValue()); } //else: eigentlich in den Constructor hacken $this->classBuilder->generateGetter($collection); $this->classBuilder->generateSetter($collection); $item = $this->getItem(); $this->codeVars = array('collection' => $collection->getName(), 'item' => $item->lcSingular, 'ucItem' => $item->ucSingular, 'strict' => 'TRUE'); $paramAnnotation = 'param ' . $item->docType . ' $' . $item->lcSingular; $gClass->createMethod('get' . $item->ucSingular, array(new GParameter('key')), $this->getImplementation('itemGetter'))->createDocBlock()->addSimpleAnnotation('param integer $key 0-based')->addSimpleAnnotation('return ' . $item->docType . '|NULL'); $gClass->createMethod('add' . $item->ucSingular, array(new GParameter($item->lcSingular, $item->hint)), $this->getImplementation('itemAdder'))->createDocBlock()->addSimpleAnnotation($paramAnnotation)->addSimpleAnnotation('chainable'); $gClass->createMethod('remove' . $item->ucSingular, array(new GParameter($item->lcSingular, $item->hint)), $this->getImplementation('itemRemover'))->createDocBlock()->addSimpleAnnotation($paramAnnotation)->addSimpleAnnotation('chainable'); $gClass->createMethod('has' . $item->ucSingular, array(new GParameter($item->lcSingular, $item->hint)), $this->getImplementation('itemChecker'))->createDocBlock()->addSimpleAnnotation($paramAnnotation)->addSimpleAnnotation('return bool'); $this->classBuilder->generateDocBlocks(); }