[php-src] Issue #10379: Exception::$message can't be extends with string type
| From: | julien-boudry | Date: | Thu, 19 Jan 2023 16:46:43 +0000 |
| Subject: | [php-src] Issue #10379: Exception::$message can't be extends with string type | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243503@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10379
Author: julien-boudry
### Description
### Documentation book
The PHP book describes Exception class as follows:
https://www.php.net/manual/en/class.exception.php
```php
class Exception implements [Throwable](https://www.php.net/manual/en/class.throwable.php) {
/* Properties */
protected string $message= "";
[...]
}
```
### The extending it:
https://3v4l.org/QtEA0#v8.2.1
```php
<?php
class AException extends \Exception
{
protected $message = 'New Default Message';
}
class BException extends \Exception
{
protected string $message = 'New Default Message';
}
```
Resulted in this output:
```
Fatal error: Type of BException::$message must not be defined (as in class Exception)
```
But I expected this output instead:
_No error. Or an error for class A, not class B._
### PHP Version
PHP 8.2.1
### Operating System
*