rfc:stack-frame-class
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:stack-frame-class [2020/07/07 20:37] – brzuchal | rfc:stack-frame-class [2020/07/21 05:12] – $file and $line nullability 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 | * Target Version: PHP 8.0 | ||
Line 12: | Line 12: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | Introduce new '' | + | Introduce new '' |
There are two places where this could be a replacement for retrieving trace in array of arrays way and these are '' | There are two places where this could be a replacement for retrieving trace in array of arrays way and these are '' | ||
Line 18: | Line 18: | ||
==== StackFrame class ==== | ==== StackFrame class ==== | ||
- | '' | + | '' |
+ | |||
+ | There are additional properties and methods which expose additional information: | ||
+ | |||
+ | * property '' | ||
+ | * property '' | ||
<code php> | <code php> | ||
final class StackFrame implements ArrayAccess | final class StackFrame implements ArrayAccess | ||
{ | { | ||
- | public | + | public |
| | ||
- | public | + | public |
| | ||
- | public | + | public ?string $function; |
| | ||
- | public | + | public ?string $class; |
| | ||
- | public | + | public ?object $object; |
+ | |||
+ | public ?string $object_class; | ||
+ | |||
+ | public ?\Closure $closure; | ||
| | ||
- | public | + | public array $args; |
| | ||
- | public static function getTrace(): array {} | + | public static function getTrace(int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT, |
- | public function getFile(): string {} | + | public function getFile(): |
- | public function getLine(): int {} | + | public function getLine(): |
public function getFunction(): | public function getFunction(): | ||
Line 46: | Line 55: | ||
public function getObject(): | public function getObject(): | ||
+ | | ||
+ | public function getObjectClass(): | ||
+ | |||
+ | public function getClosure(): | ||
public function getType(): ?string {} | public function getType(): ?string {} | ||
Line 51: | Line 64: | ||
public function getArgs(): array {} | public function getArgs(): array {} | ||
} | } | ||
+ | </ | ||
+ | |||
+ | ==== 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([ | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ]); | ||
</ | </ | ||
rfc/stack-frame-class.txt · Last modified: 2020/08/04 08:00 by brzuchal