Пример #1
0
 function __construct()
 {
     // GET THE CORRECT CLASSNAME, WITHOUT NAMESPACE
     $this->modelName = getClassFromNamespace(get_class($this)) . "s";
     // MAKE A NEW CONNECTION
     $this->connection = DB::_open($this->modelName);
 }
 private function __construct($class, $method)
 {
     $ref = new ReflectionMethod($class, $method);
     $parameters = $ref->getParameters();
     // SETTING UP NUMBER OF PARAMETERS
     if (($this->countParams = count($parameters)) > 0) {
         $this->name = array();
         $this->isOptional = array();
         $this->defaultValue = array();
         $this->classFullName = array();
         $this->className = array();
         $this->classNameCount = array();
     }
     foreach ($parameters as $index => $param) {
         // SETTING UP PARAMETER NAME
         $this->name[$index] = $param->getName();
         if (!is_null($param->getClass())) {
             $this->classFullName[$index] = $param->getClass()->name;
             $this->className[$index] = getClassFromNamespace($this->classFullName[$index]);
             if (!isset($this->classNameCount[$this->className[$index]])) {
                 $this->classNameCount[$this->className[$index]] = 0;
             }
             if (!isset($this->classOccurencies[$this->className[$index]])) {
                 $this->classOccurencies[$this->className[$index]] = array();
             }
             $this->classOccurencies[$this->className[$index]][$index] = $index;
             $this->classNameCount[$this->className[$index]]++;
         }
         //if($param->isOptional()){
         if ($param->isDefaultValueAvailable()) {
             $this->countOptionalParams++;
             $this->isOptional[$index] = true;
             $this->defaultValue[$index] = $param->getDefaultValue();
         } else {
             $this->isOptional[$index] = false;
         }
     }
     $this->countNecessaryParams = $this->countParams - $this->countOptionalParams;
 }