diff --git a/src/Symfony/Component/BrowserKit/AbstractBrowser.php b/src/Symfony/Component/BrowserKit/AbstractBrowser.php index 5604fce6d2ce6..8cf0770347238 100644 --- a/src/Symfony/Component/BrowserKit/AbstractBrowser.php +++ b/src/Symfony/Component/BrowserKit/AbstractBrowser.php @@ -64,12 +64,10 @@ public function __construct(array $server = [], History $history = null, CookieJ /** * Sets whether to automatically follow redirects or not. - * - * @param bool $followRedirect Whether to follow redirects */ - public function followRedirects($followRedirect = true) + public function followRedirects(bool $followRedirects = true) { - $this->followRedirects = (bool) $followRedirect; + $this->followRedirects = $followRedirects; } /** @@ -92,10 +90,8 @@ public function isFollowingRedirects() /** * Sets the maximum number of redirects that crawler can follow. - * - * @param int $maxRedirects */ - public function setMaxRedirects($maxRedirects) + public function setMaxRedirects(int $maxRedirects) { $this->maxRedirects = $maxRedirects < 0 ? -1 : $maxRedirects; $this->followRedirects = -1 != $this->maxRedirects; @@ -118,13 +114,13 @@ public function getMaxRedirects() * * @throws \RuntimeException When Symfony Process Component is not installed */ - public function insulate($insulated = true) + public function insulate(bool $insulated = true) { if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) { throw new \LogicException('Unable to isolate requests as the Symfony Process Component is not installed.'); } - $this->insulated = (bool) $insulated; + $this->insulated = $insulated; } /** @@ -141,11 +137,8 @@ public function setServerParameters(array $server) /** * Sets single server parameter. - * - * @param string $key A key of the parameter - * @param string $value A value of the parameter */ - public function setServerParameter($key, $value) + public function setServerParameter(string $key, string $value) { $this->server[$key] = $value; } @@ -153,12 +146,9 @@ public function setServerParameter($key, $value) /** * Gets single server parameter for specified key. * - * @param string $key A key of the parameter to get - * @param string $default A default value when key is undefined - * * @return string A value of the parameter */ - public function getServerParameter($key, $default = '') + public function getServerParameter(string $key, $default = '') { return isset($this->server[$key]) ? $this->server[$key] : $default; } @@ -416,7 +406,7 @@ public function request(string $method, string $uri, array $parameters = [], arr return $this->crawler = $this->followRedirect(); } - $this->crawler = $this->createCrawlerFromContent($this->internalRequest->getUri(), $this->internalResponse->getContent(), $this->internalResponse->getHeader('Content-Type')); + $this->crawler = $this->createCrawlerFromContent($this->internalRequest->getUri(), $this->internalResponse->getContent(), $this->internalResponse->getHeader('Content-Type') ?? ''); // Check for meta refresh redirect if ($this->followMetaRefresh && null !== $redirect = $this->getMetaRefreshUrl()) { @@ -515,13 +505,9 @@ protected function filterResponse($response) * * This method returns null if the DomCrawler component is not available. * - * @param string $uri A URI - * @param string $content Content for the crawler to use - * @param string $type Content type - * * @return Crawler|null */ - protected function createCrawlerFromContent($uri, $content, $type) + protected function createCrawlerFromContent(string $uri, string $content, string $type) { if (!class_exists('Symfony\Component\DomCrawler\Crawler')) { return; @@ -655,7 +641,7 @@ public function restart() * * @return string An absolute URI */ - protected function getAbsoluteUri($uri) + protected function getAbsoluteUri(string $uri) { // already absolute? if (0 === strpos($uri, 'http://') || 0 === strpos($uri, 'https://')) { diff --git a/src/Symfony/Component/BrowserKit/Cookie.php b/src/Symfony/Component/BrowserKit/Cookie.php index ee786e69c2b24..a6c5abe8e285b 100644 --- a/src/Symfony/Component/BrowserKit/Cookie.php +++ b/src/Symfony/Component/BrowserKit/Cookie.php @@ -119,14 +119,11 @@ public function __toString() /** * Creates a Cookie instance from a Set-Cookie header value. * - * @param string $cookie A Set-Cookie header value - * @param string|null $url The base URL - * * @return static * * @throws \InvalidArgumentException */ - public static function fromString($cookie, $url = null) + public static function fromString(string $cookie, string $url = null) { $parts = explode(';', $cookie); diff --git a/src/Symfony/Component/BrowserKit/CookieJar.php b/src/Symfony/Component/BrowserKit/CookieJar.php index bce66197d3703..2da42af38c0c2 100644 --- a/src/Symfony/Component/BrowserKit/CookieJar.php +++ b/src/Symfony/Component/BrowserKit/CookieJar.php @@ -33,13 +33,9 @@ public function set(Cookie $cookie) * (this behavior ensures a BC behavior with previous versions of * Symfony). * - * @param string $name The cookie name - * @param string $path The cookie path - * @param string $domain The cookie domain - * * @return Cookie|null A Cookie instance or null if the cookie does not exist */ - public function get($name, $path = '/', $domain = null) + public function get(string $name, string $path = '/', string $domain = null) { $this->flushExpiredCookies(); @@ -68,12 +64,8 @@ public function get($name, $path = '/', $domain = null) * You should never use an empty domain, but if you do so, * all cookies for the given name/path expire (this behavior * ensures a BC behavior with previous versions of Symfony). - * - * @param string $name The cookie name - * @param string $path The cookie path - * @param string $domain The cookie domain */ - public function expire($name, $path = '/', $domain = null) + public function expire(string $name, ?string $path = '/', string $domain = null) { if (null === $path) { $path = '/'; @@ -143,7 +135,7 @@ public function updateFromSetCookie(array $setCookies, $uri = null) * @param Response $response A Response object * @param string $uri The base URL */ - public function updateFromResponse(Response $response, $uri = null) + public function updateFromResponse(Response $response, string $uri = null) { $this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri); } @@ -172,12 +164,9 @@ public function all() /** * Returns not yet expired cookie values for the given URI. * - * @param string $uri A URI - * @param bool $returnsRawValue Returns raw value or urldecoded value - * * @return array An array of cookie values */ - public function allValues($uri, $returnsRawValue = false) + public function allValues(string $uri, bool $returnsRawValue = false) { $this->flushExpiredCookies(); @@ -212,11 +201,9 @@ public function allValues($uri, $returnsRawValue = false) /** * Returns not yet expired raw cookie values for the given URI. * - * @param string $uri A URI - * * @return array An array of cookie values */ - public function allRawValues($uri) + public function allRawValues(string $uri) { return $this->allValues($uri, true); } diff --git a/src/Symfony/Component/BrowserKit/Response.php b/src/Symfony/Component/BrowserKit/Response.php index 376bd78df4c69..f4c04c93eaa82 100644 --- a/src/Symfony/Component/BrowserKit/Response.php +++ b/src/Symfony/Component/BrowserKit/Response.php @@ -84,12 +84,9 @@ public function getHeaders(): array /** * Gets a response header. * - * @param string $header The header name - * @param bool $first Whether to return the first value or all header values - * * @return string|array The first header value if $first is true, an array of values otherwise */ - public function getHeader($header, $first = true) + public function getHeader(string $header, bool $first = true) { $normalizedHeader = str_replace('-', '_', strtolower($header)); foreach ($this->headers as $key => $value) {