PhpSandbox\PHPSandbox::_get_defined_constants PHP Méthode

_get_defined_constants() public méthode

Get PHPSandbox redefined constants in place of get_defined_constants(). This is an internal PHPSandbox function but requires public access to work.
public _get_defined_constants ( array $constants = [] ) : array
$constants array Array result from get_defined_constants() is passed here
Résultat array Returns the redefined constants
    public function _get_defined_constants(array $constants = [])
    {
        if (count($this->whitelist['constants'])) {
            $constants = [];
            foreach ($this->whitelist['constants'] as $name => $value) {
                if (defined($name)) {
                    $constants[$name] = $name;
                }
            }
            foreach ($this->definitions['constants'] as $name => $value) {
                if (defined($name)) {
                    //these shouldn't be undefined, but just in case they are we don't want to report inaccurate information
                    $constants[$name] = $name;
                }
            }
            return array_values($constants);
        } else {
            if (count($this->blacklist['constants'])) {
                foreach ($constants as $index => $name) {
                    if (isset($this->blacklist['constants'][$name])) {
                        unset($constants[$index]);
                    }
                }
                reset($constants);
                return $constants;
            }
        }
        return [];
    }
PHPSandbox