rfc:simple-annotations
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:simple-annotations [2016/05/13 10:04] – mindplay | rfc:simple-annotations [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Simple Annotations ====== | ====== PHP RFC: Simple Annotations ====== | ||
- | * Version: 0.1 | + | * Version: 0.3 |
* Date: 2016-05-13 | * Date: 2016-05-13 | ||
* Author: Rasmus Schultz, rasmus@mindplay.dk | * Author: Rasmus Schultz, rasmus@mindplay.dk | ||
Line 9: | Line 9: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | This RFC proposes the introduction of simple value annotations - arbitrary | + | This RFC proposes the introduction of simple value annotations - arbitrary values |
As an alternative proposal to [[https:// | As an alternative proposal to [[https:// | ||
Line 17: | Line 17: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | The proposed syntax of a single annotation is extremely | + | The proposed syntax of a single annotation is very simple: |
< | < | ||
Line 29: | Line 29: | ||
* '' | * '' | ||
* '' | * '' | ||
- | * function | + | * anonymous '' |
- | * anonymous | + | * anonymous '' |
+ | * argument declarations of functions, methods and closures | ||
Annotations are internally collected, for each annotated class or member, in a list which can be obtained via reflection. | Annotations are internally collected, for each annotated class or member, in a list which can be obtained via reflection. | ||
Line 80: | Line 81: | ||
Annotation expressions are not evaluated until reflection is invoked, and are evaluated only once and internally memoized upon the first call to '' | Annotation expressions are not evaluated until reflection is invoked, and are evaluated only once and internally memoized upon the first call to '' | ||
- | ==== Context | + | ==== Annotations are Context-free ==== |
- | Annotations | + | By design, annotations expressions |
- | This is by design - annotations | + | Annotations |
- | Annotations that do require context should explicitly ask for that context - for example, you could use an anonymous function to provide context via dependency injection. | + | Annotations that do require context should explicitly ask for that context - for example, you could use an anonymous function, a '' |
+ | |||
+ | ==== Reflection API ==== | ||
+ | |||
+ | The following classes will have an added '' | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | The '' | ||
+ | |||
+ | public function getAnnotations($filter = null) : array | ||
+ | |||
+ | The optional '' | ||
+ | |||
+ | * If one of '' | ||
+ | * If a fully-qualified class-name is given, filters annotations using '' | ||
+ | |||
+ | If '' | ||
+ | |||
+ | These methods do not take into account inheritance - annotations belong to the actual *declaration*, | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 118: | Line 141: | ||
Annotations are a new feature - it does not affect any existing functionality. | Annotations are a new feature - it does not affect any existing functionality. | ||
- | ===== Future | + | ===== Out of Scope ===== |
- | TODO file-level annotations? | + | It has been suggested that this RFC should reserve certain names for compiler directives, such as (for instance) the memoization-directive [[https:// |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== |
rfc/simple-annotations.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1