Skip to content

Commit af38cce

Browse files
committedOct 22, 2024
do not access typed properties before initialization
1 parent 887cb33 commit af38cce

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎AbstractBrowser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public function reload(): Crawler
531531
*/
532532
public function followRedirect(): Crawler
533533
{
534-
if (!$this->redirect) {
534+
if (!isset($this->redirect)) {
535535
throw new LogicException('The request was not redirected.');
536536
}
537537

‎Tests/AbstractBrowserTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\BrowserKit\CookieJar;
1616
use Symfony\Component\BrowserKit\Exception\BadMethodCallException;
1717
use Symfony\Component\BrowserKit\Exception\InvalidArgumentException;
18+
use Symfony\Component\BrowserKit\Exception\LogicException;
1819
use Symfony\Component\BrowserKit\History;
1920
use Symfony\Component\BrowserKit\Request;
2021
use Symfony\Component\BrowserKit\Response;
@@ -889,4 +890,14 @@ public function testInternalRequestNull()
889890

890891
$client->getInternalRequest();
891892
}
893+
894+
public function testFollowRedirectWithoutRequest()
895+
{
896+
$browser = $this->getBrowser();
897+
898+
$this->expectException(LogicException::class);
899+
$this->expectExceptionMessage('The request was not redirected.');
900+
901+
$browser->followRedirect();
902+
}
892903
}

0 commit comments

Comments
 (0)