From c36a30da8c8d006e2bc1ff10b33c23dd7436c947 Mon Sep 17 00:00:00 2001 From: Andy Postnikov Date: Tue, 30 Apr 2024 06:46:59 +0200 Subject: [PATCH 1/2] Fix PHP RFC: Deprecate implicitly nullable parameter types --- src/Element/ElementFinder.php | 2 +- src/Exception/DriverException.php | 2 +- src/Exception/ElementHtmlException.php | 2 +- src/Exception/ExpectationException.php | 2 +- .../UnsupportedDriverActionException.php | 2 +- src/Session.php | 2 +- src/WebAssert.php | 18 +++++++++--------- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Element/ElementFinder.php b/src/Element/ElementFinder.php index 84195c514..98e0c9a95 100644 --- a/src/Element/ElementFinder.php +++ b/src/Element/ElementFinder.php @@ -33,7 +33,7 @@ class ElementFinder */ private $xpathManipulator; - public function __construct(DriverInterface $driver, SelectorsHandler $selectorsHandler, Manipulator $xpathManipulator = null) + public function __construct(DriverInterface $driver, SelectorsHandler $selectorsHandler, ?Manipulator $xpathManipulator = null) { $this->driver = $driver; $this->selectorsHandler = $selectorsHandler; diff --git a/src/Exception/DriverException.php b/src/Exception/DriverException.php index 131e5b374..dc26d6cf4 100644 --- a/src/Exception/DriverException.php +++ b/src/Exception/DriverException.php @@ -24,7 +24,7 @@ class DriverException extends Exception * @param int $code * @param \Throwable|null $previous */ - public function __construct(string $message, int $code = 0, \Throwable $previous = null) + public function __construct(string $message, int $code = 0, ?\Throwable $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Exception/ElementHtmlException.php b/src/Exception/ElementHtmlException.php index 08f6c97d9..6d7a025f9 100644 --- a/src/Exception/ElementHtmlException.php +++ b/src/Exception/ElementHtmlException.php @@ -36,7 +36,7 @@ class ElementHtmlException extends ExpectationException * @param Element $element element * @param \Throwable|null $exception expectation exception */ - public function __construct(string $message, $driver, Element $element, \Throwable $exception = null) + public function __construct(string $message, $driver, Element $element, ?\Throwable $exception = null) { $this->element = $element; diff --git a/src/Exception/ExpectationException.php b/src/Exception/ExpectationException.php index 791092552..c83a53a3e 100644 --- a/src/Exception/ExpectationException.php +++ b/src/Exception/ExpectationException.php @@ -38,7 +38,7 @@ class ExpectationException extends Exception * @param DriverInterface|Session $driver driver instance (or session for BC) * @param \Throwable|null $exception expectation exception */ - public function __construct(string $message, $driver, \Throwable $exception = null) + public function __construct(string $message, $driver, ?\Throwable $exception = null) { if ($driver instanceof Session) { @trigger_error('Passing a Session object to the ExpectationException constructor is deprecated as of Mink 1.7. Pass the driver instead.', E_USER_DEPRECATED); diff --git a/src/Exception/UnsupportedDriverActionException.php b/src/Exception/UnsupportedDriverActionException.php index 13f1708ff..45fb83be7 100644 --- a/src/Exception/UnsupportedDriverActionException.php +++ b/src/Exception/UnsupportedDriverActionException.php @@ -26,7 +26,7 @@ class UnsupportedDriverActionException extends DriverException * @param DriverInterface $driver driver instance * @param \Throwable|null $previous previous exception */ - public function __construct(string $template, DriverInterface $driver, \Throwable $previous = null) + public function __construct(string $template, DriverInterface $driver, ?\Throwable $previous = null) { $message = sprintf($template, get_class($driver)); diff --git a/src/Session.php b/src/Session.php index 71a86bdf6..78e9f12fc 100644 --- a/src/Session.php +++ b/src/Session.php @@ -39,7 +39,7 @@ class Session */ private $selectorsHandler; - public function __construct(DriverInterface $driver, SelectorsHandler $selectorsHandler = null) + public function __construct(DriverInterface $driver, ?SelectorsHandler $selectorsHandler = null) { $this->driver = $driver; $this->selectorsHandler = $selectorsHandler ?? new SelectorsHandler(); diff --git a/src/WebAssert.php b/src/WebAssert.php index 43c2f3727..05e13b9b7 100644 --- a/src/WebAssert.php +++ b/src/WebAssert.php @@ -426,7 +426,7 @@ public function responseNotMatches(string $regex) * * @throws ExpectationException */ - public function elementsCount(string $selectorType, $selector, int $count, ElementInterface $container = null) + public function elementsCount(string $selectorType, $selector, int $count, ?ElementInterface $container = null) { $container = $container ?: $this->session->getPage(); $nodes = $container->findAll($selectorType, $selector); @@ -452,7 +452,7 @@ public function elementsCount(string $selectorType, $selector, int $count, Eleme * * @throws ElementNotFoundException */ - public function elementExists(string $selectorType, $selector, ElementInterface $container = null) + public function elementExists(string $selectorType, $selector, ?ElementInterface $container = null) { $container = $container ?: $this->session->getPage(); $node = $container->find($selectorType, $selector); @@ -479,7 +479,7 @@ public function elementExists(string $selectorType, $selector, ElementInterface * * @throws ExpectationException */ - public function elementNotExists(string $selectorType, $selector, ElementInterface $container = null) + public function elementNotExists(string $selectorType, $selector, ?ElementInterface $container = null) { $container = $container ?: $this->session->getPage(); $node = $container->find($selectorType, $selector); @@ -722,7 +722,7 @@ public function elementAttributeNotContains(string $selectorType, $selector, str * * @throws ElementNotFoundException */ - public function fieldExists(string $field, TraversableElement $container = null) + public function fieldExists(string $field, ?TraversableElement $container = null) { $container = $container ?: $this->session->getPage(); $node = $container->findField($field); @@ -744,7 +744,7 @@ public function fieldExists(string $field, TraversableElement $container = null) * * @throws ExpectationException */ - public function fieldNotExists(string $field, TraversableElement $container = null) + public function fieldNotExists(string $field, ?TraversableElement $container = null) { $container = $container ?: $this->session->getPage(); $node = $container->findField($field); @@ -763,7 +763,7 @@ public function fieldNotExists(string $field, TraversableElement $container = nu * * @throws ExpectationException */ - public function fieldValueEquals(string $field, string $value, TraversableElement $container = null) + public function fieldValueEquals(string $field, string $value, ?TraversableElement $container = null) { $node = $this->fieldExists($field, $container); @@ -792,7 +792,7 @@ public function fieldValueEquals(string $field, string $value, TraversableElemen * * @throws ExpectationException */ - public function fieldValueNotEquals(string $field, string $value, TraversableElement $container = null) + public function fieldValueNotEquals(string $field, string $value, ?TraversableElement $container = null) { $node = $this->fieldExists($field, $container); $actual = $node->getValue(); @@ -819,7 +819,7 @@ public function fieldValueNotEquals(string $field, string $value, TraversableEle * * @throws ExpectationException */ - public function checkboxChecked(string $field, TraversableElement $container = null) + public function checkboxChecked(string $field, ?TraversableElement $container = null) { $node = $this->fieldExists($field, $container); @@ -836,7 +836,7 @@ public function checkboxChecked(string $field, TraversableElement $container = n * * @throws ExpectationException */ - public function checkboxNotChecked(string $field, TraversableElement $container = null) + public function checkboxNotChecked(string $field, ?TraversableElement $container = null) { $node = $this->fieldExists($field, $container); From 4a730e15d7f0b583b67b15103837f61075a4276d Mon Sep 17 00:00:00 2001 From: Andy Postnikov Date: Wed, 21 Aug 2024 03:08:06 +0200 Subject: [PATCH 2/2] Add PHP 8.4 to test matrix --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6122d1469..e5e89bdcf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -39,7 +39,7 @@ jobs: strategy: matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] composer_flags: [ '' ] minimum_stability: [ '' ] symfony_deprecations_helper: [ '' ]