function check($strict = false) { $trace = next(debug_backtrace(0)); if (!is_array($trace)) { throw new \LogicException('Invalid context'); } if (isset($trace['class'])) { $reflection = new \ReflectionMethod($trace['class'], $trace['function']); } else { $reflection = new \ReflectionFunction($trace['function']); } $handler = new Handler(new CheckerCollection(), ValidatorSingleton::getInstance()); try { $handler->check($reflection, $trace['args'], $strict); } catch (\InvalidArgumentException $e) { throw new \InvalidArgumentException(sprintf('%s, called in %s on line %d and defined in %s on line %d', $e->getMessage(), $trace['file'], $trace['line'], $reflection->getFileName(), $reflection->getStartLine())); } }
public function testValidArrayOfStringNoStrict() { $this->handler->check(new \ReflectionMethod(__CLASS__, 'methodWithArrayOfString'), array(array('foo', 42))); }