rfc:scalar_type_hints
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:scalar_type_hints [2015/02/05 20:32] – Split Vote into sections ajf | rfc:scalar_type_hints [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Scalar Type Hints ====== | ====== PHP RFC: Scalar Type Hints ====== | ||
- | * Version: 0.3 | + | * Version: 0.3.1 |
- | * Date: 2014-12-14 (initial draft; put Under Discussion 2014-12-31; version 0.2 created 2015-01-13) | + | * Date: 2014-12-14 (initial draft; put Under Discussion 2014-12-31; version 0.2 created 2015-01-13; withdrawn 2015-02-15) |
* Author: Andrea Faulds, ajf@ajf.me | * Author: Andrea Faulds, ajf@ajf.me | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 186: | Line 186: | ||
==== History ==== | ==== History ==== | ||
- | PHP has had parameter type hints for class names since PHP 5.0, arrays since PHP 5.1 and callables since PHP 5.4. These type hints allow the PHP runtime to ensure that correctly-typed arguments are passed to functions, and make function signatures more informative. Unfortunately, | + | PHP has had parameter type hints for interface and class names since PHP 5.0, arrays since PHP 5.1 and callables since PHP 5.4. These type hints allow the PHP runtime to ensure that correctly-typed arguments are passed to functions, and make function signatures more informative. Unfortunately, |
There have been some previous attempts at adding scalar type hints, such as the [[rfc: | There have been some previous attempts at adding scalar type hints, such as the [[rfc: | ||
Line 399: | Line 399: | ||
This doesn' | This doesn' | ||
- | When the strict type-checking mode isn't in use (which is the default), function calls behave identically to previous PHP versions. | + | When the strict type-checking mode isn't in use (which is the default), function calls to built-in and extension PHP functions |
===== Open Issues ===== | ===== Open Issues ===== | ||
Line 415: | Line 415: | ||
Because scalar type hints guarantee that a passed argument will be of a certain type within a function body (at least initially), this could be used in the Zend Engine for optimisations. For example, if a function takes two '' | Because scalar type hints guarantee that a passed argument will be of a certain type within a function body (at least initially), this could be used in the Zend Engine for optimisations. For example, if a function takes two '' | ||
+ | |||
+ | In discussions around this RFC, the '' | ||
+ | |||
+ | Another issue that came up is PHP's lack of a typehint for numbers (which also came up with the previous Scalar Type Hinting with Cast RFC). I plan to propose a '' | ||
===== Vote ===== | ===== Vote ===== | ||
- | As this is a language change, this RFC requires a 2/3 majority to pass. Voting for all three votes started on 2015-02-05 and all end on 2015-02-19. | + | As this is a language change, this RFC requires a 2/3 majority to pass. Voting for all three votes started on 2015-02-05 and all were to end on 2015-02-19, but the voting was cancelled and the RFC withdrawn on 2015-02-15. |
==== Main ==== | ==== Main ==== | ||
Line 424: | Line 428: | ||
This vote is for the RFC itself. | This vote is for the RFC itself. | ||
- | <doodle title=" | + | <doodle title=" |
* Yes | * Yes | ||
* No | * No | ||
Line 433: | Line 437: | ||
This second vote is to solve the open issue regarding the '' | This second vote is to solve the open issue regarding the '' | ||
- | <doodle title=" | + | <doodle title=" |
* Allow synonyms | * Allow synonyms | ||
* Reserve synonyms and produce error message when used | * Reserve synonyms and produce error message when used | ||
Line 443: | Line 447: | ||
This final vote is in case the RFC fails to pass. It's a 2/3 majority-required backwards compatibility-breaking language change, which is to reserve the type hint names proposed by the RFC, so that a future RFC could implement scalar type hints without requiring a backwards compatibility break. The type names reserved include the synonyms '' | This final vote is in case the RFC fails to pass. It's a 2/3 majority-required backwards compatibility-breaking language change, which is to reserve the type hint names proposed by the RFC, so that a future RFC could implement scalar type hints without requiring a backwards compatibility break. The type names reserved include the synonyms '' | ||
- | <doodle title=" | + | <doodle title=" |
* Yes | * Yes | ||
* No | * No | ||
Line 466: | Line 470: | ||
===== Changelog ===== | ===== Changelog ===== | ||
+ | * v0.3.1 - Noted '' | ||
* v0.3 - Return types support | * v0.3 - Return types support | ||
* v0.2.3 - '' | * v0.2.3 - '' |
rfc/scalar_type_hints.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1