예제 #1
0
파일: source.php 프로젝트: jaz303/phpx
 public function __call($method, $args)
 {
     // Existence check
     if (preg_match('/^(constant|variable|method)_defined$/', $method, $match)) {
         return $this->index_contains($match[0], $args[0]);
     }
     // Collections
     if (preg_match('/^(constant|variable|method)s$/', $method, $match)) {
         return $this->index_to_array($match[0]);
     }
     //
     // Index manipulation
     $words = explode('_', $method);
     if (count($words) >= 2) {
         $verb = array_shift($words);
         $type = array_pop($words);
         if (in_array($type, array('constant', 'variable', 'method'))) {
             switch ($verb) {
                 case 'define':
                     $this->with_access(new Access(implode(' ', $words)), function ($class) use($type, $args) {
                         call_user_func_array(array($class, "define_{$type}"), $args);
                     });
                     return;
                 case 'add':
                     $this->add_to_index($type, $args[0]);
                     return;
                 case 'remove':
                     return $this->index_remove($type, $args[0]);
             }
         }
     }
     //
     // Delegate anything else to the macro system
     Macro::apply($method, $this, $args);
 }