Skip to content

Commit

Permalink
Declare nullable parameter types explicitly for PHP 8.4 compatibility (
Browse files Browse the repository at this point in the history
  • Loading branch information
W0rma authored Jul 29, 2024
1 parent d9fbf1c commit 12dadcf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/Codeception/Constraint/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function matches($nodes): bool
* @param string $selector
* @param ComparisonFailure|null $comparisonFailure
*/
protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): never
protected function fail($nodes, $selector, ?ComparisonFailure $comparisonFailure = null): never
{
if (!$nodes->count()) {
throw new ElementNotFound($selector, 'Element located either by name, CSS or XPath');
Expand Down Expand Up @@ -77,7 +77,7 @@ protected function failureDescription($other): string
return $description;
}

protected function nodesList(SymfonyDomCrawler $domCrawler, string $contains = null): string
protected function nodesList(SymfonyDomCrawler $domCrawler, ?string $contains = null): string
{
$output = '';
foreach ($domCrawler as $node) {
Expand Down
2 changes: 1 addition & 1 deletion src/Codeception/Constraint/CrawlerNot.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function matches($nodes): bool
* @param string $selector
* @param ComparisonFailure|null $comparisonFailure
*/
protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): never
protected function fail($nodes, $selector, ?ComparisonFailure $comparisonFailure = null): never
{
if (!$this->string) {
throw new ExpectationFailedException(
Expand Down
18 changes: 9 additions & 9 deletions src/Codeception/Lib/InnerBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function _request(
array $parameters = [],
array $files = [],
array $server = [],
string $content = null
?string $content = null
): ?string {
$this->clientRequest($method, $uri, $parameters, $files, $server, $content);
return $this->_getResponseContent();
Expand Down Expand Up @@ -189,7 +189,7 @@ protected function clientRequest(
array $parameters = [],
array $files = [],
array $server = [],
string $content = null,
?string $content = null,
bool $changeHistory = true
): SymfonyCrawler {
$this->debugSection("Request Headers", $this->headers);
Expand Down Expand Up @@ -280,7 +280,7 @@ public function _loadPage(
array $parameters = [],
array $files = [],
array $server = [],
string $content = null
?string $content = null
): void {
$this->crawler = $this->clientRequest($method, $uri, $parameters, $files, $server, $content);
$this->baseUrl = $this->retrieveBaseUrl();
Expand Down Expand Up @@ -562,7 +562,7 @@ public function dontSeeInSource(string $raw): void
$this->assertPageSourceNotContains($raw);
}

public function seeLink(string $text, string $url = null): void
public function seeLink(string $text, ?string $url = null): void
{
$crawler = $this->getCrawler()->selectLink($text);
if ($crawler->count() === 0) {
Expand Down Expand Up @@ -633,7 +633,7 @@ public function dontSeeCurrentUrlMatches(string $uri): void
$this->assertNotRegExp($uri, $this->_getCurrentUri());
}

public function grabFromCurrentUrl(string $uri = null): mixed
public function grabFromCurrentUrl(?string $uri = null): mixed
{
if (!$uri) {
return $this->_getCurrentUri();
Expand Down Expand Up @@ -892,7 +892,7 @@ protected function setCheckboxBoolValues(Crawler $form, array $params): array
* form
* @param string|null $button the name of a submit button in the form
*/
protected function proceedSubmitForm(Crawler $frmCrawl, array $params, string $button = null): void
protected function proceedSubmitForm(Crawler $frmCrawl, array $params, ?string $button = null): void
{
$url = null;
$form = $this->getFormFor($frmCrawl);
Expand Down Expand Up @@ -939,7 +939,7 @@ protected function proceedSubmitForm(Crawler $frmCrawl, array $params, string $b
$this->forms = [];
}

public function submitForm($selector, array $params, string $button = null): void
public function submitForm($selector, array $params, ?string $button = null): void
{
$form = $this->match($selector)->first();
if (count($form) === 0) {
Expand Down Expand Up @@ -1374,7 +1374,7 @@ protected function debugResponse($url): void
$this->debugSection('Response Headers', $this->getRunningClient()->getInternalResponse()->getHeaders());
}

public function makeHtmlSnapshot(string $name = null): void
public function makeHtmlSnapshot(?string $name = null): void
{
if (empty($name)) {
$name = uniqid(date("Y-m-d_H-i-s_"), true);
Expand Down Expand Up @@ -1487,7 +1487,7 @@ public function grabAttributeFrom($cssOrXpath, string $attribute): mixed
return $nodes->first()->attr($attribute);
}

public function grabMultiple($cssOrXpath, string $attribute = null): array
public function grabMultiple($cssOrXpath, ?string $attribute = null): array
{
$result = [];
$nodes = $this->match($cssOrXpath);
Expand Down

0 comments on commit 12dadcf

Please sign in to comment.