Ejemplo n.º 1
0
 public function visitTypeAttributeEnter(PiBX_AST_Tree $tree)
 {
     if ($tree->countChildren() == 0) {
         // base type attribute
         $attributeName = PiBX_Binding_Names::getAttributeName($tree->getName());
         $methodName = PiBX_Binding_Names::getCamelCasedName($tree->getName());
         $this->currentClassAttributes .= "\tprivate \$" . $attributeName . ";\n";
         $type = $tree->getType();
         $methods = "\tpublic function set" . $methodName . "(";
         if (!PiBX_ParseTree_BaseType::isBaseType($type)) {
             // complexTypes (i.e. classes) have to be type-hinted
             // in the method signature.
             $expectedType = PiBX_Binding_Names::createClassnameFor($type);
             $methods .= $expectedType . ' ';
         }
         $methods .= "\$" . $attributeName . ") {\n";
         if ($this->doTypeChecks) {
             $methods .= $this->typeChecks->getTypeCheckFor($tree->getType(), $attributeName);
         }
         $methods .= "\t\t\$this->" . $attributeName . " = \$" . $attributeName . ";\n" . "\t}\n" . "\tpublic function get" . $methodName . "() {\n" . "\t\treturn \$this->" . $attributeName . ";\n" . "\t}\n";
         $this->currentClassMethods .= $methods;
         return false;
     } else {
         return true;
     }
 }