Skip to content

Commit 9f9537a

Browse files
authored
Declare nullable parameter types explicitly for PHP 8.4 compatibility (#134)
1 parent ba43d1e commit 9f9537a

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/Codeception/Constraint/WebDriver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function matches($nodes): bool
4747
* @param string|array|WebDriverBy $selector
4848
* @param ComparisonFailure|null $comparisonFailure
4949
*/
50-
protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): never
50+
protected function fail($nodes, $selector, ?ComparisonFailure $comparisonFailure = null): never
5151
{
5252
if (count($nodes) === 0) {
5353
throw new ElementNotFound($selector, 'Element located either by name, CSS or XPath');
@@ -89,7 +89,7 @@ protected function failureDescription($nodes): string
8989
* @param string|null $contains
9090
* @return string
9191
*/
92-
protected function nodesList(array $nodes, string $contains = null): string
92+
protected function nodesList(array $nodes, ?string $contains = null): string
9393
{
9494
$output = "";
9595
foreach ($nodes as $node) {

src/Codeception/Constraint/WebDriverNot.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function matches($nodes): bool
2525
* @param string|array|WebDriverBy $selector
2626
* @param ComparisonFailure|null $comparisonFailure
2727
*/
28-
protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null): never
28+
protected function fail($nodes, $selector, ?ComparisonFailure $comparisonFailure = null): never
2929
{
3030
if (!is_string($selector) || strpos($selector, "'") === false) {
3131
$selector = Locator::humanReadableString($selector);

src/Codeception/Module/WebDriver.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ public function _failed(TestInterface $test, $fail)
659659
/**
660660
* Print out latest Selenium Logs in debug mode
661661
*/
662-
public function debugWebDriverLogs(TestInterface $test = null): void
662+
public function debugWebDriverLogs(?TestInterface $test = null): void
663663
{
664664
if ($this->webDriver === null) {
665665
$this->debug('WebDriver::debugWebDriverLogs method has been called when webDriver is not set');
@@ -903,7 +903,7 @@ public function _savePageSource(string $filename): void
903903
* // saved to: tests/_output/debug/2017-05-26_14-24-11_4b3403665fea6.png
904904
* ```
905905
*/
906-
public function makeScreenshot(string $name = null): void
906+
public function makeScreenshot(?string $name = null): void
907907
{
908908
if (empty($name)) {
909909
$name = uniqid(date("Y-m-d_H-i-s_"));
@@ -933,7 +933,7 @@ public function makeScreenshot(string $name = null): void
933933
*
934934
* @param WebDriverBy|array $selector
935935
*/
936-
public function makeElementScreenshot($selector, string $name = null): void
936+
public function makeElementScreenshot($selector, ?string $name = null): void
937937
{
938938
if (empty($name)) {
939939
$name = uniqid(date("Y-m-d_H-i-s_"));
@@ -949,7 +949,7 @@ public function makeElementScreenshot($selector, string $name = null): void
949949
$this->debugSection('Screenshot Saved', "file://{$screenName}");
950950
}
951951

952-
public function makeHtmlSnapshot(string $name = null): void
952+
public function makeHtmlSnapshot(?string $name = null): void
953953
{
954954
if (empty($name)) {
955955
$name = uniqid(date("Y-m-d_H-i-s_"));
@@ -1327,7 +1327,7 @@ protected function findField($selector): WebDriverElement
13271327
return reset($arr);
13281328
}
13291329

1330-
public function seeLink(string $text, string $url = null): void
1330+
public function seeLink(string $text, ?string $url = null): void
13311331
{
13321332
$this->enableImplicitWait();
13331333
$nodes = $this->getBaseElement()->findElements(WebDriverBy::partialLinkText($text));
@@ -2768,7 +2768,7 @@ public function executeInSelenium(Closure $function)
27682768
* });
27692769
* ```
27702770
*/
2771-
public function switchToWindow(string $name = null): void
2771+
public function switchToWindow(?string $name = null): void
27722772
{
27732773
$this->webDriver->switchTo()->window($name);
27742774
}
@@ -2795,7 +2795,7 @@ public function switchToWindow(string $name = null): void
27952795
*
27962796
* @param string|null $locator (name, CSS or XPath)
27972797
*/
2798-
public function switchToIFrame(string $locator = null): void
2798+
public function switchToIFrame(?string $locator = null): void
27992799
{
28002800
$this->findAndSwitchToFrame($locator, 'iframe');
28012801
}
@@ -2822,12 +2822,12 @@ public function switchToIFrame(string $locator = null): void
28222822
*
28232823
* @param string|null $locator (name, CSS or XPath)
28242824
*/
2825-
public function switchToFrame(string $locator = null): void
2825+
public function switchToFrame(?string $locator = null): void
28262826
{
28272827
$this->findAndSwitchToFrame($locator);
28282828
}
28292829

2830-
private function findAndSwitchToFrame(string $locator = null, string $tag = 'frame'): void
2830+
private function findAndSwitchToFrame(?string $locator = null, string $tag = 'frame'): void
28312831
{
28322832
if ($locator === null) {
28332833
$this->webDriver->switchTo()->defaultContent();
@@ -2962,7 +2962,7 @@ public function dragAndDrop($source, $target): void
29622962
* @param null|string|array|WebDriverBy $cssOrXPath css or xpath of the web element
29632963
* @throws ElementNotFound
29642964
*/
2965-
public function moveMouseOver($cssOrXPath = null, int $offsetX = null, int $offsetY = null): void
2965+
public function moveMouseOver($cssOrXPath = null, ?int $offsetX = null, ?int $offsetY = null): void
29662966
{
29672967
$where = null;
29682968
if (null !== $cssOrXPath) {
@@ -2991,7 +2991,7 @@ public function moveMouseOver($cssOrXPath = null, int $offsetX = null, int $offs
29912991
*
29922992
* @throws ElementNotFound
29932993
*/
2994-
public function clickWithLeftButton($cssOrXPath = null, int $offsetX = null, int $offsetY = null): void
2994+
public function clickWithLeftButton($cssOrXPath = null, ?int $offsetX = null, ?int $offsetY = null): void
29952995
{
29962996
$this->moveMouseOver($cssOrXPath, $offsetX, $offsetY);
29972997
$this->webDriver->getMouse()->click();
@@ -3014,7 +3014,7 @@ public function clickWithLeftButton($cssOrXPath = null, int $offsetX = null, int
30143014
* @param null|string|array|WebDriverBy $cssOrXPath css or xpath of the web element (body by default).
30153015
* @throws ElementNotFound
30163016
*/
3017-
public function clickWithRightButton($cssOrXPath = null, int $offsetX = null, int $offsetY = null): void
3017+
public function clickWithRightButton($cssOrXPath = null, ?int $offsetX = null, ?int $offsetY = null): void
30183018
{
30193019
$this->moveMouseOver($cssOrXPath, $offsetX, $offsetY);
30203020
$this->webDriver->getMouse()->contextClick();
@@ -3487,7 +3487,7 @@ protected function isPhantom(): bool
34873487
*
34883488
* @param string|array|WebDriverBy $selector
34893489
*/
3490-
public function scrollTo($selector, int $offsetX = null, int $offsetY = null): void
3490+
public function scrollTo($selector, ?int $offsetX = null, ?int $offsetY = null): void
34913491
{
34923492
$el = $this->matchFirstOrFail($this->getBaseElement(), $selector);
34933493
$x = $el->getLocation()->getX() + $offsetX;

0 commit comments

Comments
 (0)