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/12/12 15:46] – 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 = '/ | ||
Line 41: | Line 61: | ||
echo Environment:: | echo Environment:: | ||
+ | |||
+ | ==== As abstract final ==== | ||
+ | |||
+ | abstract final class StringUtil | ||
+ | { | ||
+ | public static function isNotNullOrSpace($str) | ||
+ | { | ||
+ | return !($str === null || strlen($str) < 1 || strlen(trim($str)) < 1); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | echo StringUtil:: | ||
+ | ? 'Empty string' | ||
+ | : ' | ||
+ | |||
===== Vote ===== | ===== Vote ===== | ||
- | <doodle title=" | + | <doodle title=" |
* Yes, as " | * Yes, as " | ||
* Yes, as " | * Yes, as " | ||
Line 53: | Line 88: | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | Most recent suggested implementation available 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