rfc:class_const_visibility
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:class_const_visibility [2015/03/02 08:45] – created reeze | rfc:class_const_visibility [2015/12/08 16:01] – Merged into 7.1 sean-der | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Support Class Constant Visibility ====== | ====== PHP RFC: Support Class Constant Visibility ====== | ||
- | * Version: 0.1 | + | * Version: 0.2 |
- | * Date: 2015-03-02 | + | * Date: 2015-09-13 |
- | * Author: Reeze Xia, reeze@php.net | + | * Author: |
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
- | This is a suggested template for PHP Request for Comments (RFCs). Change this template to suit your RFC. Not all RFCs need to be tightly specified. | ||
- | Read https:// | ||
+ | ===== Introduction ===== | ||
- | Quoting | + | Classes in PHP allow modifiers on properties and methods, but not constants. |
+ | It is an easily fixed inconsistency, | ||
+ | that it doesn' | ||
- | > PHP is and should remain: | + | In a thread on php-internals |
- | > 1) a pragmatic web-focused language | + | * Defining bitmasks/ |
- | > 2) a loosely typed language | + | * Help make it more clear what is important, exposing harmless constants clutters documentation |
- | > 3) a language which caters | + | |
- | Your RFC should move PHP forward following his vision. As [[http:// | + | ===== Proposal ===== |
- | large chunk of our userbase, and not something that could be useful in some | + | |
- | extremely specialized edge cases [...] Make sure you think about the full context, the huge audience out there, the consequences of making the learning curve steeper with | + | |
- | every new feature, and the scope of the goodness that those new features bring." | + | |
- | ===== Introduction ===== | + | This RFC propose PHP support class constant visibility that mirror the behavior of method |
- | The elevator pitch for the RFC. The first paragraph in this section will be slightly larger to give it emphasis; please write a good introduction. | + | and property visibility. |
- | ===== Proposal ===== | + | Class constant may be define as public, private or protected. class constants declared |
- | All the features and examples of the proposal. | + | without any explicit visibility keyword are defined as public. |
- | To [[http://news.php.net/php.internals/66051|paraphrase Zeev Suraski]], explain hows the proposal brings substantial value to be considered | + | Proposed syntax: |
- | for inclusion in one of the world's most popular programming languages. | + | |
+ | <code php> | ||
+ | <?php | ||
+ | |||
+ | class Token { | ||
+ | // Constants default to public | ||
+ | const PUBLIC_CONST = 0; | ||
+ | |||
+ | | ||
+ | private const PRIVATE_CONST = 0; | ||
+ | protected const PROTECTED_CONST = 0; | ||
+ | public const PUBLIC_CONST_TWO = 0; | ||
+ | |||
+ | //Constants can only have one visibility declaration list | ||
+ | private const FOO = 1, BAR = 2; | ||
+ | } | ||
+ | |||
+ | |||
+ | // | ||
+ | interface ICache { | ||
+ | public const PUBLIC = 0; | ||
+ | const IMPLICIT_PUBLIC = 1; | ||
+ | } | ||
+ | |||
+ | // | ||
+ | class testClass | ||
+ | const TEST_CONST = 'test'; | ||
+ | } | ||
+ | |||
+ | $obj = new ReflectionClass( " | ||
+ | $const = $obj-> | ||
+ | $consts = $obj-> | ||
+ | |||
+ | </ | ||
- | Remember that the RFC contents should be easily reusable in the PHP Documentation. | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | What breaks, and what is the justification for it? | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | List the proposed | + | |
+ | This RFC targets | ||
===== RFC Impact ===== | ===== RFC Impact ===== | ||
+ | |||
==== To SAPIs ==== | ==== To SAPIs ==== | ||
- | Describe the impact to CLI, Development web server, embedded PHP etc. | + | |
+ | None. | ||
==== To Existing Extensions ==== | ==== To Existing Extensions ==== | ||
- | Will existing extensions be affected? | ||
- | ==== To Opcache ==== | + | None, all the class constant APIs will be the same. |
- | It is necessary | + | There will be new _ex APIs that allow callers |
- | Please explain how you have verified your RFC's compatibility with opcache. | + | If a extension accesses non-public structures (the now non-existent class_constants HashTable) there will be breakage |
- | ==== New Constants | + | ==== To Opcache |
- | Describe any new constants so they can be accurately and comprehensively explained in the PHP documentation. | + | |
- | ==== php.ini Defaults ==== | + | Need update. |
- | If there are any php.ini settings then list: | + | |
- | * hardcoded default values | + | |
- | * php.ini-development values | + | |
- | * php.ini-production values | + | |
- | ===== Open Issues | + | ===== Vote ===== |
- | Make sure there are no open issues when the vote starts! | + | |
- | ===== Unaffected PHP Functionality ===== | + | Simple Yes/No option. This requires a 2/3 majority. |
- | List existing areas/features of PHP that will not be changed by the RFC. | + | |
- | This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, and helps reduces mail list noise. | + | This vote will close on 06:00 UTC on Tuesday 2015-10-27 |
- | ===== Future Scope ===== | + | <doodle title="Class Constant Visibility" |
- | This sections details areas where the feature might be improved in future, but that are not currently proposed in this RFC. | + | * Yes |
- | + | * No | |
- | ===== Proposed Voting Choices ===== | + | </doodle> |
- | Include these so readers know where you are heading and can discuss the proposed voting options. | + | |
- | + | ||
- | State whether this project requires a 2/3 or 50%+1 majority (see [[voting]]) | + | |
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | Links to any external patches and tests go here. | ||
- | If there is no patch, make it clear who will create a patch, or whether a volunteer to help with implementation is needed. | + | A pull request has been made. It is feature complete but needs review, more tests, and help with opcache changes : https:// |
- | Make it clear if the patch is intended to be the final patch, or is just a prototype. | + | This feature |
- | + | ||
- | ===== Implementation ===== | + | |
- | After the project is implemented, | + | |
- | - the version(s) it was merged | + | |
- | | + | |
- | - a link to the PHP manual entry for the feature | + | |
===== References ===== | ===== References ===== | ||
- | Links to external references, discussions or RFCs | + | * http:// |
+ | * http:// | ||
+ | |||
+ | ===== Changelog ===== | ||
- | ===== Rejected Features ===== | + | * V0.1 Initial version |
- | Keep this updated with features that were discussed on the mail lists. | + | * V0.2 Adopted by Sean DuBois < |
rfc/class_const_visibility.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1