PhpSandbox\PHPSandbox::whitelistMagicConst PHP Méthode

whitelistMagicConst() public méthode

You can pass a string of magic constant name, or pass an array of the magic constant names to whitelist
public whitelistMagicConst ( string | array $name )
$name string | array String of magic constant name or array of magic constant names to whitelist
    public function whitelistMagicConst($name)
    {
        if (func_num_args() > 1) {
            return $this->whitelistMagicConst(func_get_args());
        }
        $name = $this->normalizeMagicConst($name);
        return $this->whitelist('magic_constants', $name);
    }

Usage Example

 /**
  * Test whether sandbox disallows violating callbacks
  */
 public function testWhitelistMagicConstants()
 {
     $this->sandbox->whitelistMagicConst('DIR');
     $this->assertEquals(str_replace('tests', 'src', __DIR__), $this->sandbox->execute(function () {
         return __DIR__;
     }));
 }
PHPSandbox