Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc626a8

Browse files
minor #42508 Add return types - batch 4/n (nicolas-grekas)
This PR was merged into the 6.0 branch. Discussion ---------- Add return types - batch 4/n | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #40154 | License | MIT | Doc PR | - Extracted from #42496 Not all possible return types are patched for the attached components, to save breaking BC cross-components, for now at least. Commits ------- bad9b7d Add return types - batch 4/n
2 parents 2c2229b + bad9b7d commit cc626a8

File tree

190 files changed

+748
-929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+748
-929
lines changed

src/Symfony/Component/BrowserKit/AbstractBrowser.php

Lines changed: 20 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@ public function followMetaRefresh(bool $followMetaRefresh = true)
7575

7676
/**
7777
* Returns whether client automatically follows redirects or not.
78-
*
79-
* @return bool
8078
*/
81-
public function isFollowingRedirects()
79+
public function isFollowingRedirects(): bool
8280
{
8381
return $this->followRedirects;
8482
}
@@ -94,10 +92,8 @@ public function setMaxRedirects(int $maxRedirects)
9492

9593
/**
9694
* Returns the maximum number of redirects that crawler can follow.
97-
*
98-
* @return int
9995
*/
100-
public function getMaxRedirects()
96+
public function getMaxRedirects(): int
10197
{
10298
return $this->maxRedirects;
10399
}
@@ -136,10 +132,8 @@ public function setServerParameter(string $key, string $value)
136132

137133
/**
138134
* Gets single server parameter for specified key.
139-
*
140-
* @return mixed
141135
*/
142-
public function getServerParameter(string $key, mixed $default = '')
136+
public function getServerParameter(string $key, mixed $default = ''): mixed
143137
{
144138
return $this->server[$key] ?? $default;
145139
}
@@ -175,30 +169,24 @@ public function jsonRequest(string $method, string $uri, array $parameters = [],
175169

176170
/**
177171
* Returns the History instance.
178-
*
179-
* @return History
180172
*/
181-
public function getHistory()
173+
public function getHistory(): History
182174
{
183175
return $this->history;
184176
}
185177

186178
/**
187179
* Returns the CookieJar instance.
188-
*
189-
* @return CookieJar
190180
*/
191-
public function getCookieJar()
181+
public function getCookieJar(): CookieJar
192182
{
193183
return $this->cookieJar;
194184
}
195185

196186
/**
197187
* Returns the current Crawler instance.
198-
*
199-
* @return Crawler
200188
*/
201-
public function getCrawler()
189+
public function getCrawler(): Crawler
202190
{
203191
if (null === $this->crawler) {
204192
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
@@ -209,10 +197,8 @@ public function getCrawler()
209197

210198
/**
211199
* Returns the current BrowserKit Response instance.
212-
*
213-
* @return Response
214200
*/
215-
public function getInternalResponse()
201+
public function getInternalResponse(): Response
216202
{
217203
if (null === $this->internalResponse) {
218204
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
@@ -227,11 +213,9 @@ public function getInternalResponse()
227213
* The origin response is the response instance that is returned
228214
* by the code that handles requests.
229215
*
230-
* @return object
231-
*
232216
* @see doRequest()
233217
*/
234-
public function getResponse()
218+
public function getResponse(): object
235219
{
236220
if (null === $this->response) {
237221
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
@@ -242,10 +226,8 @@ public function getResponse()
242226

243227
/**
244228
* Returns the current BrowserKit Request instance.
245-
*
246-
* @return Request
247229
*/
248-
public function getInternalRequest()
230+
public function getInternalRequest(): Request
249231
{
250232
if (null === $this->internalRequest) {
251233
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
@@ -260,11 +242,9 @@ public function getInternalRequest()
260242
* The origin request is the request instance that is sent
261243
* to the code that handles requests.
262244
*
263-
* @return object
264-
*
265245
* @see doRequest()
266246
*/
267-
public function getRequest()
247+
public function getRequest(): object
268248
{
269249
if (null === $this->request) {
270250
throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
@@ -275,10 +255,8 @@ public function getRequest()
275255

276256
/**
277257
* Clicks on a given link.
278-
*
279-
* @return Crawler
280258
*/
281-
public function click(Link $link)
259+
public function click(Link $link): Crawler
282260
{
283261
if ($link instanceof Form) {
284262
return $this->submit($link);
@@ -306,10 +284,8 @@ public function clickLink(string $linkText): Crawler
306284
*
307285
* @param array $values An array of form field values
308286
* @param array $serverParameters An array of server parameters
309-
*
310-
* @return Crawler
311287
*/
312-
public function submit(Form $form, array $values = [], array $serverParameters = [])
288+
public function submit(Form $form, array $values = [], array $serverParameters = []): Crawler
313289
{
314290
$form->setValues($values);
315291

@@ -347,10 +323,8 @@ public function submitForm(string $button, array $fieldValues = [], string $meth
347323
* @param array $server The server parameters (HTTP headers are referenced with an HTTP_ prefix as PHP does)
348324
* @param string $content The raw body data
349325
* @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
350-
*
351-
* @return Crawler
352326
*/
353-
public function request(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true)
327+
public function request(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], string $content = null, bool $changeHistory = true): Crawler
354328
{
355329
if ($this->isMainRequest) {
356330
$this->redirectCount = 0;
@@ -504,10 +478,8 @@ protected function filterResponse(object $response)
504478
* Creates a crawler.
505479
*
506480
* This method returns null if the DomCrawler component is not available.
507-
*
508-
* @return Crawler|null
509481
*/
510-
protected function createCrawlerFromContent(string $uri, string $content, string $type)
482+
protected function createCrawlerFromContent(string $uri, string $content, string $type): ?Crawler
511483
{
512484
if (!class_exists(Crawler::class)) {
513485
return null;
@@ -521,10 +493,8 @@ protected function createCrawlerFromContent(string $uri, string $content, string
521493

522494
/**
523495
* Goes back in the browser history.
524-
*
525-
* @return Crawler
526496
*/
527-
public function back()
497+
public function back(): Crawler
528498
{
529499
do {
530500
$request = $this->history->back();
@@ -535,10 +505,8 @@ public function back()
535505

536506
/**
537507
* Goes forward in the browser history.
538-
*
539-
* @return Crawler
540508
*/
541-
public function forward()
509+
public function forward(): Crawler
542510
{
543511
do {
544512
$request = $this->history->forward();
@@ -549,22 +517,18 @@ public function forward()
549517

550518
/**
551519
* Reloads the current browser.
552-
*
553-
* @return Crawler
554520
*/
555-
public function reload()
521+
public function reload(): Crawler
556522
{
557523
return $this->requestFromRequest($this->history->current(), false);
558524
}
559525

560526
/**
561527
* Follow redirects?
562528
*
563-
* @return Crawler
564-
*
565529
* @throws \LogicException If request was not a redirect
566530
*/
567-
public function followRedirect()
531+
public function followRedirect(): Crawler
568532
{
569533
if (empty($this->redirect)) {
570534
throw new \LogicException('The request was not redirected.');
@@ -639,7 +603,7 @@ public function restart()
639603
*
640604
* @return string An absolute URI
641605
*/
642-
protected function getAbsoluteUri(string $uri)
606+
protected function getAbsoluteUri(string $uri): string
643607
{
644608
// already absolute?
645609
if (0 === strpos($uri, 'http://') || 0 === strpos($uri, 'https://')) {
@@ -682,10 +646,8 @@ protected function getAbsoluteUri(string $uri)
682646
* Makes a request from a Request object directly.
683647
*
684648
* @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload())
685-
*
686-
* @return Crawler
687649
*/
688-
protected function requestFromRequest(Request $request, bool $changeHistory = true)
650+
protected function requestFromRequest(Request $request, bool $changeHistory = true): Crawler
689651
{
690652
return $this->request($request->getMethod(), $request->getUri(), $request->getParameters(), $request->getFiles(), $request->getServer(), $request->getContent(), $changeHistory);
691653
}

src/Symfony/Component/BrowserKit/Cookie.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,9 @@ public function __toString(): string
119119
/**
120120
* Creates a Cookie instance from a Set-Cookie header value.
121121
*
122-
* @return static
123-
*
124122
* @throws \InvalidArgumentException
125123
*/
126-
public static function fromString(string $cookie, string $url = null)
124+
public static function fromString(string $cookie, string $url = null): static
127125
{
128126
$parts = explode(';', $cookie);
129127

@@ -222,7 +220,7 @@ private static function parseDate(string $dateValue): ?string
222220
*
223221
* @return string The cookie name
224222
*/
225-
public function getName()
223+
public function getName(): string
226224
{
227225
return $this->name;
228226
}
@@ -232,7 +230,7 @@ public function getName()
232230
*
233231
* @return string The cookie value
234232
*/
235-
public function getValue()
233+
public function getValue(): string
236234
{
237235
return $this->value;
238236
}
@@ -242,7 +240,7 @@ public function getValue()
242240
*
243241
* @return string The cookie value
244242
*/
245-
public function getRawValue()
243+
public function getRawValue(): string
246244
{
247245
return $this->rawValue;
248246
}
@@ -252,7 +250,7 @@ public function getRawValue()
252250
*
253251
* @return string|null The cookie expires time
254252
*/
255-
public function getExpiresTime()
253+
public function getExpiresTime(): ?string
256254
{
257255
return $this->expires;
258256
}
@@ -262,7 +260,7 @@ public function getExpiresTime()
262260
*
263261
* @return string The cookie path
264262
*/
265-
public function getPath()
263+
public function getPath(): string
266264
{
267265
return $this->path;
268266
}
@@ -272,7 +270,7 @@ public function getPath()
272270
*
273271
* @return string The cookie domain
274272
*/
275-
public function getDomain()
273+
public function getDomain(): string
276274
{
277275
return $this->domain;
278276
}
@@ -282,7 +280,7 @@ public function getDomain()
282280
*
283281
* @return bool The cookie secure flag
284282
*/
285-
public function isSecure()
283+
public function isSecure(): bool
286284
{
287285
return $this->secure;
288286
}
@@ -292,7 +290,7 @@ public function isSecure()
292290
*
293291
* @return bool The cookie httponly flag
294292
*/
295-
public function isHttpOnly()
293+
public function isHttpOnly(): bool
296294
{
297295
return $this->httponly;
298296
}
@@ -302,7 +300,7 @@ public function isHttpOnly()
302300
*
303301
* @return bool true if the cookie has expired, false otherwise
304302
*/
305-
public function isExpired()
303+
public function isExpired(): bool
306304
{
307305
return null !== $this->expires && 0 != $this->expires && $this->expires <= time();
308306
}

src/Symfony/Component/BrowserKit/CookieJar.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ public function set(Cookie $cookie)
3232
* this method returns the first cookie for the given name/path
3333
* (this behavior ensures a BC behavior with previous versions of
3434
* Symfony).
35-
*
36-
* @return Cookie|null
3735
*/
38-
public function get(string $name, string $path = '/', string $domain = null)
36+
public function get(string $name, string $path = '/', string $domain = null): ?Cookie
3937
{
4038
$this->flushExpiredCookies();
4139

@@ -143,7 +141,7 @@ public function updateFromResponse(Response $response, string $uri = null)
143141
*
144142
* @return Cookie[] An array of cookies
145143
*/
146-
public function all()
144+
public function all(): array
147145
{
148146
$this->flushExpiredCookies();
149147

@@ -164,7 +162,7 @@ public function all()
164162
*
165163
* @return array An array of cookie values
166164
*/
167-
public function allValues(string $uri, bool $returnsRawValue = false)
165+
public function allValues(string $uri, bool $returnsRawValue = false): array
168166
{
169167
$this->flushExpiredCookies();
170168

@@ -201,7 +199,7 @@ public function allValues(string $uri, bool $returnsRawValue = false)
201199
*
202200
* @return array An array of cookie values
203201
*/
204-
public function allRawValues(string $uri)
202+
public function allRawValues(string $uri): array
205203
{
206204
return $this->allValues($uri, true);
207205
}

0 commit comments

Comments
 (0)