[php-src] Issue #20878: `#[Override]` on properties leads to unexpected backwards incompatible changes

[email protected] (kkmuffme)
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/20878
Author: kkmuffme

### Description

The following code:

```php
<?php

class A {
    public string $foo;
}

class B extends A {
    #[Override]
    public string $foo;
}
```

https://3v4l.org/om5mJ#v8.5.1
=> no error
https://3v4l.org/om5mJ#v8.3.29
>Fatal error: Attribute "Override" cannot target property (allowed targets: method)
https://3v4l.org/om5mJ#v8.2.30
=> no error

This creates the weird case where code works fine in older PHP and in the latest PHP but you get a fatal for some versions in between, which means the attribute cannot be used for properties at all for quite some time when you need to support all maintained PHP versions (it's only safe to use from 2029 when PHP 8.3 support ends)

Possibly for properties we change it to `#[OverrideProperty]` (or whatever) to prevent this issue? (and deprecate Override on properties again with 8.6, the OverrideProperty attribute could ship with the next 8.5 version though)

The RFC https://wiki.php.net/rfc/override_properties says no backward incompatible changes, however this is quite incompatible, isn't it?

### PHP Version

```plain
8.5
8.3/8.4
<8.3
```

### Operating System

_No response_
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.