@@ -53,7 +53,7 @@ class Assert
53
53
/**
54
54
* Asserts that two values are equal and have the same type and identity of objects.
55
55
*/
56
- public static function same ($ expected , $ actual , string $ description = null ): void
56
+ public static function same ($ expected , $ actual , ? string $ description = null ): void
57
57
{
58
58
self ::$ counter ++;
59
59
if ($ actual !== $ expected ) {
@@ -65,7 +65,7 @@ public static function same($expected, $actual, string $description = null): voi
65
65
/**
66
66
* Asserts that two values are not equal or do not have the same type and identity of objects.
67
67
*/
68
- public static function notSame ($ expected , $ actual , string $ description = null ): void
68
+ public static function notSame ($ expected , $ actual , ? string $ description = null ): void
69
69
{
70
70
self ::$ counter ++;
71
71
if ($ actual === $ expected ) {
@@ -78,7 +78,7 @@ public static function notSame($expected, $actual, string $description = null):
78
78
* Asserts that two values are equal and checks expectations. The identity of objects,
79
79
* the order of keys in the arrays and marginally different floats are ignored.
80
80
*/
81
- public static function equal ($ expected , $ actual , string $ description = null ): void
81
+ public static function equal ($ expected , $ actual , ? string $ description = null ): void
82
82
{
83
83
self ::$ counter ++;
84
84
if (!self ::isEqual ($ expected , $ actual )) {
@@ -91,7 +91,7 @@ public static function equal($expected, $actual, string $description = null): vo
91
91
* Asserts that two values are not equal and checks expectations. The identity of objects,
92
92
* the order of keys in the arrays and marginally different floats are ignored.
93
93
*/
94
- public static function notEqual ($ expected , $ actual , string $ description = null ): void
94
+ public static function notEqual ($ expected , $ actual , ? string $ description = null ): void
95
95
{
96
96
self ::$ counter ++;
97
97
try {
@@ -110,7 +110,7 @@ public static function notEqual($expected, $actual, string $description = null):
110
110
* @param mixed $needle
111
111
* @param array|string $actual
112
112
*/
113
- public static function contains ($ needle , $ actual , string $ description = null ): void
113
+ public static function contains ($ needle , $ actual , ? string $ description = null ): void
114
114
{
115
115
self ::$ counter ++;
116
116
if (is_array ($ actual )) {
@@ -135,7 +135,7 @@ public static function contains($needle, $actual, string $description = null): v
135
135
* @param mixed $needle
136
136
* @param array|string $actual
137
137
*/
138
- public static function notContains ($ needle , $ actual , string $ description = null ): void
138
+ public static function notContains ($ needle , $ actual , ? string $ description = null ): void
139
139
{
140
140
self ::$ counter ++;
141
141
if (is_array ($ actual )) {
@@ -159,7 +159,7 @@ public static function notContains($needle, $actual, string $description = null)
159
159
* Asserts that a haystack has an expected key.
160
160
* @param string|int $key
161
161
*/
162
- public static function hasKey ($ key , array $ actual , string $ description = null ): void
162
+ public static function hasKey ($ key , array $ actual , ? string $ description = null ): void
163
163
{
164
164
self ::$ counter ++;
165
165
if (!is_int ($ key ) && !is_string ($ key )) {
@@ -175,7 +175,7 @@ public static function hasKey($key, array $actual, string $description = null):
175
175
* Asserts that a haystack doesn't have an expected key.
176
176
* @param string|int $key
177
177
*/
178
- public static function hasNotKey ($ key , array $ actual , string $ description = null ): void
178
+ public static function hasNotKey ($ key , array $ actual , ? string $ description = null ): void
179
179
{
180
180
self ::$ counter ++;
181
181
if (!is_int ($ key ) && !is_string ($ key )) {
@@ -191,7 +191,7 @@ public static function hasNotKey($key, array $actual, string $description = null
191
191
* Asserts that a value is true.
192
192
* @param mixed $actual
193
193
*/
194
- public static function true ($ actual , string $ description = null ): void
194
+ public static function true ($ actual , ? string $ description = null ): void
195
195
{
196
196
self ::$ counter ++;
197
197
if ($ actual !== true ) {
@@ -204,7 +204,7 @@ public static function true($actual, string $description = null): void
204
204
* Asserts that a value is false.
205
205
* @param mixed $actual
206
206
*/
207
- public static function false ($ actual , string $ description = null ): void
207
+ public static function false ($ actual , ? string $ description = null ): void
208
208
{
209
209
self ::$ counter ++;
210
210
if ($ actual !== false ) {
@@ -217,7 +217,7 @@ public static function false($actual, string $description = null): void
217
217
* Asserts that a value is null.
218
218
* @param mixed $actual
219
219
*/
220
- public static function null ($ actual , string $ description = null ): void
220
+ public static function null ($ actual , ? string $ description = null ): void
221
221
{
222
222
self ::$ counter ++;
223
223
if ($ actual !== null ) {
@@ -230,7 +230,7 @@ public static function null($actual, string $description = null): void
230
230
* Asserts that a value is not null.
231
231
* @param mixed $actual
232
232
*/
233
- public static function notNull ($ actual , string $ description = null ): void
233
+ public static function notNull ($ actual , ? string $ description = null ): void
234
234
{
235
235
self ::$ counter ++;
236
236
if ($ actual === null ) {
@@ -243,7 +243,7 @@ public static function notNull($actual, string $description = null): void
243
243
* Asserts that a value is Not a Number.
244
244
* @param mixed $actual
245
245
*/
246
- public static function nan ($ actual , string $ description = null ): void
246
+ public static function nan ($ actual , ? string $ description = null ): void
247
247
{
248
248
self ::$ counter ++;
249
249
if (!is_float ($ actual ) || !is_nan ($ actual )) {
@@ -256,7 +256,7 @@ public static function nan($actual, string $description = null): void
256
256
* Asserts that a value is truthy.
257
257
* @param mixed $actual
258
258
*/
259
- public static function truthy ($ actual , string $ description = null ): void
259
+ public static function truthy ($ actual , ? string $ description = null ): void
260
260
{
261
261
self ::$ counter ++;
262
262
if (!$ actual ) {
@@ -269,7 +269,7 @@ public static function truthy($actual, string $description = null): void
269
269
* Asserts that a value is falsey.
270
270
* @param mixed $actual
271
271
*/
272
- public static function falsey ($ actual , string $ description = null ): void
272
+ public static function falsey ($ actual , ? string $ description = null ): void
273
273
{
274
274
self ::$ counter ++;
275
275
if ($ actual ) {
@@ -282,7 +282,7 @@ public static function falsey($actual, string $description = null): void
282
282
* Asserts the number of items in an array or Countable.
283
283
* @param array|\Countable $value
284
284
*/
285
- public static function count (int $ count , $ value , string $ description = null ): void
285
+ public static function count (int $ count , $ value , ? string $ description = null ): void
286
286
{
287
287
self ::$ counter ++;
288
288
if (!$ value instanceof \Countable && !is_array ($ value )) {
@@ -299,7 +299,7 @@ public static function count(int $count, $value, string $description = null): vo
299
299
* @param string|object $type
300
300
* @param mixed $value
301
301
*/
302
- public static function type ($ type , $ value , string $ description = null ): void
302
+ public static function type ($ type , $ value , ? string $ description = null ): void
303
303
{
304
304
self ::$ counter ++;
305
305
if (!is_object ($ type ) && !is_string ($ type )) {
@@ -329,7 +329,7 @@ public static function type($type, $value, string $description = null): void
329
329
public static function exception (
330
330
callable $ function ,
331
331
string $ class ,
332
- string $ message = null ,
332
+ ? string $ message = null ,
333
333
$ code = null
334
334
): ?\Throwable {
335
335
self ::$ counter ++;
@@ -359,7 +359,7 @@ public static function exception(
359
359
/**
360
360
* Asserts that a function throws exception of given type and its message matches given pattern. Alias for exception().
361
361
*/
362
- public static function throws (callable $ function , string $ class , string $ message = null , $ code = null ): ?\Throwable
362
+ public static function throws (callable $ function , string $ class , ? string $ message = null , $ code = null ): ?\Throwable
363
363
{
364
364
return self ::exception ($ function , $ class , $ message , $ code );
365
365
}
@@ -372,7 +372,7 @@ public static function throws(callable $function, string $class, string $message
372
372
* @throws \Exception
373
373
* @throws \Exception
374
374
*/
375
- public static function error (callable $ function , $ expectedType , string $ expectedMessage = null ): ?\Throwable
375
+ public static function error (callable $ function , $ expectedType , ? string $ expectedMessage = null ): ?\Throwable
376
376
{
377
377
if (is_string ($ expectedType ) && !preg_match ('#^E_[A-Z_]+$#D ' , $ expectedType )) {
378
378
return static ::exception ($ function , $ expectedType , $ expectedMessage );
@@ -458,7 +458,7 @@ public static function noError(callable $function): void
458
458
* %h% one or more HEX digits
459
459
* @param string $pattern mask|regexp; only delimiters ~ and # are supported for regexp
460
460
*/
461
- public static function match (string $ pattern , $ actual , string $ description = null ): void
461
+ public static function match (string $ pattern , $ actual , ? string $ description = null ): void
462
462
{
463
463
self ::$ counter ++;
464
464
if (!is_scalar ($ actual )) {
@@ -477,7 +477,7 @@ public static function match(string $pattern, $actual, string $description = nul
477
477
/**
478
478
* Asserts that a string matches a given pattern stored in file.
479
479
*/
480
- public static function matchFile (string $ file , $ actual , string $ description = null ): void
480
+ public static function matchFile (string $ file , $ actual , ? string $ description = null ): void
481
481
{
482
482
self ::$ counter ++;
483
483
$ pattern = @file_get_contents ($ file ); // @ is escalated to exception
@@ -504,8 +504,8 @@ public static function fail(
504
504
string $ message ,
505
505
$ actual = null ,
506
506
$ expected = null ,
507
- \Throwable $ previous = null ,
508
- string $ outputName = null
507
+ ? \Throwable $ previous = null ,
508
+ ? string $ outputName = null
509
509
): void {
510
510
$ e = new AssertException ($ message , $ expected , $ actual , $ previous );
511
511
$ e ->outputName = $ outputName ;
@@ -517,7 +517,7 @@ public static function fail(
517
517
}
518
518
519
519
520
- private static function describe (string $ reason , string $ description = null ): string
520
+ private static function describe (string $ reason , ? string $ description = null ): string
521
521
{
522
522
return ($ description ? $ description . ': ' : '' ) . $ reason ;
523
523
}
0 commit comments