rfc:normalize_inc_dec
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:normalize_inc_dec [2013/12/19 09:28] – created datibbaw | rfc:normalize_inc_dec [2017/02/03 06:20] – krakjoe | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Your Title Here ====== | + | ====== PHP RFC: Normalize increment and decrement operators |
- | * Version: 0.1 | + | * Version: 0.2 |
* Date: 2013-12-19 | * Date: 2013-12-19 | ||
- | * Author: | + | * Author: |
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
- | 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:// | ||
- | |||
- | You RFC should move PHP forward. As [[http:// | ||
- | 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 ===== | ===== Introduction ===== | ||
- | The elevator pitch for the RFC. | + | The current behaviour of increment and decrement operators is not very intuitive: |
- | ===== Proposal ===== | + | <code php> |
+ | // booleans | ||
+ | $a = false; ++$a; // bool(false) | ||
+ | $a = true; --$a; // bool(true) | ||
- | All the features and examples of the proposal. | + | // null values |
+ | $a = null; --$a; // null | ||
+ | $a = null; ++$a; // int(1) | ||
- | To [[http://news.php.net/ | + | // empty strings |
- | for inclusion in one of the world's most popular programming languages. | + | $a = ''; ++$a; // string(1) " |
- | Remember that the RFC contents should be easily reusable in the PHP Documentation. | + | // non-numeric strings |
- | ===== Backward Incompatible Changes ===== | + | $a = ' |
+ | ++$a; // string(4) " | ||
+ | ++$a; // float(13) | ||
+ | </ | ||
- | What breaks, and what is the justification for it? | + | ===== Proposal ===== |
- | ===== Proposed PHP Version(s) ===== | + | The proposal is: |
+ | - always treat boolean and null types as an integer, but raise a warning. | ||
+ | - deprecate alphanumeric increment and introduce '' | ||
- | List the proposed PHP versions that the feature will be included in. Use relative versions such as "next PHP 5.x" or "next PHP 5.x.y" | + | ==== Operation on bool / null ==== |
- | ===== SAPIs Impacted ===== | + | <code php> |
+ | // booleans | ||
+ | $a = false; | ||
+ | ++$a; // int(1) + warning | ||
+ | ++$a; // int(2) | ||
+ | $a = true; | ||
+ | --$a; // int(0) + warning | ||
+ | --$a; // int(-1) | ||
- | Describe the impact to CLI, Development web server, embedded PHP etc. | + | // null values |
+ | $a = null; --$a; // int(-1) + warning | ||
+ | $a = null; ++$a; // int(1) + warning | ||
+ | </ | ||
- | ===== Impact to Existing Extensions ===== | + | ==== Operation on alphanumeric strings |
- | Will existing extensions be affected? | + | <code php> |
+ | // non-numeric strings | ||
+ | $a = ' | ||
+ | ++$a; // string(4) " | ||
+ | ++$a; // float(13) | ||
+ | </ | ||
- | ===== New Constants ===== | + | Additionally, |
- | Describe any new constants so they can be accurately and comprehensively explained in the PHP documentation. | + | * '' |
+ | * '' | ||
- | ===== php.ini Defaults | + | ===== Backward Incompatible Changes |
- | If there are any php.ini settings then list: | + | Incrementing '' |
- | * hardcoded default values | + | |
- | * php.ini-development values | + | ===== Proposed PHP Version(s) ===== |
- | * php.ini-production values | + | |
+ | **PHP 7** | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | Make sure there are no open issues when the vote starts! | + | None. |
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
- | List existing areas/ | + | The changes do not affect |
- | + | * '' | |
- | This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, and helps reduces mail list noise. | + | * '' |
- | + | * '' | |
- | ===== Future Scope ===== | + | * '' |
- | + | * '' | |
- | This sections details areas where the feature might be improved in future, but that are not currently proposed in this RFC. | + | |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Include these so readers know where you are heading and can discuss the proposed voting options. | + | Yay or nay. |
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | Links to any external patches and tests go here. | + | Coming soon ... |
- | If there is no patch, make it clear who will create a patch, or whether a volunteer to help with implementation is needed. | + | ===== Implementation ===== |
- | Make it clear if the patch is intended to be the final patch, or is just a prototype. | + | N/A |
- | ===== Implementation | + | ===== References |
- | After the project is implemented, | + | [[https:// |
- | | + | |
- | - a link to the git commit(s) | + | |
- | - a link to the PHP manual entry for the feature | + | |
- | ===== References ===== | + | The competing proposal: |
- | Links to external references, discussions or RFCs | + | [[alpanumeric_decrement|Alphanumeric Decrement]] |
===== Rejected Features ===== | ===== Rejected Features ===== | ||
Keep this updated with features that were discussed on the mail lists. | Keep this updated with features that were discussed on the mail lists. |
rfc/normalize_inc_dec.txt · Last modified: 2018/06/18 10:17 by cmb