PhpSandbox\PHPSandbox::undefine PHP Méthode

undefine() public méthode

You can pass a string of the $type and $name to undefine, or pass an associative array of definitions types and an array of key names to undefine
public undefine ( string | array $type, string | array $name = null )
$type string | array Associative array or string of definition type to undefine
$name string | array Associative array or string of definition name to undefine
    public function undefine($type, $name = null)
    {
        if (is_array($type)) {
            foreach ($type as $_type => $name) {
                if (is_string($_type) && $_type && is_array($name)) {
                    foreach ($name as $_name) {
                        if (is_string($_name) && $_name) {
                            $this->undefine($type, $name);
                        }
                    }
                }
            }
        } else {
            if (is_string($type) && $type && is_array($name)) {
                foreach ($name as $_name) {
                    if (is_string($_name) && $_name) {
                        $this->undefine($type, $name);
                    }
                }
            } else {
                if ($type && $name) {
                    switch ($type) {
                        case 'functions':
                            return $this->undefineFunc($name);
                        case 'variables':
                            return $this->undefineVar($name);
                        case 'superglobals':
                            return $this->undefineSuperglobal($name);
                        case 'constants':
                            return $this->undefineConst($name);
                        case 'magic_constants':
                            return $this->undefineMagicConst($name);
                        case 'namespaces':
                            return $this->undefineNamespace($name);
                        case 'aliases':
                            return $this->undefineAlias($name);
                        case 'classes':
                            return $this->undefineClass($name);
                        case 'interfaces':
                            return $this->undefineInterface($name);
                        case 'traits':
                            return $this->undefineTrait($name);
                    }
                }
            }
        }
        return $this;
    }
PHPSandbox