Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $ao->uasort(function($a, $b) use ($ao, &$i) {
try {
$ao->exchangeArray([4, 5, 6]);
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump($ao);
}
Expand All @@ -19,7 +19,7 @@ $ao->uasort(function($a, $b) use ($ao, &$i) {

?>
--EXPECT--
Modification of ArrayObject during sorting is prohibited
Error: Modification of ArrayObject during sorting is prohibited
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(3) {
Expand Down
20 changes: 10 additions & 10 deletions ext/spl/tests/ArrayObject/ArrayObject_illegal_offset.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ $ao = new ArrayObject([1, 2, 3]);
try {
var_dump($ao[[]]);
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
$ao[[]] = new stdClass;
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
$ref =& $ao[[]];
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
var_dump(isset($ao[[]]));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
unset($ao[[]]);
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
Cannot access offset of type array on ArrayObject
Cannot access offset of type array on ArrayObject
Cannot access offset of type array on ArrayObject
Cannot access offset of type array in isset or empty
Cannot unset offset of type array on ArrayObject
TypeError: Cannot access offset of type array on ArrayObject
TypeError: Cannot access offset of type array on ArrayObject
TypeError: Cannot access offset of type array on ArrayObject
TypeError: Cannot access offset of type array in isset or empty
TypeError: Cannot unset offset of type array on ArrayObject
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ try {
// See GH-15918: this *should* fail to not break invariants
$ao->exchangeArray($fixedArray);
} catch (InvalidArgumentException $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECTF--
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
Overloaded object of type SplFixedArray is not compatible with ArrayObject
InvalidArgumentException: Overloaded object of type SplFixedArray is not compatible with ArrayObject
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ $ao = new ArrayObject([1, 2, 3]);
try {
$ao->exchangeArray(new DateInterval('P1D'));
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump($ao);

?>
--EXPECTF--
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
Overloaded object of type DateInterval is not compatible with ArrayObject
InvalidArgumentException: Overloaded object of type DateInterval is not compatible with ArrayObject
object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ $a->p = 1;
try {
var_dump(new ArrayObject($a, 0, "Exception"));
} catch (TypeError $e) {
echo $e->getMessage() . "(" . $e->getLine() . ")\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo "Non-existent class:\n";
try {
var_dump(new ArrayObject(new stdClass, 0, "nonExistentClassName"));
} catch (TypeError $e) {
echo $e->getMessage() . "(" . $e->getLine() . ")\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
Comment thread
NickSdot marked this conversation as resolved.
?>
--EXPECT--
Bad iterator type:
ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, Exception given(6)
TypeError: ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, Exception given
Non-existent class:
ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, nonExistentClassName given(13)
TypeError: ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, nonExistentClassName given
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Class C implements Iterator {
try {
var_dump(new ArrayObject(new stdClass, 0, "C", "extra"));
} catch (TypeError $e) {
echo $e->getMessage() . "(" . $e->getLine() . ")\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
Too many arguments:
ArrayObject::__construct() expects at most 3 arguments, 4 given(12)
ArgumentCountError: ArrayObject::__construct() expects at most 3 arguments, 4 given
4 changes: 2 additions & 2 deletions ext/spl/tests/ArrayObject/arrayObject_asort_basic1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var_dump($ao1);
try {
var_dump($ao2->asort('blah'));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump($ao2);
var_dump($ao2->asort(SORT_NUMERIC));
Expand All @@ -36,7 +36,7 @@ object(ArrayObject)#%d (1) {
int(4)
}
}
ArrayObject::asort(): Argument #1 ($flags) must be of type int, string given
TypeError: ArrayObject::asort(): Argument #1 ($flags) must be of type int, string given
object(ArrayObject)#%d (1) {
["storage":"ArrayObject":private]=>
array(3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ object(ArrayObject)#%d (1) {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ try {
$copy = $ao->exchangeArray($swapIn);
$copy['addedToCopy'] = 'added To Copy';
} catch (Exception $e) {
echo "Exception:" . $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
$swapIn->addedToSwapIn = 'added To Swap-In';
$original->addedToOriginal = 'added To Original';
Expand All @@ -31,7 +31,7 @@ try {
$copy = $ao->exchangeArray();
$copy['addedToCopy'] = 'added To Copy';
} catch (TypeError $e) {
echo "Exception: " . $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
$original->addedToOriginal = 'added To Original';
var_dump($ao, $original, $copy);
Expand All @@ -44,7 +44,7 @@ try {
$copy = $ao->exchangeArray(null);
$copy['addedToCopy'] = 'added To Copy';
} catch (TypeError $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
$original->addedToOriginal = 'added To Original';
var_dump($ao, $original, $copy);
Expand Down Expand Up @@ -92,7 +92,7 @@ array(2) {
--> exchangeArray() with no arg:

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
Exception: ArrayObject::exchangeArray() expects exactly 1 argument, 0 given
ArgumentCountError: ArrayObject::exchangeArray() expects exactly 1 argument, 0 given

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

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

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
ArrayObject::exchangeArray(): Argument #1 ($array) must be of type array, null given
TypeError: ArrayObject::exchangeArray(): Argument #1 ($array) must be of type array, null given

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

Expand Down
4 changes: 2 additions & 2 deletions ext/spl/tests/ArrayObject/arrayObject_ksort_basic1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var_dump($ao1);
try {
var_dump($ao2->ksort('blah'));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump($ao2);
var_dump($ao2->ksort(SORT_STRING));
Expand All @@ -35,7 +35,7 @@ object(ArrayObject)#%d (1) {
int(3)
}
}
ArrayObject::ksort(): Argument #1 ($flags) must be of type int, string given
TypeError: ArrayObject::ksort(): Argument #1 ($flags) must be of type int, string given
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>
array(4) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var_dump($ao1);
try {
var_dump($ao2->natcasesort('blah'));
} catch (ArgumentCountError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump($ao2);
?>
Expand All @@ -38,7 +38,7 @@ object(ArrayObject)#1 (1) {
string(5) "boo22"
}
}
ArrayObject::natcasesort() expects exactly 0 arguments, 1 given
ArgumentCountError: ArrayObject::natcasesort() expects exactly 0 arguments, 1 given
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>
array(5) {
Expand Down
4 changes: 2 additions & 2 deletions ext/spl/tests/ArrayObject/arrayObject_natsort_basic1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var_dump($ao1);
try {
var_dump($ao2->natsort('blah'));
} catch (ArgumentCountError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump($ao2);
?>
Expand All @@ -38,7 +38,7 @@ object(ArrayObject)#1 (1) {
string(5) "boo22"
}
}
ArrayObject::natsort() expects exactly 0 arguments, 1 given
ArgumentCountError: ArrayObject::natsort() expects exactly 0 arguments, 1 given
object(ArrayObject)#2 (1) {
["storage":"ArrayObject":private]=>
array(5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ try {
echo " $key=>$value\n";
}
} catch (TypeError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
Expand All @@ -19,7 +19,7 @@ try {
echo " $key=>$value\n";
}
} catch (TypeError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}


Expand All @@ -29,7 +29,7 @@ try {
echo " $key=>$value\n";
}
} catch (TypeError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
Expand All @@ -38,12 +38,12 @@ try {
echo " $key=>$value\n";
}
} catch (TypeError $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
string(133) "ArrayObject::setIteratorClass(): Argument #1 ($iteratorClass) must be a class name derived from ArrayIterator, nonExistentClass given"
string(125) "ArrayObject::setIteratorClass(): Argument #1 ($iteratorClass) must be a class name derived from ArrayIterator, stdClass given"
string(128) "ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, nonExistentClass given"
string(120) "ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, stdClass given"
TypeError: ArrayObject::setIteratorClass(): Argument #1 ($iteratorClass) must be a class name derived from ArrayIterator, nonExistentClass given
TypeError: ArrayObject::setIteratorClass(): Argument #1 ($iteratorClass) must be a class name derived from ArrayIterator, stdClass given
TypeError: ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, nonExistentClass given
TypeError: ArrayObject::__construct(): Argument #3 ($iteratorClass) must be a class name derived from ArrayIterator, stdClass given
8 changes: 4 additions & 4 deletions ext/spl/tests/ArrayObject/array_014.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ try
}
catch(Exception $e)
{
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try
Expand All @@ -26,7 +26,7 @@ try
}
catch(Exception $e)
{
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

$pos = 0;
Expand All @@ -41,8 +41,8 @@ foreach($it as $v)
int(11)
int(5)
int(4)
Seek position -1 is out of range
Seek position 12 is out of range
OutOfBoundsException: Seek position -1 is out of range
OutOfBoundsException: Seek position 12 is out of range
int(0)
int(1)
int(2)
Expand Down
4 changes: 2 additions & 2 deletions ext/spl/tests/ArrayObject/array_018.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ try
}
catch (Exception $e)
{
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}

var_dump($foo);
Expand All @@ -23,7 +23,7 @@ try
}
catch (Exception $e)
{
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}

var_dump($foo);
Expand Down
16 changes: 8 additions & 8 deletions ext/spl/tests/ArrayObject/gh15833_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ $recursiveArrayIterator = new RecursiveArrayIterator($obj);
try {
var_dump($recursiveArrayIterator->current());
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
var_dump($recursiveArrayIterator->current());
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
$recursiveArrayIterator->next();
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
var_dump($recursiveArrayIterator->current());
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECTF--
Deprecated: ArrayIterator::__construct(): Using an object as a backing array for ArrayIterator is deprecated, as it allows violating class constraints and invariants in %s on line %d
nope 0
nope 1
nope 2
nope 3
Error: nope 0
Error: nope 1
Error: nope 2
Error: nope 3
4 changes: 2 additions & 2 deletions ext/spl/tests/ArrayObject/gh15918.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ $foo = new SplFixedArray(5);
try {
$arrayObject = new ArrayObject($foo);
} catch (InvalidArgumentException $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECTF--
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
Overloaded object of type SplFixedArray is not compatible with ArrayObject
InvalidArgumentException: Overloaded object of type SplFixedArray is not compatible with ArrayObject
Loading
Loading