diff --git a/lib/WebDriver/AbstractWebDriver.php b/lib/WebDriver/AbstractWebDriver.php index d88cb80..a2aa2e1 100644 --- a/lib/WebDriver/AbstractWebDriver.php +++ b/lib/WebDriver/AbstractWebDriver.php @@ -120,6 +120,8 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti $url .= '/' . $parameters; } + $this->assertNonObjectParameters($parameters); + list($rawResult, $info) = ServiceFactory::getInstance()->getService('service.curl')->execute($requestMethod, $url, $parameters, $extraOptions); $httpCode = $info['http_code']; @@ -197,6 +199,32 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti ); } + /** + * @param mixed $parameters + */ + private function assertNonObjectParameters($parameters) + { + if ($parameters === null || is_scalar($parameters)) { + return; + } + + if (is_array($parameters)) { + foreach ($parameters as $value) { + $this->assertNonObjectParameters($value); + } + + return; + } + + throw WebDriverException::factory( + WebDriverException::UNEXPECTED_PARAMETERS, + sprintf( + "Unable to serialize non-scalar type %s", + is_object($parameters) ? get_class($parameters) : gettype($parameters) + ) + ); + } + /** * Magic method that maps calls to class methods to execute WebDriver commands *