PhpSandbox\PHPSandbox::whitelistType PHP Method

whitelistType() public method

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

Usage Example

示例#1
0
 /**
  * Test whether sandbox custom exception handler intercepts exceptions
  */
 public function testCustomExceptionHandler()
 {
     $this->expectException('Exception');
     $this->sandbox->whitelistType('Exception');
     $this->sandbox->setExceptionHandler(function ($exception) {
         throw $exception;
     });
     $this->sandbox->execute(function () {
         throw new \Exception();
     });
 }
All Usage Examples Of PhpSandbox\PHPSandbox::whitelistType
PHPSandbox