rfc:to-array
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:to-array [2019/12/04 18:05] – stevenwadejr | rfc:to-array [2020/02/11 12:52] – Remove reference to print_r() casting to array stevenwadejr | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2019-08-28 | * Date: 2019-08-28 | ||
* Author: Steven Wade, stevenwadejr@gmail.com | * Author: Steven Wade, stevenwadejr@gmail.com | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | PHP contains many [[https:// | ||
This RFC proposes to add a new magic method called < | This RFC proposes to add a new magic method called < | ||
+ | |||
+ | PHP contains many [[https:// | ||
===== Proposal ===== | ===== Proposal ===== | ||
Line 43: | Line 44: | ||
<code php> | <code php> | ||
- | print_r($person); | ||
- | |||
- | // Output | ||
- | /* | ||
- | Array | ||
- | ( | ||
- | [name] => John Doe | ||
- | [email] => j.doe@example.com | ||
- | ) | ||
- | */ | ||
- | |||
$personArray = (array) $person; // casting triggers __toArray() | $personArray = (array) $person; // casting triggers __toArray() | ||
</ | </ | ||
Line 102: | Line 92: | ||
**array_* | **array_* | ||
- | The array operating functions listed on the [[ref.array.php|Array Functions]] would first convert an object implementing the < | + | The array operating functions listed on the [[https:// |
<code php> | <code php> | ||
- | print_r(array_keys($person)); | + | print_r( |
+ | | ||
+ | ); | ||
// Output | // Output | ||
Line 118: | Line 110: | ||
==== What this is not ==== | ==== What this is not ==== | ||
- | This proposal does not allow accessing and setting values as you would in a normal array, that functionality remains with classes implementing the [[class.arrayaccess.php|ArrayAccess]] interface. | + | This proposal does not allow accessing and setting values as you would in a normal array, that functionality remains with classes implementing the [[https:// |
- | Discuss what the RFC does not cover (accessing and setting values as you would in a normal array. | + | |
+ | Array functions that operate on an array by reference such as < | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | What breaks, and what is the justification for it? | + | :?: Help needed |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 129: | Line 122: | ||
===== RFC Impact ===== | ===== RFC Impact ===== | ||
==== To SAPIs ==== | ==== To SAPIs ==== | ||
- | Describe the impact to CLI, Development web server, embedded PHP etc. | + | :?: Help needed |
==== To Existing Extensions ==== | ==== To Existing Extensions ==== | ||
- | Will existing extensions be affected? | + | :?: Help needed |
==== To Opcache ==== | ==== To Opcache ==== | ||
- | It is necessary to develop RFC's with opcache in mind, since opcache is a core extension distributed with PHP. | + | :?: Help needed |
- | Please explain how you have verified your RFC's compatibility with opcache. | + | ===== Concerns ===== |
- | ===== Open Issues ===== | + | A [[https:// |
- | Make sure there are no open issues when the vote starts! | + | |
- | ===== Unaffected PHP Functionality ===== | + | >As it currently stands, the array cast is the only operation capable |
- | List existing areas/ | + | |
- | This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, and helps reduces mail list noise. | + | As a response to this concern, the new < |
- | + | ||
- | ===== Future Scope ===== | + | |
- | This section 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. | + | Vote will require 2/3 majority |
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | Links to any external patches and tests go here. | + | No patch exists yet. A [[https:// |
- | + | ||
- | 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. | + | |
- | + | ||
- | For changes affecting the core language, you should also provide a patch for the language specification. | + | |
- | + | ||
- | ===== Implementation ===== | + | |
- | After the project is implemented, | + | |
- | - the version(s) it was merged into | + | |
- | - a link to the git commit(s) | + | |
- | - a link to the PHP manual entry for the feature | + | |
- | - a link to the language specification section (if any) | + | |
===== References ===== | ===== References ===== | ||
- | Links to external references, discussions or RFCs | + | * PHP Manual: [[https:// |
+ | * PHP RFC: [[https:// | ||
+ | * Initial idea and discussion: [[https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
- | Keep this updated with features that were discussed on the mail lists. | + |
rfc/to-array.txt · Last modified: 2020/02/11 13:57 by stevenwadejr