rfc:property_type_hints

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:property_type_hints [2015/12/20 18:43] mindplayrfc:property_type_hints [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== PHP RFC: Property type-hints ====== ====== PHP RFC: Property type-hints ======
-  * Version: 0.1+  * Version: 1.0
   * Date: 2015-07-19   * Date: 2015-07-19
   * Author: Rasmus Schultz <rasmus@mindplay.dk>   * Author: Rasmus Schultz <rasmus@mindplay.dk>
Line 13: Line 13:
 The significance of type-checked properties is a given, as demonstrated by it's inclusion in Hack, as well as other recent scripting languages, including Typescript, Dart and ActionScript. The need for type-hinting is demonstrated by the widespread use of php-doc, and support for such type-hinting in modern PHP IDEs. The significance of type-checked properties is a given, as demonstrated by it's inclusion in Hack, as well as other recent scripting languages, including Typescript, Dart and ActionScript. The need for type-hinting is demonstrated by the widespread use of php-doc, and support for such type-hinting in modern PHP IDEs.
  
-The proposed syntax is compatible with that of Hack, and is a natural addition to the language, resembling the syntax set forth by otherr gruadually-typed (and statically-typed) languages.+The proposed syntax is compatible with that of Hack, and is a natural addition to the language, resembling the syntax set forth by other gruadually-typed (and statically-typed) languages.
  
 ===== Proposal ===== ===== Proposal =====
Line 83: Line 83:
  
 TBD: [[https://wiki.php.net/rfc/reflectionparameter.typehint|Another RFC]] is in the works, which could affect the Reflection API changes proposed by this RFC. TBD: [[https://wiki.php.net/rfc/reflectionparameter.typehint|Another RFC]] is in the works, which could affect the Reflection API changes proposed by this RFC.
 +
 +===== Non-features =====
 +
 +The inclusion of a ''var'' keyword (to be used in place of a type-hint, which would infer the property type-hint from the initialization) was considered, but is not part of this RFC. As per the description of property initialization behavior above, the expression used for initialization of a property is not evaluated until the ''new'' keyword is applied - hence, explicit type-inference in this manner isn't possible, since the property type needs to be available for reflection immediately after loading, e.g. prior to creation of an instance.
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 93: Line 97:
 ==== To Opcache ==== ==== To Opcache ====
 The impact on opcache needs to be examined. The impact on opcache needs to be examined.
 +
 +==== To Zend Engine ====
 +Static type-hints could enable some engine optimizations - this should be investigated.
  
 ===== Open Issues ===== ===== Open Issues =====
-TBD: Documentation for existing, standard classes (reflection, spl, etc.) may need updates, e.g. adding type-hints to existing class documentation.+None
  
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
 The introduction of an optional type-hint does not affect legacy PHP code. The introduction of an optional type-hint does not affect legacy PHP code.
 +
 +To preserve backwards compatibility, existing standard library classes will not have property type-hints added to them.
  
 ===== Future Scope ===== ===== Future Scope =====
Line 116: Line 125:
  
 ===== References ===== ===== References =====
-TBD+None
  
 ===== Rejected Features ===== ===== Rejected Features =====
-TBD+None 
rfc/property_type_hints.1450636987.txt.gz · Last modified: 2017/09/22 13:28 (external edit)