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 03:42] – guilhermeblanco | rfc:abstract_final_class [2014/12/23 00:05] – Closing vote guilhermeblanco | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: IntlChar class ====== | + | ====== PHP RFC: Static classes |
- | * 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. | + | Please understand only one of the following proposals can be accepted, not both. |
+ | They' | ||
+ | |||
+ | ==== As Static classes ==== | ||
+ | |||
+ | |||
+ | 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' |
+ | |||
+ | ==== As abstract final ==== | ||
+ | |||
+ | |||
+ | |||
+ | Abstract final classes are helpful in the case you are wrapping common functions that are static, but the common class itself cannot be instantiated. Currently, PHP developers' | ||
+ | |||
+ | For such, here is motivation: | ||
+ | |||
+ | As “abstract”, | ||
+ | As “final”, | ||
+ | | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | Change language scanner to accept abstract final class constructor, and subsequently | + | Change language scanner to accept |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 26: | Line 48: | ||
===== Example ===== | ===== Example ===== | ||
+ | |||
+ | ==== As static class ==== | ||
+ | |||
+ | static class Environment | ||
+ | { | ||
+ | private static $rootDirectory = '/ | ||
+ | public static function getRootDirectory() | ||
+ | { | ||
+ | return self:: | ||
+ | } | ||
+ | } | ||
+ | |||
+ | echo Environment:: | ||
+ | |||
+ | ==== As abstract final ==== | ||
abstract final class StringUtil | abstract final class StringUtil | ||
Line 36: | Line 73: | ||
echo StringUtil:: | echo StringUtil:: | ||
- | | + | |
- | : ' | + | : ' |
- | ===== Proposed Voting Choices ===== | ||
- | Good question... 2/3? or 50% + 1? | + | ===== Vote ===== |
+ | <doodle title=" | ||
+ | * Yes, as " | ||
+ | * Yes, as " | ||
+ | * 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