mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
This is in preparation for the possible future transformation of `clone` into a function call, but also meaningful on its own, since the purpose of the tests is not to test the stack trace generation, but rather that an exception was thrown. It also cleans up some unreachable code in the tests.
21 lines
284 B
PHP
21 lines
284 B
PHP
--TEST--
|
|
Generators cannot be cloned
|
|
--FILE--
|
|
<?php
|
|
|
|
function gen() {
|
|
yield;
|
|
}
|
|
|
|
|
|
try {
|
|
$gen = gen();
|
|
clone $gen;
|
|
} catch (Throwable $e) {
|
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Error: Trying to clone an uncloneable object of class Generator
|