Skip to content

Commit

Permalink
Fix PHP RFC: Deprecate implicitly nullable parameter types
Browse files Browse the repository at this point in the history
  • Loading branch information
andypost committed Apr 30, 2024
1 parent d8527fd commit c36a30d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Element/ElementFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/DriverException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ElementHtmlException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ExpectationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/UnsupportedDriverActionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 9 additions & 9 deletions src/WebAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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();
Expand All @@ -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);

Expand All @@ -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);

Expand Down

0 comments on commit c36a30d

Please sign in to comment.