rfc:stack-frame-class
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:stack-frame-class [2020/07/07 18:38] – created brzuchal | rfc:stack-frame-class [2020/07/21 09:53] – removed methods from the class API brzuchal | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: StackFrame class ====== | ====== PHP RFC: StackFrame class ====== | ||
- | * Version: | + | * Version: |
* Date: 2020-07-07 | * Date: 2020-07-07 | ||
- | * Author: Michał Brzuchalski, | + | * Author: Michał |
* Status: Under Discussion | * Status: Under Discussion | ||
+ | * Target Version: PHP 8.0 | ||
* First Published at: http:// | * First Published at: http:// | ||
+ | * Implementation: | ||
+ | ===== Introduction ===== | ||
The '' | The '' | ||
- | |||
- | ===== Introduction ===== | ||
- | ... | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | ... | + | Introduce new '' |
+ | |||
+ | There are two places where this could be a replacement for retrieving trace in array of arrays way and these are '' | ||
+ | |||
+ | ==== StackFrame class ==== | ||
+ | |||
+ | '' | ||
+ | |||
+ | There are additional properties and methods which expose additional information: | ||
+ | |||
+ | * property '' | ||
+ | * property '' | ||
+ | |||
+ | <code php> | ||
+ | final class StackFrame implements ArrayAccess | ||
+ | { | ||
+ | public ?string $file; | ||
+ | |||
+ | public ?int $line; | ||
+ | |||
+ | public ?string $function; | ||
+ | |||
+ | public ?string $class; | ||
+ | |||
+ | public ?object $object; | ||
+ | |||
+ | public ?string $objectClass; | ||
+ | |||
+ | public ?string $type; | ||
+ | |||
+ | public ?\Closure $closure; | ||
+ | |||
+ | public array $args = []; | ||
+ | |||
+ | public static function getTrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT, | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Example ==== | ||
+ | An example below shows exactly the same portion of information as if it would call '' | ||
+ | |||
+ | <code php> | ||
+ | function frames() { | ||
+ | return StackFrame:: | ||
+ | } | ||
+ | $frame = frames()[0]; | ||
+ | |||
+ | var_dump([ | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ]); | ||
+ | </ | ||
+ | |||
+ | ==== Performance ==== | ||
+ | On a test script with 1M recursions to produce huge result results were as above: | ||
+ | |||
+ | - '' | ||
+ | - '' | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | ... | + | If vote decides about changing '' |
+ | Although a '' | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | Next PHP 8.x | + | Next PHP 8.0 |
===== RFC Impact ===== | ===== RFC Impact ===== | ||
==== To SAPIs ==== | ==== To SAPIs ==== | ||
- | None | + | None. |
==== To Existing Extensions ==== | ==== To Existing Extensions ==== | ||
Line 31: | Line 94: | ||
==== New Constants ==== | ==== New Constants ==== | ||
- | Not yet. | + | None. |
- | ===== 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. | + | As this is a language in exception handling mechanism it requires 2/3 accepted. |
- | ===== Patches and Tests ===== | + | The vote will be a simple Yes/No for '' |
- | 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. | + | |
- | + | ||
- | 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 | + | |
===== Implementation ===== | ===== Implementation ===== | ||
- | After the project is implemented, | + | * [[https:// |
- | | + | |
- | - 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 ===== | + | |
- | Links to external references, discussions or RFCs | + | |
- | + | ||
- | ===== Rejected Features ===== | + | |
- | Keep this updated with features that were discussed on the mail lists. | + |
rfc/stack-frame-class.txt · Last modified: 2020/08/04 08:00 by brzuchal