From 12dadcf658a5c33797798efe0b8123b20a8307de Mon Sep 17 00:00:00 2001 From: Dieter Beck Date: Mon, 29 Jul 2024 06:22:00 +0200 Subject: [PATCH] Declare nullable parameter types explicitly for PHP 8.4 compatibility (#70) --- src/Codeception/Constraint/Crawler.php | 4 ++-- src/Codeception/Constraint/CrawlerNot.php | 2 +- src/Codeception/Lib/InnerBrowser.php | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Codeception/Constraint/Crawler.php b/src/Codeception/Constraint/Crawler.php index 9da0d42..0b7c0fa 100644 --- a/src/Codeception/Constraint/Crawler.php +++ b/src/Codeception/Constraint/Crawler.php @@ -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'); @@ -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) { diff --git a/src/Codeception/Constraint/CrawlerNot.php b/src/Codeception/Constraint/CrawlerNot.php index 0333f52..37e5765 100644 --- a/src/Codeception/Constraint/CrawlerNot.php +++ b/src/Codeception/Constraint/CrawlerNot.php @@ -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( diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php index f124345..25cc57e 100644 --- a/src/Codeception/Lib/InnerBrowser.php +++ b/src/Codeception/Lib/InnerBrowser.php @@ -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(); @@ -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); @@ -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(); @@ -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) { @@ -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(); @@ -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); @@ -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) { @@ -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); @@ -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);