Skip to content

Commit

Permalink
do not access typed properties before initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Oct 22, 2024
1 parent 887cb33 commit af38cce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion AbstractBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public function reload(): Crawler
*/
public function followRedirect(): Crawler
{
if (!$this->redirect) {
if (!isset($this->redirect)) {
throw new LogicException('The request was not redirected.');
}

Expand Down
11 changes: 11 additions & 0 deletions Tests/AbstractBrowserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\BrowserKit\CookieJar;
use Symfony\Component\BrowserKit\Exception\BadMethodCallException;
use Symfony\Component\BrowserKit\Exception\InvalidArgumentException;
use Symfony\Component\BrowserKit\Exception\LogicException;
use Symfony\Component\BrowserKit\History;
use Symfony\Component\BrowserKit\Request;
use Symfony\Component\BrowserKit\Response;
Expand Down Expand Up @@ -889,4 +890,14 @@ public function testInternalRequestNull()

$client->getInternalRequest();
}

public function testFollowRedirectWithoutRequest()
{
$browser = $this->getBrowser();

$this->expectException(LogicException::class);
$this->expectExceptionMessage('The request was not redirected.');

$browser->followRedirect();
}
}

0 comments on commit af38cce

Please sign in to comment.