[php-src] Issue #14493: Trait methods with `Override` attribute with existing parent methods throw error after #14480 was fixed
| From: | spaze | Date: | Fri, 07 Jun 2024 01:40:13 +0000 |
| Subject: | [php-src] Issue #14493: Trait methods with `Override` attribute with existing parent methods throw error after #14480 was fixed | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247052@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14493
Author: spaze
### Description
I have a trait method that looks like this
```php
trait Traita
{
#[Override]
public function methodWithDefaultImplementation(): int {}
}
```
which is used in a class
```php
final class Childa extends Parenta
{
use Traita;
}
```
(all in the repo here https://github.com/spaze/php-override-test)
and this has started throwing errors () on the patched PHP 8.3.8 after the fix https://github.com/dstogov/php-src/commit/955d717e242c3433cdf76fa353831aefae530cab
for #14480 has been applied:
```
PHP Fatal error: Childa::methodWithDefaultImplementation() has #[\Override] attribute, but no
matching parent method exists
```
see https://github.com/spaze/php-override-test/actions/runs/9409995626/job/25920912091
I'm running tests with shivammathur/setup-php and they have patched 8.3.8 with the mentioned
patch see https://github.com/shivammathur/setup-php/issues/849#issuecomment-2153420979
When run with unpatched deb.sury.org package, there's no error (but the code from #14480 throws
errors as expected without the patch).
### PHP Version
8.3.8 + #14480.patch
### Operating System
_No response_