rfc:normalize_inc_dec

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:normalize_inc_dec [2013/12/19 09:38] datibbawrfc:normalize_inc_dec [2017/09/22 13:28] – external edit 127.0.0.1
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: Tjerk Meesters (datibbaw) 
-  * Status: Draft+  * Status: Abandoned
   * First Published at: https://wiki.php.net/rfc/normalize_inc_dec   * First Published at: https://wiki.php.net/rfc/normalize_inc_dec
  
 ===== Introduction ===== ===== Introduction =====
  
-This proposal aims to do away with the current behaviour:+The current behaviour of increment and decrement operators is not very intuitive:
  
 <code php> <code php>
Line 22: Line 22:
 // empty strings // empty strings
 $a = ''; ++$a; // string(1) "1" $a = ''; ++$a; // string(1) "1"
-$a = ''; --$a; // int(-1) 
  
 // non-numeric strings // non-numeric strings
Line 32: Line 31:
 ===== Proposal ===== ===== Proposal =====
  
-All the features and examples of the proposal.+The proposal is: 
 +  - always treat boolean and null types as an integer, but raise a warning. 
 +  - deprecate alphanumeric increment and introduce ''str_inc()'' and ''str_dec()''.
  
-To [[http://news.php.net/php.internals/66051|paraphrase Zeev Suraski]], explain hows the proposal brings substantial value to be considered +==== Operation on bool null ====
-for inclusion in one of the world's most popular programming languages.+
  
-Remember that the RFC contents should be easily reusable in the PHP Documentation. +<code php> 
-===== Backward Incompatible Changes =====+// booleans 
 +$a false;  
 +++$a; // int(1) + warning 
 +++$a; // int(2) 
 +$a true;  
 +--$a; // int(0) + warning 
 +--$a; // int(-1)
  
-What breaks, and what is the justification for it?+// null values 
 +$a = null; --$a; // int(-1) + warning 
 +$a = null; ++$a; // int(1) + warning 
 +</code>
  
-===== Proposed PHP Version(s) =====+==== Operation on alphanumeric strings ====
  
-List the proposed PHP versions that the feature will be included in.  Use relative versions such as "next PHP 5.xor "next PHP 5.x.y".+<code php> 
 +// non-numeric strings 
 +$a = '12d9';  
 +++$a; // string(4) "12e0+ Notice: String increment is deprecated, use str_inc() instead in php shell code on line 1 
 +++$a; // float(13) 
 +</code>
  
-===== SAPIs Impacted =====+Additionally, it makes two new string functions available:
  
-Describe the impact to CLI, Development web server, embedded PHP etc.+  * ''str_inc($str)''to perform the current string increments. 
 +  * ''str_dec($str)'' - the string decrement.
  
-===== Impact to Existing Extensions =====+===== Backward Incompatible Changes =====
  
-Will existing extensions be affected?+Incrementing ''null'' will now raise a warning; incrementing alphanumeric strings will raise a deprecation notice.
  
-===== New Constants ===== +===== Proposed PHP Version(s) =====
- +
-Describe any new constants so they can be accurately and comprehensively explained in the PHP documentation. +
- +
-===== php.ini Defaults =====+
  
-If there are any php.ini settings then list: +**PHP 7**
-  hardcoded default values +
-  php.ini-development values +
-  php.ini-production values+
  
 ===== 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/features of PHP that will not be changed by the RFC. +The changes do not affect the following data types: 
- +  * ''array'' 
-This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, and helps reduces mail list noise. +  * ''int'
- +  * ''float'' 
-===== Future Scope ===== +  * ''object'' 
- +  * ''resource''
-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. +
- +
-Make it clear if the patch is intended to be the final patch, or is just a prototype.+
  
 ===== Implementation ===== ===== Implementation =====
  
-After the project is implemented, this section should contain  +N/A
-  - the version(s) it was merged to +
-  - a link to the git commit(s) +
-  - a link to the PHP manual entry for the feature+
  
 ===== References ===== ===== References =====
  
-Links to external references, discussions or RFCs+[[https://github.com/php/php-src/pull/547|Pull Request]] 
 + 
 +The competing proposal: 
 + 
 +[[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