rfc:abstract_final_class
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:abstract_final_class [2014/11/27 04:00] – fixed title guilhermeblanco | rfc:abstract_final_class [2014/12/12 15:41] – guilhermeblanco | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Abstract final classes ====== | + | ====== PHP RFC: Static |
- | * Version: 1.0 | + | * Version: 1.1 |
* Date: 2014-11-26 | * Date: 2014-11-26 | ||
* Author: Guilherme Blanco, guilhermeblanco@php.net | * Author: Guilherme Blanco, guilhermeblanco@php.net | ||
Line 8: | Line 8: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Abstract final classes are helpful in the case you are wrapping common functions that are static, but the common class itself cannot be instantiated. | + | Static |
Currently, PHP developers' | Currently, PHP developers' | ||
+ | |||
+ | When untestable/ | ||
+ | |||
+ | By the acceptance of this patch, every method declaration would automatically be enforced to behave as static without any further keyword needed. This reduces the human error of methods being forgotten to be declared as static. | ||
For such, here is motivation: | For such, here is motivation: | ||
- | * As "abstract", it cannot be instantiated | + | * As "static", it purely behaves at class level, not at instance level |
- | * As " | + | * Could also be used with combination of " |
- | * There' | + | * There' |
===== Proposal ===== | ===== Proposal ===== | ||
- | Change language scanner to accept | + | Change language scanner to accept |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 27: | Line 31: | ||
===== Example ===== | ===== Example ===== | ||
- | | + | final static |
{ | { | ||
- | public static function | + | |
+ | | ||
{ | { | ||
- | return | + | return |
} | } | ||
} | } | ||
- | echo StringUtil::isNotNullOrSpace('' | + | echo Environment::getRootDirectory(); |
- | ? 'Empty string' | + | |
- | : ' | + | |
- | + | ||
- | ===== Proposed Voting Choices ===== | + | |
- | Good question... 2/3? or 50% + 1? | + | ===== Vote ===== |
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | \\ | ||
+ | The vote starts on 12/12/2014 and ends on 12/19/2014. 2/3 majority required. | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | https:// | + | Most recent suggested implementation available at https:// |
+ | Originally suggested as abstract class at https:// |
rfc/abstract_final_class.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1