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/28 19:36] – guilhermeblanco | rfc:abstract_final_class [2014/12/23 00:05] – guilhermeblanco | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2014-11-26 | * Date: 2014-11-26 | ||
* Author: Guilherme Blanco, guilhermeblanco@php.net | * Author: Guilherme Blanco, guilhermeblanco@php.net | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
+ | |||
+ | Please understand only one of the following proposals can be accepted, not both. | ||
+ | They' | ||
+ | |||
+ | ==== As Static classes ==== | ||
+ | |||
Static classes are helpful in the case you are wrapping common functions that are static, but the common class itself cannot be instantiated. | Static classes are helpful in the case you are wrapping common functions that are static, but the common class itself cannot be instantiated. | ||
Line 20: | Line 26: | ||
* Could also be used with combination of " | * 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”, | ||
+ | There' | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | Change language scanner to accept static class construction, | + | Change language scanner to accept static class or abstract final construction, |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 31: | Line 49: | ||
===== Example ===== | ===== Example ===== | ||
- | final static class Environment | + | ==== As static class ==== |
+ | |||
+ | | ||
{ | { | ||
private static $rootDirectory = '/ | private static $rootDirectory = '/ | ||
- | public function getRootDirectory() | + | public |
{ | { | ||
return self:: | return self:: | ||
Line 42: | Line 62: | ||
echo Environment:: | echo Environment:: | ||
- | ===== Proposed Voting Choices | + | ==== As abstract final ==== |
+ | |||
+ | abstract final class StringUtil | ||
+ | { | ||
+ | public static function isNotNullOrSpace($str) | ||
+ | { | ||
+ | return !($str | ||
+ | } | ||
+ | } | ||
+ | |||
+ | echo StringUtil:: | ||
+ | ? 'Empty string' | ||
+ | : ' | ||
- | Since this is a language update, it requires | + | ===== Vote ===== |
+ | <doodle title=" | ||
+ | * Yes, as " | ||
+ | * Yes, as " | ||
+ | * No | ||
+ | </ | ||
+ | \\ | ||
+ | The vote starts on 12/12/2014 and ends on 12/ | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | To be updated. Originally suggested as abstract class at 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