PhpSandbox\PHPSandbox::define PHP Méthode

define() public méthode

You can pass a string of the $type, $name and $value, or pass an associative array of definitions types and an associative array of their corresponding values
public define ( string | array $type, string | array | null $name = null, mixed | null $value = null )
$type string | array Associative array or string of definition type to define
$name string | array | null Associative array or string of definition name to define
$value mixed | null Value of definition to define
    public function define($type, $name = null, $value = null)
    {
        if (is_array($type)) {
            foreach ($type as $_type => $name) {
                if (is_string($_type) && $_type && is_array($name)) {
                    foreach ($name as $_name => $_value) {
                        $this->define($_type, is_int($_name) ? $_value : $_name, is_int($_name) ? $value : $_value);
                    }
                }
            }
        } else {
            if ($type && is_array($name)) {
                foreach ($name as $_name => $_value) {
                    $this->define($type, is_int($_name) ? $_value : $_name, is_int($_name) ? $value : $_value);
                }
            } else {
                if ($type && $name) {
                    switch ($type) {
                        case 'functions':
                            return $this->defineFunc($name, $value);
                        case 'variables':
                            return $this->defineVar($name, $value);
                        case 'superglobals':
                            return $this->defineSuperglobal($name, $value);
                        case 'constants':
                            return $this->defineConst($name, $value);
                        case 'magic_constants':
                            return $this->defineMagicConst($name, $value);
                        case 'namespaces':
                            return $this->defineNamespace($name);
                        case 'aliases':
                            return $this->defineAlias($name, $value);
                        case 'classes':
                            return $this->defineClass($name, $value);
                        case 'interfaces':
                            return $this->defineInterface($name, $value);
                        case 'traits':
                            return $this->defineTrait($name, $value);
                    }
                }
            }
        }
        return $this;
    }
PHPSandbox