Skip to content

Commit 8952815

Browse files
committed
PHP 8.4: Implicitly nullable parameter declarations deprecated
Fix using Zf1s\Compat\Types
1 parent be847a6 commit 8952815

14 files changed

Lines changed: 102 additions & 26 deletions

File tree

PHPUnit/Extensions/PhptTestCase.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use Zf1s\Compat\Types;
4+
25
/**
36
* PHPUnit
47
*
@@ -115,12 +118,14 @@ public function count()
115118
/**
116119
* Runs a test and collects its result in a TestResult instance.
117120
*
118-
* @param PHPUnit_Framework_TestResult $result
121+
* @param null|PHPUnit_Framework_TestResult $result
119122
* @param array $options
120123
* @return PHPUnit_Framework_TestResult
121124
*/
122-
public function run(PHPUnit_Framework_TestResult $result = NULL, array $options = array())
125+
public function run($result = NULL, array $options = array())
123126
{
127+
Types::isNullable('result', $result, 'PHPUnit_Framework_TestResult');
128+
124129
if (!class_exists('PEAR_RunTest', FALSE)) {
125130
throw new PHPUnit_Framework_Exception('Class PEAR_RunTest not found.');
126131
}

PHPUnit/Extensions/RepeatedTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use Zf1s\Compat\Types;
4+
25
/**
36
* PHPUnit
47
*
@@ -125,12 +128,14 @@ public function count()
125128
* Runs the decorated test and collects the
126129
* result in a TestResult.
127130
*
128-
* @param PHPUnit_Framework_TestResult $result
131+
* @param null|PHPUnit_Framework_TestResult $result
129132
* @return PHPUnit_Framework_TestResult
130133
* @throws PHPUnit_Framework_Exception
131134
*/
132-
public function run(PHPUnit_Framework_TestResult $result = NULL)
135+
public function run($result = NULL)
133136
{
137+
Types::isNullable('result', $result, 'PHPUnit_Framework_TestResult');
138+
134139
if ($result === NULL) {
135140
$result = $this->createResult();
136141
}

PHPUnit/Extensions/TestDecorator.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use Zf1s\Compat\Types;
4+
25
/**
36
* PHPUnit
47
*
@@ -134,11 +137,13 @@ public function getTest()
134137
* Runs the decorated test and collects the
135138
* result in a TestResult.
136139
*
137-
* @param PHPUnit_Framework_TestResult $result
140+
* @param null|PHPUnit_Framework_TestResult $result
138141
* @return PHPUnit_Framework_TestResult
139142
*/
140-
public function run(PHPUnit_Framework_TestResult $result = NULL)
143+
public function run($result = NULL)
141144
{
145+
Types::isNullable('result', $result, 'PHPUnit_Framework_TestResult');
146+
142147
if ($result === NULL) {
143148
$result = $this->createResult();
144149
}

PHPUnit/Framework/Constraint.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use Zf1s\Compat\Types;
4+
25
/**
36
* PHPUnit
47
*
@@ -123,11 +126,13 @@ public function count()
123126
*
124127
* @param mixed $other Evaluated value or object.
125128
* @param string $description Additional information about the test
126-
* @param PHPUnit_Framework_ComparisonFailure $comparisonFailure
129+
* @param null|PHPUnit_Framework_ComparisonFailure $comparisonFailure
127130
* @throws PHPUnit_Framework_ExpectationFailedException
128131
*/
129-
protected function fail($other, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL)
132+
protected function fail($other, $description, $comparisonFailure = NULL)
130133
{
134+
Types::isNullable('comparisonFailure', $comparisonFailure, 'PHPUnit_Framework_ComparisonFailure');
135+
131136
$failureDescription = sprintf(
132137
'Failed asserting that %s.',
133138
$this->failureDescription($other)

PHPUnit/Framework/Error.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use Zf1s\Compat\Types;
4+
25
/**
36
* PHPUnit
47
*
@@ -63,10 +66,12 @@ class PHPUnit_Framework_Error extends Exception
6366
* @param integer $code
6467
* @param string $file
6568
* @param integer $line
66-
* @param Exception $previous
69+
* @param null|Exception $previous
6770
*/
68-
public function __construct($message, $code, $file, $line, Exception $previous = NULL)
71+
public function __construct($message, $code, $file, $line, $previous = NULL)
6972
{
73+
Types::isNullable('previous', $previous, 'Exception');
74+
7075
parent::__construct($message, $code, $previous);
7176

7277
$this->file = $file;

PHPUnit/Framework/ExpectationFailedException.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use Zf1s\Compat\Types;
4+
25
/**
36
* PHPUnit
47
*
@@ -61,12 +64,15 @@
6164
class PHPUnit_Framework_ExpectationFailedException extends PHPUnit_Framework_AssertionFailedError
6265
{
6366
/**
64-
* @var PHPUnit_Framework_ComparisonFailure
67+
* @var null|PHPUnit_Framework_ComparisonFailure
6568
*/
6669
protected $comparisonFailure;
6770

68-
public function __construct($message, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL, Exception $previous = NULL)
71+
public function __construct($message, $comparisonFailure = NULL, $previous = NULL)
6972
{
73+
Types::isNullable('comparisonFailure', $comparisonFailure, 'PHPUnit_Framework_ComparisonFailure');
74+
Types::isNullable('previous', $previous, 'Exception');
75+
7076
$this->comparisonFailure = $comparisonFailure;
7177

7278
parent::__construct($message, 0, $previous);

PHPUnit/Framework/Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ interface PHPUnit_Framework_Test extends Countable
6262
* @param PHPUnit_Framework_TestResult $result
6363
* @return PHPUnit_Framework_TestResult
6464
*/
65-
public function run(PHPUnit_Framework_TestResult $result = NULL);
65+
public function run($result = NULL);
6666
}

PHPUnit/Framework/TestCase.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use Zf1s\Compat\Types;
4+
25
/**
36
* PHPUnit
47
*
@@ -672,12 +675,14 @@ public function hasFailed()
672675
* Runs the test case and collects the results in a TestResult object.
673676
* If no TestResult object is passed a new one will be created.
674677
*
675-
* @param PHPUnit_Framework_TestResult $result
678+
* @param null|PHPUnit_Framework_TestResult $result
676679
* @return PHPUnit_Framework_TestResult
677680
* @throws PHPUnit_Framework_Exception
678681
*/
679-
public function run(PHPUnit_Framework_TestResult $result = NULL)
682+
public function run($result = NULL)
680683
{
684+
Types::isNullable('result', $result, 'PHPUnit_Framework_TestResult');
685+
681686
if ($result === NULL) {
682687
$result = $this->createResult();
683688
}

PHPUnit/Framework/TestSuite.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use Zf1s\Compat\Types;
4+
25
/**
36
* PHPUnit
47
*
@@ -617,16 +620,18 @@ public function getGroups()
617620
/**
618621
* Runs the tests and collects their result in a TestResult.
619622
*
620-
* @param PHPUnit_Framework_TestResult $result
623+
* @param null|PHPUnit_Framework_TestResult $result
621624
* @param mixed $filter
622625
* @param array $groups
623626
* @param array $excludeGroups
624627
* @param boolean $processIsolation
625628
* @return PHPUnit_Framework_TestResult
626629
* @throws PHPUnit_Framework_Exception
627630
*/
628-
public function run(PHPUnit_Framework_TestResult $result = NULL, $filter = FALSE, array $groups = array(), array $excludeGroups = array(), $processIsolation = FALSE)
631+
public function run($result = NULL, $filter = FALSE, array $groups = array(), array $excludeGroups = array(), $processIsolation = FALSE)
629632
{
633+
Types::isNullable('result', $result, 'PHPUnit_Framework_TestResult');
634+
630635
if ($result === NULL) {
631636
$result = $this->createResult();
632637
}

PHPUnit/TextUI/TestRunner.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<?php
2+
3+
use Zf1s\Compat\Types;
4+
25
/**
36
* PHPUnit
47
*
@@ -82,12 +85,15 @@ class PHPUnit_TextUI_TestRunner extends PHPUnit_Runner_BaseTestRunner
8285
protected static $versionStringPrinted = FALSE;
8386

8487
/**
85-
* @param PHPUnit_Runner_TestSuiteLoader $loader
86-
* @param PHP_CodeCoverage_Filter $filter
88+
* @param null|PHPUnit_Runner_TestSuiteLoader $loader
89+
* @param null|PHP_CodeCoverage_Filter $filter
8790
* @since Method available since Release 3.4.0
8891
*/
89-
public function __construct(PHPUnit_Runner_TestSuiteLoader $loader = NULL, PHP_CodeCoverage_Filter $filter = NULL)
92+
public function __construct($loader = NULL, $filter = NULL)
9093
{
94+
Types::isNullable('loader', $loader, 'PHPUnit_Runner_TestSuiteLoader');
95+
Types::isNullable('filter', $filter, 'PHP_CodeCoverage_Filter');
96+
9197
if ($filter === NULL) {
9298
$filter = new PHP_CodeCoverage_Filter;
9399
}

0 commit comments

Comments
 (0)