Skip to content

Commit 06a5a1f

Browse files
authored
ext/spl: applied fixers to improve test robustness (#23058)
1 parent aa8b895 commit 06a5a1f

171 files changed

Lines changed: 688 additions & 688 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎ext/spl/tests/ArrayObject/ArrayObject_exchange_array_during_sorting.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $ao->uasort(function($a, $b) use ($ao, &$i) {
1010
try {
1111
$ao->exchangeArray([4, 5, 6]);
1212
} catch (Error $e) {
13-
echo $e->getMessage(), "\n";
13+
echo $e::class, ': ', $e->getMessage(), "\n";
1414
}
1515
var_dump($ao);
1616
}
@@ -19,7 +19,7 @@ $ao->uasort(function($a, $b) use ($ao, &$i) {
1919

2020
?>
2121
--EXPECT--
22-
Modification of ArrayObject during sorting is prohibited
22+
Error: Modification of ArrayObject during sorting is prohibited
2323
object(ArrayObject)#1 (1) {
2424
["storage":"ArrayObject":private]=>
2525
array(3) {

‎ext/spl/tests/ArrayObject/ArrayObject_illegal_offset.phpt‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@ $ao = new ArrayObject([1, 2, 3]);
77
try {
88
var_dump($ao[[]]);
99
} catch (TypeError $e) {
10-
echo $e->getMessage(), "\n";
10+
echo $e::class, ': ', $e->getMessage(), "\n";
1111
}
1212
try {
1313
$ao[[]] = new stdClass;
1414
} catch (TypeError $e) {
15-
echo $e->getMessage(), "\n";
15+
echo $e::class, ': ', $e->getMessage(), "\n";
1616
}
1717
try {
1818
$ref =& $ao[[]];
1919
} catch (TypeError $e) {
20-
echo $e->getMessage(), "\n";
20+
echo $e::class, ': ', $e->getMessage(), "\n";
2121
}
2222
try {
2323
var_dump(isset($ao[[]]));
2424
} catch (TypeError $e) {
25-
echo $e->getMessage(), "\n";
25+
echo $e::class, ': ', $e->getMessage(), "\n";
2626
}
2727
try {
2828
unset($ao[[]]);
2929
} catch (TypeError $e) {
30-
echo $e->getMessage(), "\n";
30+
echo $e::class, ': ', $e->getMessage(), "\n";
3131
}
3232

3333
?>
3434
--EXPECT--
35-
Cannot access offset of type array on ArrayObject
36-
Cannot access offset of type array on ArrayObject
37-
Cannot access offset of type array on ArrayObject
38-
Cannot access offset of type array in isset or empty
39-
Cannot unset offset of type array on ArrayObject
35+
TypeError: Cannot access offset of type array on ArrayObject
36+
TypeError: Cannot access offset of type array on ArrayObject
37+
TypeError: Cannot access offset of type array on ArrayObject
38+
TypeError: Cannot access offset of type array in isset or empty
39+
TypeError: Cannot unset offset of type array on ArrayObject

‎ext/spl/tests/ArrayObject/ArrayObject_overloaded_SplFixedArray.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ try {
99
// See GH-15918: this *should* fail to not break invariants
1010
$ao->exchangeArray($fixedArray);
1111
} catch (InvalidArgumentException $e) {
12-
echo $e->getMessage(), "\n";
12+
echo $e::class, ': ', $e->getMessage(), "\n";
1313
}
1414
?>
1515
--EXPECTF--
1616
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
17-
Overloaded object of type SplFixedArray is not compatible with ArrayObject
17+
InvalidArgumentException: Overloaded object of type SplFixedArray is not compatible with ArrayObject

‎ext/spl/tests/ArrayObject/ArrayObject_overloaded_object_incompatible.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ $ao = new ArrayObject([1, 2, 3]);
77
try {
88
$ao->exchangeArray(new DateInterval('P1D'));
99
} catch (Exception $e) {
10-
echo $e->getMessage(), "\n";
10+
echo $e::class, ': ', $e->getMessage(), "\n";
1111
}
1212
var_dump($ao);
1313

1414
?>
1515
--EXPECTF--
1616
Deprecated: ArrayObject::exchangeArray(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
17-
Overloaded object of type DateInterval is not compatible with ArrayObject
17+
InvalidArgumentException: Overloaded object of type DateInterval is not compatible with ArrayObject
1818
object(ArrayObject)#1 (1) {
1919
["storage":"ArrayObject":private]=>
2020
array(3) {

‎ext/spl/tests/ArrayObject/arrayObject___construct_error1.phpt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ $a->p = 1;
88
try {
99
var_dump(new ArrayObject($a, 0, "Exception"));
1010
} catch (TypeError $e) {
11-
echo $e->getMessage() . "(" . $e->getLine() . ")\n";
11+
echo $e::class, ': ', $e->getMessage(), "\n";
1212
}
1313

1414
echo "Non-existent class:\n";
1515
try {
1616
var_dump(new ArrayObject(new stdClass, 0, "nonExistentClassName"));
1717
} catch (TypeError $e) {
18-
echo $e->getMessage() . "(" . $e->getLine() . ")\n";
18+
echo $e::class, ': ', $e->getMessage(), "\n";
1919
}
2020
?>
2121
--EXPECT--
2222
Bad iterator type:
23-
ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, Exception given(6)
23+
TypeError: ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, Exception given
2424
Non-existent class:
25-
ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, nonExistentClassName given(13)
25+
TypeError: ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, nonExistentClassName given

‎ext/spl/tests/ArrayObject/arrayObject___construct_error2.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ Class C implements Iterator {
1414
try {
1515
var_dump(new ArrayObject(new stdClass, 0, "C", "extra"));
1616
} catch (TypeError $e) {
17-
echo $e->getMessage() . "(" . $e->getLine() . ")\n";
17+
echo $e::class, ': ', $e->getMessage(), "\n";
1818
}
1919
?>
2020
--EXPECT--
2121
Too many arguments:
22-
ArrayObject::__construct() expects at most 3 arguments, 4 given(12)
22+
ArgumentCountError: ArrayObject::__construct() expects at most 3 arguments, 4 given

‎ext/spl/tests/ArrayObject/arrayObject_asort_basic1.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var_dump($ao1);
1616
try {
1717
var_dump($ao2->asort('blah'));
1818
} catch (TypeError $e) {
19-
echo $e->getMessage(), "\n";
19+
echo $e::class, ': ', $e->getMessage(), "\n";
2020
}
2121
var_dump($ao2);
2222
var_dump($ao2->asort(SORT_NUMERIC));
@@ -36,7 +36,7 @@ object(ArrayObject)#%d (1) {
3636
int(4)
3737
}
3838
}
39-
ArrayObject::asort(): Argument #1 ($flags) must be of type int, string given
39+
TypeError: ArrayObject::asort(): Argument #1 ($flags) must be of type int, string given
4040
object(ArrayObject)#%d (1) {
4141
["storage":"ArrayObject":private]=>
4242
array(3) {

‎ext/spl/tests/ArrayObject/arrayObject_exchangeArray_basic2.phpt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ object(ArrayObject)#%d (1) {
104104
}
105105
}
106106
}
107-
}
107+
}

‎ext/spl/tests/ArrayObject/arrayObject_exchangeArray_basic3.phpt‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ try {
1616
$copy = $ao->exchangeArray($swapIn);
1717
$copy['addedToCopy'] = 'added To Copy';
1818
} catch (Exception $e) {
19-
echo "Exception:" . $e->getMessage() . "\n";
19+
echo $e::class, ': ', $e->getMessage(), "\n";
2020
}
2121
$swapIn->addedToSwapIn = 'added To Swap-In';
2222
$original->addedToOriginal = 'added To Original';
@@ -31,7 +31,7 @@ try {
3131
$copy = $ao->exchangeArray();
3232
$copy['addedToCopy'] = 'added To Copy';
3333
} catch (TypeError $e) {
34-
echo "Exception: " . $e->getMessage() . "\n";
34+
echo $e::class, ': ', $e->getMessage(), "\n";
3535
}
3636
$original->addedToOriginal = 'added To Original';
3737
var_dump($ao, $original, $copy);
@@ -44,7 +44,7 @@ try {
4444
$copy = $ao->exchangeArray(null);
4545
$copy['addedToCopy'] = 'added To Copy';
4646
} catch (TypeError $e) {
47-
echo $e->getMessage() . "\n";
47+
echo $e::class, ': ', $e->getMessage(), "\n";
4848
}
4949
$original->addedToOriginal = 'added To Original';
5050
var_dump($ao, $original, $copy);
@@ -92,7 +92,7 @@ array(2) {
9292
--> exchangeArray() with no arg:
9393

9494
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
95-
Exception: ArrayObject::exchangeArray() expects exactly 1 argument, 0 given
95+
ArgumentCountError: ArrayObject::exchangeArray() expects exactly 1 argument, 0 given
9696

9797
Deprecated: Creation of dynamic property C::$addedToOriginal is deprecated in %s on line %d
9898

@@ -118,7 +118,7 @@ NULL
118118
--> exchangeArray() with bad arg type:
119119

120120
Deprecated: ArrayObject::__construct(): Using an object as a backing array for ArrayObject is deprecated, as it allows violating class constraints and invariants in %s on line %d
121-
ArrayObject::exchangeArray(): Argument #1 ($array) must be of type array, null given
121+
TypeError: ArrayObject::exchangeArray(): Argument #1 ($array) must be of type array, null given
122122

123123
Deprecated: Creation of dynamic property C::$addedToOriginal is deprecated in %s on line %d
124124

‎ext/spl/tests/ArrayObject/arrayObject_ksort_basic1.phpt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var_dump($ao1);
1515
try {
1616
var_dump($ao2->ksort('blah'));
1717
} catch (TypeError $e) {
18-
echo $e->getMessage(), "\n";
18+
echo $e::class, ': ', $e->getMessage(), "\n";
1919
}
2020
var_dump($ao2);
2121
var_dump($ao2->ksort(SORT_STRING));
@@ -35,7 +35,7 @@ object(ArrayObject)#%d (1) {
3535
int(3)
3636
}
3737
}
38-
ArrayObject::ksort(): Argument #1 ($flags) must be of type int, string given
38+
TypeError: ArrayObject::ksort(): Argument #1 ($flags) must be of type int, string given
3939
object(ArrayObject)#2 (1) {
4040
["storage":"ArrayObject":private]=>
4141
array(4) {

0 commit comments

Comments
 (0)