rfc:attributes_v2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:attributes_v2 [2020/04/17 13:49] – beberlei | rfc:attributes_v2 [2020/08/01 23:38] (current) – carusogabriel | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Attributes v2 ====== | ====== PHP RFC: Attributes v2 ====== | ||
- | * Version: 0.4 | + | * Version: 0.5 |
* Date: 2020-03-09 | * Date: 2020-03-09 | ||
* Author: Benjamin Eberlei (beberlei@php.net), | * Author: Benjamin Eberlei (beberlei@php.net), | ||
- | * Status: | + | * Status: |
+ | * Target: 8.0 | ||
* First Published at: http:// | * First Published at: http:// | ||
* Implementation: | * Implementation: | ||
Line 102: | Line 103: | ||
<code php> | <code php> | ||
<< | << | ||
- | function foo() {} | ||
- | </ | ||
- | |||
- | The parser understands the context to differentiate them from bitshifts: | ||
- | |||
- | <code php> | ||
- | << | ||
function foo() {} | function foo() {} | ||
</ | </ | ||
Line 253: | Line 247: | ||
**Note:** This is intentionally different from the previous Attributes RFC where an object | **Note:** This is intentionally different from the previous Attributes RFC where an object | ||
with ast\node was returned. | with ast\node was returned. | ||
+ | |||
+ | The parser understands the context to differentiate attributes from bitshifts in constant ASTs. | ||
+ | |||
+ | <code php> | ||
+ | << | ||
+ | function foo() {} | ||
+ | </ | ||
==== Reflection ==== | ==== Reflection ==== | ||
Line 279: | Line 280: | ||
<code php> | <code php> | ||
- | $attributes = $reflectionFunction-> | + | $attributes = $reflectionFunction-> |
+ | | ||
+ | | ||
+ | ); | ||
</ | </ | ||
Line 289: | Line 293: | ||
public function getName(): string | public function getName(): string | ||
public function getArguments(): | public function getArguments(): | ||
- | public function | + | public function |
} | } | ||
</ | </ | ||
Line 295: | Line 299: | ||
Because validation of attributes is only performed during | Because validation of attributes is only performed during | ||
- | // | + | // |
declare the attribute class. | declare the attribute class. | ||
from // | from // | ||
Line 324: | Line 328: | ||
var_dump($attributes[0]-> | var_dump($attributes[0]-> | ||
var_dump($attributes[0]-> | var_dump($attributes[0]-> | ||
- | var_dump($attributes[0]-> | + | var_dump($attributes[0]-> |
} | } | ||
Line 527: | Line 531: | ||
foreach ($attributes as $listenerAttribute) { | foreach ($attributes as $listenerAttribute) { | ||
/** @var $listener Listener */ | /** @var $listener Listener */ | ||
- | $listener = $listenerAttribute-> | + | $listener = $listenerAttribute-> |
// with $listener instanceof Listener attribute, | // with $listener instanceof Listener attribute, | ||
Line 746: | Line 750: | ||
* Other languages such as Go have simple but powerful serialization from XML/JSON to objects and back. The combination of typed properties an attributes puts this in reach for core or a PHP extension to implement. | * Other languages such as Go have simple but powerful serialization from XML/JSON to objects and back. The combination of typed properties an attributes puts this in reach for core or a PHP extension to implement. | ||
* An alternative " | * An alternative " | ||
- | * Extending userland attributes to allow declaring which target they are allowed to be declared on including validation of those targets in // | + | * Extending userland attributes to allow declaring which target they are allowed to be declared on including validation of those targets in // |
- | ===== Proposed | + | ===== Voting ===== |
- | * Accept PHP Attributes v2 into core? 2/3 majority | + | <doodle title=" |
- | * Which syntax to use for attributes? "<<>> | + | |
+ | * No | ||
+ | </ | ||
+ | |||
+ | Secondary vote (choice with the most votes is picked): | ||
+ | |||
+ | <doodle title=" | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Vote closes on May 4th, 12:00 UTC. | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
Line 800: | Line 815: | ||
* Changed validation of compiler attributes to use a C callback instead of instantiating object | * Changed validation of compiler attributes to use a C callback instead of instantiating object | ||
* Offer alternative syntax " | * Offer alternative syntax " | ||
+ | |||
+ | 0.5: | ||
+ | |||
+ | * Rename ReflectionAttribute:: | ||
rfc/attributes_v2.1587131382.txt.gz · Last modified: 2020/04/17 13:49 by beberlei