Ejemplo n.º 1
0
 protected function _parse($comment)
 {
     $meta = array();
     $pattern = "(@[a-zA-Z]+\\s*[a-zA-Z0-9, ()_]*)";
     $matches = StringMethods::match($comment, $pattern);
     if ($matches != null) {
         foreach ($matches as $match) {
             $parts = ArrayMethods::clean(ArrayMethods::trim(StringMethods::split($match, "[\\s]", 2)));
             $meta[$parts[0]] = true;
             if (sizeof($parts) > 1) {
                 $meta[$parts[0]] = ArrayMethods::clean(ArrayMethods::trim(StringMethods::split($parts[1], ",")));
             }
         }
     }
     return $meta;
 }
Ejemplo n.º 2
0
 public function __call($name, $arguments)
 {
     if (empty($this->_inspector)) {
         throw new Exception("Call parent::__construct!");
     }
     // verifica se existem comandos getVariavel
     $getMatches = StringMethods::match($name, "^get([a-zA-Z0-9]+)\$");
     if (sizeof($getMatches) > 0) {
         // verifica qual propriedade esta sendo manipulada
         $normalized = lcfirst($getMatches[0]);
         $property = "_{$normalized}";
         if (property_exists($this, $property)) {
             $meta = $this->_inspector->getPropertyMeta($property);
             // se não tiver marcação definida
             if (empty($meta["@readwrite"]) && empty($meta["@read"])) {
                 throw $this->_getExceptionForWriteonly($normalized);
             }
             if (isset($this->{$property})) {
                 return $this->{$property};
             }
             return null;
         }
     }
     // verifica se existem comandos setVariavel
     $setMatches = StringMethods::match($name, "^set([a-zA-Z0-9]+)\$");
     if (sizeof($setMatches) > 0) {
         // verifica qual propriedade esta sendo manipulada
         $normalized = lcfirst($setMatches[0]);
         $property = "_{$normalized}";
         if (property_exists($this, $property)) {
             $meta = $this->_inspector->getPropertyMeta($property);
             // se não tiver marcação definida
             if (empty($meta["@readwrite"]) && empty($meta["@write"])) {
                 throw $this->_getExceptionForReadonly($normalized);
             }
             $this->{$property} = $arguments[0];
             return $this;
         }
     }
     // se a propriedade não existir
     throw $this->_getExceptionForImplementation($name);
 }