[wp-trac] [WordPress Trac] #59232: Introduce #[Override] attribute to mark overloaded methods
WordPress Trac
noreply at wordpress.org
Mon Aug 28 23:44:04 UTC 2023
#59232: Introduce #[Override] attribute to mark overloaded methods
-------------------------+-----------------------------
Reporter: jrf | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords: php83
Focuses: |
-------------------------+-----------------------------
From https://core.trac.wordpress.org/ticket/59231:
> === [https://wiki.php.net/rfc/marking_overriden_methods Marking
overridden methods]
>
> This is a new feature which will be introduced in PHP 8.3, with limited
validation functionality attached. The attribute basically allows to mark
methods in a (child) class/interface which overload a method in a parent
class or from an interface, as doing so intentionally.
>
> Per the RFC:
> > ... being able to express if a method is intended to override another
method or implement an interface would make it easier to debug a mistake,
to refactor and to clean up existing code. Another possible use case is to
easily detect a possibly breaking change in a parent class that was
provided by a library without needing to read the changelog in detail or
missing some item in the list of changes
>
> I'd like to advocate for adding these attributes to WP Core in all the
relevant places as it:
> * Increases awareness of the method overload for contributors.
> * Can serve as a warning that the method signature should not be touched
(unless the parent method signature changes).
> * Has no downside as attributes are ignored in older PHP versions and in
PHP versions where the attribute referenced does not exist.
>
> In the rare case that the attribute, once added, would result in a fatal
error, that would be fantastic, as that means we have actually found a bug
in WP before it got into a stable release.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59232>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list