rfc:reflectionparameter.typehint

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:reflectionparameter.typehint [2014/05/30 16:25] – The __ in toString causes issues with wiki layout. levimrfc:reflectionparameter.typehint [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 5: Line 5:
   * Status: Under Discussion   * Status: Under Discussion
   * First Published at: http://wiki.php.net/rfc/reflectionparameter.typehint   * First Published at: http://wiki.php.net/rfc/reflectionparameter.typehint
 +
 +===== Introduction =====
 +
 +This RFC proposes improvements to the way we handle type information in reflection. This work will make it easier for writing tools that convert type information from reflection into strings. This RFC also adds support the reflection API for type information return types if the [[returntypehinting|Return Type RFC]] is accepted.
  
 ===== Proposal ===== ===== Proposal =====
  
-This RFC proposes a class to represent type information; it also adds methods to ReflectionParameter to utilize this information: ReflectionParameter::hasTypeAnnotation() and ReflectionParameter::getTypeAnnotation(). Additionally it adds an explicit ''toString'' method to make parsing function/method signatures and replicating them for mocking frameworks simpler.+This RFC proposes a new class ''ReflectionTypeAnnotation'' to represent type information. This RFC adds methods to ''ReflectionParameter'' to use this new class<php>ReflectionParameter::hasTypeAnnotation()</php> and <php>ReflectionParameter::getTypeAnnotation()</php>If the Return Type RFC is accepted it will then it will also use this new ''ReflectionTypeAnnotation'' class.
  
-Current mocking frameworks have to cast the ReflectionParameter to a string, then text parse that string to retrieve the information.+The class ''ReflectionTypeAnnotation'' also has ''%%__toString%%'' method to make parsing function/method signatures and replicating them for mocking frameworks simpler; current mocking frameworks have to cast the ReflectionParameter to a string, then text parse that string to retrieve the information.
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
  
-5.next (5.7)+PHP 7
  
 ===== New Reflection class type: ReflectionTypeAnnotation ===== ===== New Reflection class type: ReflectionTypeAnnotation =====
  
-  class ReflectionTypeAnnotation implements Reflector {+<PHP> 
 +class ReflectionTypeAnnotation implements Reflector {
     public function __toString() { /* returns type annotation string (e.g. "array", "stdClass", etc...) */ }     public function __toString() { /* returns type annotation string (e.g. "array", "stdClass", etc...) */ }
     public function isArray() { /* true if the typehint is "array" */ }     public function isArray() { /* true if the typehint is "array" */ }
     public function isCallable() { /* true if the typehint is "callable" */ }     public function isCallable() { /* true if the typehint is "callable" */ }
     public function isNullable() { /* true if NULL is an acceptable value */ }     public function isNullable() { /* true if NULL is an acceptable value */ }
-  }+} 
 +</PHP>
  
 ===== Implementation and new unit test ===== ===== Implementation and new unit test =====
  
 Original proposal: https://github.com/sgolemon/php-src/commit/d352793a69eb549ffe4b04c4b5dedae2cd4ed831 Original proposal: https://github.com/sgolemon/php-src/commit/d352793a69eb549ffe4b04c4b5dedae2cd4ed831
 +
 Current proposal: https://github.com/sgolemon/php-src/compare/reflection.typehint Current proposal: https://github.com/sgolemon/php-src/compare/reflection.typehint
rfc/reflectionparameter.typehint.1401467125.txt.gz · Last modified: 2017/09/22 13:28 (external edit)