[php-src] Issue #13950: Improve the error message of duplicated class declaration
| From: | takaram | Date: | Fri, 12 Apr 2024 16:13:20 +0000 |
| Subject: | [php-src] Issue #13950: Improve the error message of duplicated class declaration | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246752@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/13950
Author: takaram
### Description
- Foo.php
```php
<?php
class Foo {}
```
- Foo2.php
```php
<?php
class Foo {}
```
- test.php
```php
<?php
include 'Foo.php';
include 'Foo2.php';
```
With these files, test.php gives this result:
```
PHP Fatal error: Cannot declare class Foo, because the name is already in use in /path/to/Foo2.php
on line 2
```
This error message includes nothing about
Foo.php, which sometimes makes debugging
hard.
It would be nice if the error message includes the file path and line number of previously declared
class. Probably like this:
```
PHP Fatal error: Cannot declare class Foo, because the name is already in use (declared in
/path/to/Foo.php on line 2) in /path/to/Foo2.php on line 2
```