mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

- Property hooks may now throw exceptions, that seem to be forgotten to be handled by https://github.com/php/php-src/pull/18442 - The $previous and $trace properties are private, and they were not accessible from the constructor of a child class
37 lines
672 B
PHP
37 lines
672 B
PHP
--TEST--
|
|
Exception properties are overridden by property hooks
|
|
--FILE--
|
|
<?php
|
|
class MyException extends Exception
|
|
{
|
|
private bool $modified = false;
|
|
|
|
protected $code {
|
|
set($value) {
|
|
if ($this->modified) {
|
|
throw new Exception();
|
|
} else {
|
|
$this->modified = true;
|
|
|
|
$this->code = $value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$e = new MyException("foo", 1, new Exception());
|
|
|
|
try {
|
|
$e->__construct("bar", 2, null);
|
|
} catch (Exception) {
|
|
}
|
|
|
|
var_dump($e->getMessage());
|
|
var_dump($e->getCode());
|
|
var_dump($e->getPrevious()::class);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
string(3) "bar"
|
|
int(1)
|
|
string(9) "Exception"
|