rfc:inheritance_private_methods
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:inheritance_private_methods [2020/04/16 17:58] – pmmaga | rfc:inheritance_private_methods [2020/07/17 14:59] (current) – pmmaga | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Ignore | + | ====== PHP RFC: Remove inappropriate |
* Version: 0.3 | * Version: 0.3 | ||
* Date: 2020-04-16 | * Date: 2020-04-16 | ||
* Author: Pedro Magalhães, pmmaga@php.net | * Author: Pedro Magalhães, pmmaga@php.net | ||
- | * Status: | + | * Status: |
+ | * Target: 8.0 | ||
* First Published at: http:// | * First Published at: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Currently, a method with the same name as a parent' | + | Currently, a method with the same name as a parent' |
This leads to inheritance checks being executed even if the parent' | This leads to inheritance checks being executed even if the parent' | ||
+ | |||
+ | Some rules are already skipped like the number of arguments or their type, but other rules are still enforced. Namely: | ||
+ | * When a method has the same name as a parent' | ||
+ | * When a method has the same name as a parent' | ||
+ | * When a method has the same name as a parent' | ||
The [[http:// | The [[http:// | ||
Line 18: | Line 24: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | This RFC aims at ignoring | + | This RFC proposes removing |
In the current state: | In the current state: | ||
- | <code php> | + | <code php> |
<?php | <?php | ||
Line 42: | Line 48: | ||
Produces: | Produces: | ||
- | < | + | < |
Fatal error: Cannot override final method A:: | Fatal error: Cannot override final method A:: | ||
</ | </ | ||
- | Besides the error ocurring, the message mentions overriding which isn't applicable for private methods. | + | Besides the error occurring, the message mentions overriding which isn't applicable for private methods. |
With the implementation of this RFC, the previous and the following code would compile correctly: | With the implementation of this RFC, the previous and the following code would compile correctly: | ||
Line 89: | Line 95: | ||
< | < | ||
+ | Warning: Private methods cannot be final as they are never overridden by other classes in ... | ||
A:: | A:: | ||
A:: | A:: | ||
Line 95: | Line 102: | ||
</ | </ | ||
- | The final keyword when applied to a private method should have no significance. | + | The final keyword when applied to a private method should have no significance. In most cases, a correct approach is to use '' |
- | Open issue: Applying final to a private | + | **NOTE:** Due to how common the usage of ''< |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | There are no BC breaking changes. | + | The new compiler warning: |
- | NOTE: The construction '' | + | < |
- | A correct approach to attain a similar effect would be '' | + | Warning: Private methods cannot be final as they are never overridden by other classes |
+ | </ | ||
- | If the optional compiler | + | Will start appearing in some code bases where both modifiers '' |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
PHP 8.0 | PHP 8.0 | ||
- | |||
- | ===== Open Issues ===== | ||
- | |||
- | * Producing a compiler warning when '' | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
Line 120: | Line 124: | ||
The inheritance rules for visible methods remains unaffected, including when these are static or declared on a trait. | The inheritance rules for visible methods remains unaffected, including when these are static or declared on a trait. | ||
- | ===== Proposed Voting Choices | + | ===== Vote ===== |
+ | |||
+ | Voting started 2020-06-15 and ends 2020-06-29. | ||
- | 2/3 majority | + | <doodle title=" |
+ | * Yes | ||
+ | * No | ||
+ | </doodle> | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== |
rfc/inheritance_private_methods.1587059902.txt.gz · Last modified: 2020/04/16 17:58 by pmmaga