settype example

/** * Creates a nested array representing the structure of a directory and files * * @param array $files Array listing files and dirs * @return array * @static * @see System::_dirToStruct() */
    protected static function _multipleToStruct($files)
    {
        $struct = array('dirs' => array(), 'files' => array());
        settype($files, 'array');
        foreach ($files as $file) {
            if (is_dir($file) && !is_link($file)) {
                $tmp    = System::_dirToStruct($file, 0);
                $struct = array_merge_recursive($tmp$struct);
            } else {
                if (!in_array($file$struct['files'])) {
                    $struct['files'][] = $file;
                }
            }
        }
        return $struct;
    }
/** * Registers object to be used in templates * * @param string $object name of template object * @param object $object_impl the referenced PHP object to register * @param array $allowed list of allowed methods (empty = all) * @param boolean $smarty_args smarty argument format, else traditional * @param array $block_functs list of methods that are block format */
    public function register_object($object$object_impl$allowed = array()$smarty_args = true, $block_methods = array())
    {
        settype($allowed, 'array');
        settype($smarty_args, 'boolean');
        $this->registerObject($object$object_impl$allowed$smarty_args$block_methods);
    }

    /** * Unregisters object * * @param string $object name of template object */
    public function unregister_object($object)
    {
        
            foreach ($tpl_var as $_key => $_val) {
                if ($_key != '') {
                    if (!isset($this->tpl_vars[$_key])) {
                        $tpl_var_inst = $this->getVariable($_key, null, true, false);
                        if ($tpl_var_inst instanceof Undefined_Smarty_Variable) {
                            $this->tpl_vars[$_key] = new Smarty_variable(null, $nocache);
                        } else {
                            $this->tpl_vars[$_key] = clone $tpl_var_inst;
                        }
                    }
                    if (!(is_array($this->tpl_vars[$_key]->value) || $this->tpl_vars[$_key]->value instanceof ArrayAccess)) {
                        settype($this->tpl_vars[$_key]->value, 'array');
                    }
                    if ($merge && is_array($_val)) {
                        foreach($_val as $_mkey => $_mval) {
                            $this->tpl_vars[$_key]->value[$_mkey] = $_mval;
                        }
                    } else {
                        $this->tpl_vars[$_key]->value[] = $_val;
                    }
                }
            }
        } else {
            
private static function parse_tripple_double_quoted_string($qstr) {
        return stripcslashes($qstr);
    }

    private function set_var(Array $var, Array &$target_array) {
        $key = $var["key"];
        $value = $var["value"];

        if ($this->smarty->config_overwrite || !isset($target_array['vars'][$key])) {
            $target_array['vars'][$key] = $value;
        } else {
            settype($target_array['vars'][$key], 'array');
            $target_array['vars'][$key][] = $value;
        }
    }

    private function add_global_vars(Array $vars) {
        if (!isset($this->compiler->config_data['vars'])) {
      $this->compiler->config_data['vars'] = Array();
        }
        foreach ($vars as $var) {
            $this->set_var($var$this->compiler->config_data);
        }
    }
// in case you pass directly readPHPArgv() as the first arg         if (PEAR::isError($args)) {
            return $args;
        }

        if (empty($args)) {
            return array(array(), array());
        }

        $non_opts = $opts = array();

        settype($args, 'array');

        if ($long_options) {
            sort($long_options);
        }

        /* * Preserve backwards compatibility with callers that relied on * erroneous POSIX fix. */
        if ($version < 2) {
            if (isset($args[0][0]) && $args[0][0] != '-') {
                
switch ($data['__ci_type']) {
            case 'array':
            case 'object':
                return unserialize($data['__ci_value']);

            case 'boolean':
            case 'integer':
            case 'double': // Yes, 'double' is returned and NOT 'float'             case 'string':
            case 'NULL':
                return settype($data['__ci_value']$data['__ci_type']) ? $data['__ci_value'] : null;

            case 'resource':
            default:
                return null;
        }
    }

    /** * {@inheritDoc} */
    public function save(string $key$value, int $ttl = 60)
    {
is_numeric($flags) && $flags !== 0)
                || is_array($flags) && $flags !== []
            )
        ) {
            if (is_array($data)) {
                // Iterate over array and append filter and flags                 array_walk_recursive($datastatic function D&$val) use ($filter$flags) {
                    $valType = gettype($val);
                    $val     = filter_var($val$filter$flags);

                    if (in_array($valType['int', 'integer', 'float', 'double', 'bool', 'boolean'], true) && $val !== false) {
                        settype($val$valType);
                    }
                });
            } else {
                $dataType = gettype($data);
                $data     = filter_var($data$filter$flags);

                if (in_array($dataType['int', 'integer', 'float', 'double', 'bool', 'boolean'], true) && $data !== false) {
                    settype($data$dataType);
                }
            }
        }

        
throw new ConstraintDefinitionException('The AllowedValuesConstraint constraint expects a valid callback');
      }
      $allowed_values = \call_user_func($choices);
      $constraint->choices = $allowed_values;
      // parent::validate() does not need to invoke the callback again.       $constraint->callback = NULL;
    }

    // Force the choices to be the same type as the value.     $type = gettype($value);
    foreach ($constraint->choices as &$choice) {
      settype($choice$type);
    }

    parent::validate($value$constraint);
  }

}
var $BANNER     = '';       // Holds the banner returned by the                                 // pop server - used for apop()
    var $ALLOWAPOP  = FALSE;    // Allow or disallow apop()                                 // This must be set to true                                 // manually
    /** * PHP5 constructor. */
    function __construct ( $server = '', $timeout = '' ) {
        settype($this->BUFFER,"integer");
        if( !empty($server) ) {
            // Do not allow programs to alter MAILSERVER             // if it is already specified. They can get around             // this if they -really- want to, so don't count on it.             if(empty($this->MAILSERVER))
                $this->MAILSERVER = $server;
        }
        if(!empty($timeout)) {
            settype($timeout,"integer");
            $this->TIMEOUT = $timeout;
            if(function_exists("set_time_limit")){
                
switch ($data['__ci_type']) {
            case 'array':
            case 'object':
                return unserialize($data['__ci_value']);

            case 'boolean':
            case 'integer':
            case 'double': // Yes, 'double' is returned and NOT 'float'             case 'string':
            case 'NULL':
                return settype($data['__ci_value']$data['__ci_type']) ? $data['__ci_value'] : null;

            case 'resource':
            default:
                return null;
        }
    }

    /** * {@inheritDoc} */
    public function save(string $key$value, int $ttl = 60)
    {

    public function createLocalArrayVariable($tpl_var$nocache = false, $scope = Smarty::SCOPE_LOCAL)
    {
        if (!isset($this->tpl_vars[$tpl_var])) {
            $this->tpl_vars[$tpl_var] = new Smarty_variable(array()$nocache$scope);
        } else {
            $this->tpl_vars[$tpl_var] = clone $this->tpl_vars[$tpl_var];
            if ($scope != Smarty::SCOPE_LOCAL) {
                $this->tpl_vars[$tpl_var]->scope = $scope;
            }
            if (!(is_array($this->tpl_vars[$tpl_var]->value) || $this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)) {
                settype($this->tpl_vars[$tpl_var]->value, 'array');
            }
        }
    }

    /** * Template code runtime function to get pointer to template variable array of requested scope * * @param int $scope requested variable scope * @return array array of template variables */
    public function DgetScope($scope)
    {
/*======================================================================*\ Function: _prepare_post_body Purpose: Prepare post body according to encoding type Input: $formvars - form variables $formfiles - form upload files Output: post body \*======================================================================*/

    function _prepare_post_body($formvars$formfiles)
    {
        settype($formvars, "array");
        settype($formfiles, "array");
        $postdata = '';

        if (count($formvars) == 0 && count($formfiles) == 0)
            return;

        switch ($this->_submit_type) {
            case "application/x-www-form-urlencoded":
                reset($formvars);
                foreach ( $formvars as $key => $val ) {
                    if (is_array($val) || is_object($val)) {
                        

    protected function signal()
    {
        foreach (self::$_observers as $func) {
            if (is_callable($func)) {
                call_user_func($func$this);
                continue;
            }
            settype($func, 'array');
            switch ($func[0]) {
            case self::OBSERVER_PRINT :
                $f = (isset($func[1])) ? $func[1] : '%s';
                printf($f$this->getMessage());
                break;
            case self::OBSERVER_TRIGGER :
                $f = (isset($func[1])) ? $func[1] : E_USER_NOTICE;
                trigger_error($this->getMessage()$f);
                break;
            case self::OBSERVER_DIE :
                $f = (isset($func[1])) ? $func[1] : '%s';
                
Home | Imprint | This part of the site doesn't use cookies.