Skip to content
Open
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 @@ -8,16 +8,16 @@ function foo($foo, int ...$bar) {}
try {
foo(1, []);
} catch (TypeError $exception) {
echo $exception->getMessage() . "\n";
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

try {
foo(1, 1, 1, []);
} catch (TypeError $exception) {
echo $exception->getMessage() . "\n";
echo $exception::class, ': ', $exception->getMessage(), "\n";
}

?>
--EXPECTF--
foo(): Argument #2 must be of type int, array given, called in %s on line %d
foo(): Argument #4 must be of type int, array given, called in %s on line %d
TypeError: foo(): Argument #2 must be of type int, array given, called in %s on line %d
TypeError: foo(): Argument #4 must be of type int, array given, called in %s on line %d
4 changes: 2 additions & 2 deletions Zend/tests/gc/bug54305.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ $methodWithArgs = new ReflectionMethod('TestClass', 'methodWithArgs');
try {
echo $methodWithArgs++;
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
Cannot increment ReflectionMethod
TypeError: Cannot increment ReflectionMethod
4 changes: 2 additions & 2 deletions Zend/tests/gc/bug80072.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ try {
$s = 'O:8:"stdClass":1:{s:1:"x";r:1;}';
unserialize($s) % gc_collect_cycles();
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

$a[]=&$a == $a=&$b > gc_collect_cycles();

?>
--EXPECT--
Unsupported operand types: stdClass % int
TypeError: Unsupported operand types: stdClass % int
4 changes: 2 additions & 2 deletions Zend/tests/generators/bug79927.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $generator->next();
try {
$generator->rewind();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
echo $generator->current(), "\n";

Expand All @@ -26,6 +26,6 @@ echo $generator2->current(), "\n";

?>
--EXPECT--
Cannot rewind a generator that was already run
Exception: Cannot rewind a generator that was already run
3
4
4 changes: 2 additions & 2 deletions Zend/tests/generators/dynamic_properties.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ $gen = gen();
try {
$gen->prop = new stdClass;
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
Cannot create dynamic property Generator::$prop
Error: Cannot create dynamic property Generator::$prop
4 changes: 2 additions & 2 deletions Zend/tests/generators/errors/count_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ $gen = gen();
try {
count($gen);
} catch (\TypeError $e) {
echo $e->getMessage(), PHP_EOL;
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
count(): Argument #1 ($value) must be of type Countable|array, Generator given
TypeError: count(): Argument #1 ($value) must be of type Countable|array, Generator given
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function gen() {
try {
$gen->next();
} catch (Error $e) {
echo "\nException: " . $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
$gen->next();
}
Expand All @@ -19,7 +19,7 @@ $gen->next();

?>
--EXPECTF--
Exception: Cannot resume an already running generator
Error: Cannot resume an already running generator

Fatal error: Uncaught Error: Cannot resume an already running generator in %s:%d
Stack trace:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ $gen = gen();
try {
$gen->send($gen);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
Cannot resume an already running generator
Error: Cannot resume an already running generator
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ var_dump($gen->current());
try {
$gen->next();
} catch (Exception $e) {
echo 'Caught exception with message "', $e->getMessage(), '"', "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

var_dump($gen->current());

?>
--EXPECT--
string(3) "foo"
Caught exception with message "test"
Exception: test
NULL
4 changes: 2 additions & 2 deletions Zend/tests/generators/generator_throwing_exception.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ var_dump($gen->current());
try {
$gen->next();
} catch (Exception $e) {
echo 'Caught exception with message "', $e->getMessage(), '"', "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

var_dump($gen->current());

?>
--EXPECT--
string(3) "foo"
Caught exception with message "test"
Exception: test
NULL
8 changes: 4 additions & 4 deletions Zend/tests/generators/generator_with_type_check_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ function gen(array $a) { yield; }
try {
gen(42);
} catch (TypeError $e) {
echo $e->getMessage()."\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
foreach (gen(42) as $val) {
var_dump($val);
}
} catch (TypeError $e) {
echo $e->getMessage()."\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECTF--
gen(): Argument #1 ($a) must be of type array, int given, called in %s on line %d
gen(): Argument #1 ($a) must be of type array, int given, called in %s on line %d
TypeError: gen(): Argument #1 ($a) must be of type array, int given, called in %s on line %d
TypeError: gen(): Argument #1 ($a) must be of type array, int given, called in %s on line %d
8 changes: 4 additions & 4 deletions Zend/tests/generators/get_return_and_finally.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ try {
// during auto-priming, so fails
var_dump($gen->getReturn());
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
// This fails, because the return value was discarded
var_dump($gen->getReturn());
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
int(42)
gen2() throw
Cannot get return value of a generator that hasn't returned
Exception: gen2() throw
Exception: Cannot get return value of a generator that hasn't returned
24 changes: 12 additions & 12 deletions Zend/tests/generators/get_return_errors.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ try {
// Generator hasn't reached the "return" yet
$gen->getReturn();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

function gen2() {
Expand All @@ -27,13 +27,13 @@ $gen = gen2();
try {
$gen->next();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
// Generator has been aborted as a result of an exception
$gen->getReturn();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

function gen3() {
Expand All @@ -47,7 +47,7 @@ try {
// Generator throws during auto-priming of getReturn() call
$gen->getReturn();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

function gen4() {
Expand All @@ -59,21 +59,21 @@ $gen = gen4();
try {
$gen->throw(new Exception("gen4() throw"));
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
// Generator has been aborted as a result of an exception
// that was injected using throw()
$gen->getReturn();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
Cannot get return value of a generator that hasn't returned
gen2() throw
Cannot get return value of a generator that hasn't returned
gen3() throw
gen4() throw
Cannot get return value of a generator that hasn't returned
Exception: Cannot get return value of a generator that hasn't returned
Exception: gen2() throw
Exception: Cannot get return value of a generator that hasn't returned
Exception: gen3() throw
Exception: gen4() throw
Exception: Cannot get return value of a generator that hasn't returned
10 changes: 5 additions & 5 deletions Zend/tests/generators/gh11028_1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function test($msg, $x) {
try {
var_dump([...generator($x)]);
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
}

Expand All @@ -26,10 +26,10 @@ test("object", new stdClass);
?>
--EXPECT--
yield null
Keys must be of type int|string during array unpacking
Error: Keys must be of type int|string during array unpacking
yield false
Keys must be of type int|string during array unpacking
Error: Keys must be of type int|string during array unpacking
yield true
Keys must be of type int|string during array unpacking
Error: Keys must be of type int|string during array unpacking
yield object
Keys must be of type int|string during array unpacking
Error: Keys must be of type int|string during array unpacking
4 changes: 2 additions & 2 deletions Zend/tests/generators/gh11028_3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function generator() {
try {
var_dump([...generator()]);
} catch (Throwable $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
exception
Exception: exception
6 changes: 3 additions & 3 deletions Zend/tests/generators/throw_into_yield_from_array.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function test($g) {
try {
$g->throw(new Exception("Exception!"));
} catch (Exception $e) {
echo "{$e->getMessage()}\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
var_dump($g->current());
}
Expand All @@ -35,9 +35,9 @@ test(yf(yielditer($data)));
?>
--EXPECT--
int(1)
Exception!
Exception: Exception!
NULL

int(1)
Exception!
Exception: Exception!
NULL
4 changes: 2 additions & 2 deletions Zend/tests/generators/yield_from_non_iterable.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ function gen() {
try {
gen()->current();
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
Can use "yield from" only with arrays and Traversables
Error: Can use "yield from" only with arrays and Traversables
4 changes: 2 additions & 2 deletions Zend/tests/generators/yield_from_valid_exception.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function gen() {
// the fact that the yield from result is used is relevant.
var_dump(yield from new FooBar);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
}

Expand All @@ -27,4 +27,4 @@ $x->current();

?>
--EXPECT--
Exception from valid()
Exception: Exception from valid()
4 changes: 2 additions & 2 deletions Zend/tests/get_called_class_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Calling get_called_class() outside a class
try {
var_dump(get_called_class());
} catch (Error $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
get_called_class() must be called from within a class
Error: get_called_class() must be called from within a class
Loading
Loading