Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/browser-kit/Client.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 5fb285c0d0e3 |
children | af1871eacc83 |
line wrap: on
line diff
--- a/vendor/symfony/browser-kit/Client.php Tue Jul 10 15:07:59 2018 +0100 +++ b/vendor/symfony/browser-kit/Client.php Thu Feb 28 13:21:36 2019 +0000 @@ -12,8 +12,8 @@ namespace Symfony\Component\BrowserKit; use Symfony\Component\DomCrawler\Crawler; +use Symfony\Component\DomCrawler\Form; use Symfony\Component\DomCrawler\Link; -use Symfony\Component\DomCrawler\Form; use Symfony\Component\Process\PhpProcess; /** @@ -30,7 +30,7 @@ { protected $history; protected $cookieJar; - protected $server = array(); + protected $server = []; protected $internalRequest; protected $request; protected $internalResponse; @@ -42,7 +42,7 @@ private $maxRedirects = -1; private $redirectCount = 0; - private $redirects = array(); + private $redirects = []; private $isMainRequest = true; /** @@ -50,7 +50,7 @@ * @param History $history A History instance to store the browser history * @param CookieJar $cookieJar A CookieJar instance to store the cookies */ - public function __construct(array $server = array(), History $history = null, CookieJar $cookieJar = null) + public function __construct(array $server = [], History $history = null, CookieJar $cookieJar = null) { $this->setServerParameters($server); $this->history = $history ?: new History(); @@ -121,9 +121,9 @@ */ public function setServerParameters(array $server) { - $this->server = array_merge(array( + $this->server = array_merge([ 'HTTP_USER_AGENT' => 'Symfony BrowserKit', - ), $server); + ], $server); } /** @@ -252,7 +252,7 @@ * * @return Crawler */ - public function submit(Form $form, array $values = array()) + public function submit(Form $form, array $values = []) { $form->setValues($values); @@ -272,7 +272,7 @@ * * @return Crawler */ - public function request($method, $uri, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true) + public function request($method, $uri, array $parameters = [], array $files = [], array $server = [], $content = null, $changeHistory = true) { if ($this->isMainRequest) { $this->redirectCount = 0; @@ -280,11 +280,17 @@ ++$this->redirectCount; } + $originalUri = $uri; + $uri = $this->getAbsoluteUri($uri); $server = array_merge($this->server, $server); - if (isset($server['HTTPS'])) { + if (!empty($server['HTTP_HOST']) && null === parse_url($originalUri, PHP_URL_HOST)) { + $uri = preg_replace('{^(https?\://)'.preg_quote($this->extractHost($uri)).'}', '${1}'.$server['HTTP_HOST'], $uri); + } + + if (isset($server['HTTPS']) && null === parse_url($originalUri, PHP_URL_SCHEME)) { $uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri); } @@ -353,9 +359,9 @@ if (file_exists($deprecationsFile)) { $deprecations = file_get_contents($deprecationsFile); unlink($deprecationsFile); - foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) { + foreach ($deprecations ? unserialize($deprecations) : [] as $deprecation) { if ($deprecation[0]) { - trigger_error($deprecation[1], E_USER_DEPRECATED); + @trigger_error($deprecation[1], E_USER_DEPRECATED); } else { @trigger_error($deprecation[1], E_USER_DEPRECATED); } @@ -497,9 +503,9 @@ $request = $this->internalRequest; - if (in_array($this->internalResponse->getStatus(), array(301, 302, 303))) { + if (\in_array($this->internalResponse->getStatus(), [301, 302, 303])) { $method = 'GET'; - $files = array(); + $files = []; $content = null; } else { $method = $request->getMethod(); @@ -509,7 +515,7 @@ if ('GET' === strtoupper($method)) { // Don't forward parameters for GET request as it should reach the redirection URI - $parameters = array(); + $parameters = []; } else { $parameters = $request->getParameters(); }