rfc:reflectionparameter-getclassname
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:reflectionparameter-getclassname [2015/01/31 04:09] – created philstu | rfc:reflectionparameter-getclassname [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: ReflectionParameter:: | ====== PHP RFC: ReflectionParameter:: | ||
- | * Version: 0.1 | + | * Version: 0.2 |
* Date: 2015-01-30 | * Date: 2015-01-30 | ||
* Author: Phil Sturgeon, me@philsturgeon.uk | * Author: Phil Sturgeon, me@philsturgeon.uk | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | Adds a new method to ReflectionParameter to allow easy access to a class name in a type hint, avoiding the need to actually load the class and use `get_class()` or `::class`. | + | Adds a new method to ReflectionParameter to allow easy access to a class name in a type hint, avoiding the need to actually load the class and use `getClass()->name`. |
===== Proposal ===== | ===== Proposal ===== | ||
Line 16: | Line 16: | ||
<PHP> | <PHP> | ||
<?php | <?php | ||
+ | |||
+ | use Bar\Baz; | ||
+ | |||
class Foo { | class Foo { | ||
- | public function bar(Qux $qux) {} | + | public function bar(Qux $qux, $bar, Baz $baz, \Bar\Quz $quz) {} |
+ | |||
+ | public function waldo(array $wibble, callable $wobble) {} | ||
} | } | ||
Line 25: | Line 30: | ||
var_dump($params[0]-> | var_dump($params[0]-> | ||
+ | var_dump($params[1]-> | ||
+ | var_dump($params[2]-> | ||
+ | var_dump($params[3]-> | ||
+ | |||
+ | $method = $class-> | ||
+ | $params = $method-> | ||
+ | var_dump($params[0]-> | ||
+ | var_dump($params[1]-> | ||
</ | </ | ||
+ | |||
+ | This is only targeted at classes, not any other typehint. If scalar type hints come then I'm sure they' | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 38: | Line 53: | ||
None so far | None so far | ||
- | |||
- | ===== Proposed Voting Choices ===== | ||
- | |||
- | 50%+1 majority | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== |
rfc/reflectionparameter-getclassname.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1