rfc:normalize_inc_dec
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:normalize_inc_dec [2014/02/15 02:12] – datibbaw | rfc:normalize_inc_dec [2018/06/18 10:17] (current) – This RFC appears to be inactive cmb | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Normalize increment and decrement operators ====== | ====== PHP RFC: Normalize increment and decrement operators ====== | ||
- | * Version: 0.1 | + | * Version: 0.2 |
* Date: 2013-12-19 | * Date: 2013-12-19 | ||
* Author: Tjerk Meesters (datibbaw) | * Author: Tjerk Meesters (datibbaw) | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
Line 31: | Line 31: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | The proposal is either: | + | The proposal is: |
- | - Treat boolean and null types as a restricted type value and deprecate alphanumeric increment. | + | - always treat boolean and null types as an integer, but raise a warning. |
- | - Treat boolean and null types as an integer value and deprecate alphanumeric increment. | + | - deprecate alphanumeric increment |
- | - No changes. | + | |
- | ==== Option 1: Restricted type values | + | ==== Operation on bool / null ==== |
<code php> | <code php> | ||
// booleans | // booleans | ||
$a = false; | $a = false; | ||
- | ++$a; // bool(true) | + | ++$a; // int(1) + warning |
- | ++$a; // bool(true) | + | |
- | $a = true; | + | |
- | --$a; // bool(false) | + | |
- | --$a; // bool(false) | + | |
- | + | ||
- | // null values | + | |
- | $a = null; --$a; // null | + | |
- | $a = null; ++$a; // null | + | |
- | + | ||
- | // empty strings | + | |
- | $a = ''; | + | |
- | </ | + | |
- | + | ||
- | ==== Option 2: Integer values ==== | + | |
- | + | ||
- | <code php> | + | |
- | // booleans | + | |
- | $a = false; | + | |
- | ++$a; // bool(true) | + | |
++$a; // int(2) | ++$a; // int(2) | ||
$a = true; | $a = true; | ||
- | --$a; // bool(false) | + | --$a; // int(0) + warning |
--$a; // int(-1) | --$a; // int(-1) | ||
// null values | // null values | ||
- | $a = null; --$a; // int(-1) | + | $a = null; --$a; // int(-1) |
- | $a = null; ++$a; // int(1) | + | $a = null; ++$a; // int(1) |
</ | </ | ||
- | ==== Deprecating | + | ==== Operation on alphanumeric |
<code php> | <code php> | ||
Line 87: | Line 67: | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | With " | + | Incrementing '' |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | **Next 5.x** | + | **PHP 7** |
- | + | ||
- | Introduce a notice for the current string increment use case. This will help developers spot their usage more easily. | + | |
- | + | ||
- | **Next major** | + | |
- | + | ||
- | Removal of string increment using ++ and --. | + | |
===== Open Issues ===== | ===== Open Issues ===== |
rfc/normalize_inc_dec.1392430365.txt.gz · Last modified: 2017/09/22 13:28 (external edit)