コード例 #1
0
 /**
  * @param mixed $val the value
  * @return PC_Obj_MultiType the type
  */
 protected function get_type_from_php($val)
 {
     if (is_array($val)) {
         return new PC_Obj_MultiType(PC_Obj_Type::get_type_by_value($val));
     } else {
         $type = PC_Obj_Type::get_type_by_name(gettype($val));
         return new PC_Obj_MultiType(new PC_Obj_Type($type->get_type(), $val));
     }
 }
コード例 #2
0
 /**
  * Builds the MultiType-instance from the given name. '|' will be assumed as separator
  * of the types.
  *
  * @param string $name the name
  * @return PC_Obj_MultiType the instance
  */
 public static function get_type_by_name($name)
 {
     $types = explode('|', $name);
     $ts = array();
     foreach ($types as $type) {
         $type = trim($type);
         $typeobj = PC_Obj_Type::get_type_by_name($type);
         if ($typeobj !== null) {
             $ts[] = $typeobj;
         }
     }
     return new PC_Obj_MultiType($ts);
 }