PhpSandbox\PHPSandbox::setFuncValidator PHP Méthode

setFuncValidator() public méthode

Validator callable must accept two parameters: a string of the normalized name of the checked element, and the PHPSandbox instance. NOTE: Normalized function names include the namespace and are lowercase!
public setFuncValidator ( callable $callable ) : PHPSandbox
$callable callable Callable that validates the normalized passed function name
Résultat PHPSandbox Returns the PHPSandbox instance for fluent querying
    public function setFuncValidator($callable)
    {
        $this->validation['function'] = $callable;
        return $this;
    }

Usage Example

 /**
  * Test whether sandbox custom function validation succeeds
  */
 public function testCustomFunctionValidationFailure()
 {
     $this->expectException('PHPSandbox\\Error');
     $this->sandbox->setFuncValidator(function ($name) {
         return $name == 'test';
     });
     $this->sandbox->execute(function () {
         test2();
     });
 }
PHPSandbox