/** * Handles the given unary-operator. Note that its needed for static-scalars in the type-scanner, * which is the reason why its here. * * @param string $op the operator (+,-,...) * @param PC_Obj_MultiType $type the expression * @return PC_Obj_MultiType the result */ public function handle_unary_op($op, $type) { if ($type->is_array_unknown()) { return $this->get_type_from_op($op, $type); } $res = 0; eval('$res = ' . $op . $type->get_first()->get_value_for_eval() . ';'); return $this->get_type_from_php($res); }
/** * Handles a cast * * @param string $cast the cast-type: 'int','float','string','array','object','bool' or 'unset' * @param PC_Obj_MultiType $e the expression * @return PC_Obj_MultiType the result */ public function handle_cast($cast, $e) { if (!$e instanceof PC_Obj_MultiType) { return $this->handle_error('$e is invalid'); } // unset casts to null. in this case we don't really know the value // object-cast make no sense here, I think if ($cast == 'unset' || $cast == 'object') { return $this->create_unknown(); } // if we don't know the type or value, just provide the type; in loops as well if ($this->vars->is_in_loop() || $e->is_array_unknown()) { return PC_Obj_MultiType::get_type_by_name($cast); } // we know the value, so perform a cast $res = 0; eval('$res = (' . $cast . ')' . $e->get_first()->get_value_for_eval() . ';'); return $this->get_type_from_php($res); }