Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2725137

Browse filesBrowse files
committed
[BrowserKit] [5.0] Add type-hint to browserkit classes
1 parent 38b9b95 commit 2725137
Copy full SHA for 2725137

File tree

5 files changed

+18
-49
lines changed
Filter options

5 files changed

+18
-49
lines changed

‎src/Symfony/Component/BrowserKit/AbstractBrowser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/AbstractBrowser.php
+10-22Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,10 @@ public function __construct(array $server = [], History $history = null, CookieJ
6464

6565
/**
6666
* Sets whether to automatically follow redirects or not.
67-
*
68-
* @param bool $followRedirect Whether to follow redirects
6967
*/
70-
public function followRedirects($followRedirect = true)
68+
public function followRedirects(bool $followRedirects = true)
7169
{
72-
$this->followRedirects = (bool) $followRedirect;
70+
$this->followRedirects = $followRedirects;
7371
}
7472

7573
/**
@@ -92,10 +90,8 @@ public function isFollowingRedirects()
9290

9391
/**
9492
* Sets the maximum number of redirects that crawler can follow.
95-
*
96-
* @param int $maxRedirects
9793
*/
98-
public function setMaxRedirects($maxRedirects)
94+
public function setMaxRedirects(int $maxRedirects)
9995
{
10096
$this->maxRedirects = $maxRedirects < 0 ? -1 : $maxRedirects;
10197
$this->followRedirects = -1 != $this->maxRedirects;
@@ -118,13 +114,13 @@ public function getMaxRedirects()
118114
*
119115
* @throws \RuntimeException When Symfony Process Component is not installed
120116
*/
121-
public function insulate($insulated = true)
117+
public function insulate(bool $insulated = true)
122118
{
123119
if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) {
124120
throw new \LogicException('Unable to isolate requests as the Symfony Process Component is not installed.');
125121
}
126122

127-
$this->insulated = (bool) $insulated;
123+
$this->insulated = $insulated;
128124
}
129125

130126
/**
@@ -141,24 +137,20 @@ public function setServerParameters(array $server)
141137

142138
/**
143139
* Sets single server parameter.
144-
*
145-
* @param string $key A key of the parameter
146-
* @param string $value A value of the parameter
147140
*/
148-
public function setServerParameter($key, $value)
141+
public function setServerParameter(string $key, string $value)
149142
{
150143
$this->server[$key] = $value;
151144
}
152145

153146
/**
154147
* Gets single server parameter for specified key.
155148
*
156-
* @param string $key A key of the parameter to get
157-
* @param string $default A default value when key is undefined
149+
* @var mixed $default
158150
*
159151
* @return string A value of the parameter
160152
*/
161-
public function getServerParameter($key, $default = '')
153+
public function getServerParameter(string $key, $default = '')
162154
{
163155
return isset($this->server[$key]) ? $this->server[$key] : $default;
164156
}
@@ -515,13 +507,9 @@ protected function filterResponse($response)
515507
*
516508
* This method returns null if the DomCrawler component is not available.
517509
*
518-
* @param string $uri A URI
519-
* @param string $content Content for the crawler to use
520-
* @param string $type Content type
521-
*
522510
* @return Crawler|null
523511
*/
524-
protected function createCrawlerFromContent($uri, $content, $type)
512+
protected function createCrawlerFromContent(string $uri, string $content, ?string $type)
525513
{
526514
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
527515
return;
@@ -655,7 +643,7 @@ public function restart()
655643
*
656644
* @return string An absolute URI
657645
*/
658-
protected function getAbsoluteUri($uri)
646+
protected function getAbsoluteUri(string $uri)
659647
{
660648
// already absolute?
661649
if (0 === strpos($uri, 'http://') || 0 === strpos($uri, 'https://')) {

‎src/Symfony/Component/BrowserKit/Cookie.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Cookie.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,11 @@ public function __toString()
119119
/**
120120
* Creates a Cookie instance from a Set-Cookie header value.
121121
*
122-
* @param string $cookie A Set-Cookie header value
123-
* @param string|null $url The base URL
124-
*
125122
* @return static
126123
*
127124
* @throws \InvalidArgumentException
128125
*/
129-
public static function fromString($cookie, $url = null)
126+
public static function fromString(string $cookie, string $url = null)
130127
{
131128
$parts = explode(';', $cookie);
132129

‎src/Symfony/Component/BrowserKit/CookieJar.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/CookieJar.php
+5-18Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,9 @@ public function set(Cookie $cookie)
3333
* (this behavior ensures a BC behavior with previous versions of
3434
* Symfony).
3535
*
36-
* @param string $name The cookie name
37-
* @param string $path The cookie path
38-
* @param string $domain The cookie domain
39-
*
4036
* @return Cookie|null A Cookie instance or null if the cookie does not exist
4137
*/
42-
public function get($name, $path = '/', $domain = null)
38+
public function get(string $name, string $path = '/', string $domain = null)
4339
{
4440
$this->flushExpiredCookies();
4541

@@ -68,12 +64,8 @@ public function get($name, $path = '/', $domain = null)
6864
* You should never use an empty domain, but if you do so,
6965
* all cookies for the given name/path expire (this behavior
7066
* ensures a BC behavior with previous versions of Symfony).
71-
*
72-
* @param string $name The cookie name
73-
* @param string $path The cookie path
74-
* @param string $domain The cookie domain
7567
*/
76-
public function expire($name, $path = '/', $domain = null)
68+
public function expire(string $name, ?string $path = '/', string $domain = null)
7769
{
7870
if (null === $path) {
7971
$path = '/';
@@ -143,7 +135,7 @@ public function updateFromSetCookie(array $setCookies, $uri = null)
143135
* @param Response $response A Response object
144136
* @param string $uri The base URL
145137
*/
146-
public function updateFromResponse(Response $response, $uri = null)
138+
public function updateFromResponse(Response $response, string $uri = null)
147139
{
148140
$this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri);
149141
}
@@ -172,12 +164,9 @@ public function all()
172164
/**
173165
* Returns not yet expired cookie values for the given URI.
174166
*
175-
* @param string $uri A URI
176-
* @param bool $returnsRawValue Returns raw value or urldecoded value
177-
*
178167
* @return array An array of cookie values
179168
*/
180-
public function allValues($uri, $returnsRawValue = false)
169+
public function allValues(string $uri, bool $returnsRawValue = false)
181170
{
182171
$this->flushExpiredCookies();
183172

@@ -212,11 +201,9 @@ public function allValues($uri, $returnsRawValue = false)
212201
/**
213202
* Returns not yet expired raw cookie values for the given URI.
214203
*
215-
* @param string $uri A URI
216-
*
217204
* @return array An array of cookie values
218205
*/
219-
public function allRawValues($uri)
206+
public function allRawValues(string $uri)
220207
{
221208
return $this->allValues($uri, true);
222209
}

‎src/Symfony/Component/BrowserKit/Response.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Response.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,9 @@ public function getHeaders(): array
8484
/**
8585
* Gets a response header.
8686
*
87-
* @param string $header The header name
88-
* @param bool $first Whether to return the first value or all header values
89-
*
9087
* @return string|array The first header value if $first is true, an array of values otherwise
9188
*/
92-
public function getHeader($header, $first = true)
89+
public function getHeader(string $header, bool $first = true)
9390
{
9491
$normalizedHeader = str_replace('-', '_', strtolower($header));
9592
foreach ($this->headers as $key => $value) {

‎src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testXmlHttpRequest()
107107
$client = $this->getBrowser();
108108
$client->xmlHttpRequest('GET', 'http://example.com/', [], [], [], null, true);
109109
$this->assertEquals($client->getRequest()->getServer()['HTTP_X_REQUESTED_WITH'], 'XMLHttpRequest');
110-
$this->assertFalse($client->getServerParameter('HTTP_X_REQUESTED_WITH', false));
110+
$this->assertSame(false, $client->getServerParameter('HTTP_X_REQUESTED_WITH', false));
111111
}
112112

113113
public function testGetRequestWithIpAsHttpHost()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.