Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/http-foundation/JsonResponse.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
line wrap: on
line diff
--- a/vendor/symfony/http-foundation/JsonResponse.php Tue Jul 10 15:07:59 2018 +0100 +++ b/vendor/symfony/http-foundation/JsonResponse.php Thu Feb 28 13:21:36 2019 +0000 @@ -39,7 +39,7 @@ * @param array $headers An array of response headers * @param bool $json If the data is already a JSON string */ - public function __construct($data = null, $status = 200, $headers = array(), $json = false) + public function __construct($data = null, $status = 200, $headers = [], $json = false) { parent::__construct('', $status, $headers); @@ -64,7 +64,7 @@ * * @return static */ - public static function create($data = null, $status = 200, $headers = array()) + public static function create($data = null, $status = 200, $headers = []) { return new static($data, $status, $headers); } @@ -72,7 +72,7 @@ /** * Make easier the creation of JsonResponse from raw json. */ - public static function fromJsonString($data = null, $status = 200, $headers = array()) + public static function fromJsonString($data = null, $status = 200, $headers = []) { return new static($data, $status, $headers, true); } @@ -94,14 +94,14 @@ // JsonpCallbackValidator is released under the MIT License. See https://github.com/willdurand/JsonpCallbackValidator/blob/v1.1.0/LICENSE for details. // (c) William Durand <william.durand1@gmail.com> $pattern = '/^[$_\p{L}][$_\p{L}\p{Mn}\p{Mc}\p{Nd}\p{Pc}\x{200C}\x{200D}]*(?:\[(?:"(?:\\\.|[^"\\\])*"|\'(?:\\\.|[^\'\\\])*\'|\d+)\])*?$/u'; - $reserved = array( + $reserved = [ 'break', 'do', 'instanceof', 'typeof', 'case', 'else', 'new', 'var', 'catch', 'finally', 'return', 'void', 'continue', 'for', 'switch', 'while', 'debugger', 'function', 'this', 'with', 'default', 'if', 'throw', 'delete', 'in', 'try', 'class', 'enum', 'extends', 'super', 'const', 'export', 'import', 'implements', 'let', 'private', 'public', 'yield', 'interface', 'package', 'protected', 'static', 'null', 'true', 'false', - ); + ]; $parts = explode('.', $callback); foreach ($parts as $part) { - if (!preg_match($pattern, $part) || in_array($part, $reserved, true)) { + if (!preg_match($pattern, $part) || \in_array($part, $reserved, true)) { throw new \InvalidArgumentException('The callback name is not valid.'); } } @@ -137,9 +137,9 @@ * * @throws \InvalidArgumentException */ - public function setData($data = array()) + public function setData($data = []) { - if (defined('HHVM_VERSION')) { + if (\defined('HHVM_VERSION')) { // HHVM does not trigger any warnings and let exceptions // thrown from a JsonSerializable object pass through. // If only PHP did the same... @@ -156,7 +156,7 @@ try { $data = json_encode($data, $this->encodingOptions); } catch (\Exception $e) { - if ('Exception' === get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) { + if ('Exception' === \get_class($e) && 0 === strpos($e->getMessage(), 'Failed calling ')) { throw $e->getPrevious() ?: $e; } throw $e;