PhpSandbox\PHPSandbox::whitelistFunc PHP Méthode

whitelistFunc() public méthode

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

Usage Example

 /**
  * Test whether sandboxed strings do not cause conflicts with is_string, is_object, or is_scalar
  */
 public function testSandboxedStringsMimicStrings()
 {
     $this->sandbox->whitelistFunc(array('is_string', 'is_object', 'is_scalar'));
     $this->assertEquals(true, $this->sandbox->execute(function () {
         return is_string("system");
     }));
     $this->assertEquals(false, $this->sandbox->execute(function () {
         return is_object("system");
     }));
     $this->assertEquals(true, $this->sandbox->execute(function () {
         return is_scalar("system");
     }));
 }
All Usage Examples Of PhpSandbox\PHPSandbox::whitelistFunc
PHPSandbox