Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision |
rfc:var_type [2016/07/04 19:37] – Added performance again with true info; extended phasing out section; added real-world usage examples. fleshgrinder | rfc:var_type [2016/07/23 21:17] – voting -> declined nikic |
---|
====== PHP RFC: var_type ====== | ====== PHP RFC: var_type ====== |
* Version: 0.4 | * Version: 1.0 |
* Date: 2016-06-25 | * Date: 2016-06-25 |
* Author: Richard Fussenegger <php@fleshgrinder.com> | * Author: Richard Fussenegger <php@fleshgrinder.com> |
* Status: Under Discussion | * Status: Declined |
* First Published at: https://wiki.php.net/rfc/var_type | * First Published at: https://wiki.php.net/rfc/var_type |
| |
| |
It is further recommended to tackle the deprecation and a possible removal of the ''gettype()'' function together with a proper solution for ''settype()'' in a future major release. A possible approach could be to emit an ''E_STRICT'' in PHP 8, deprecate in PHP 9, and remove in PHP 10; or any other combination that results in a long adoption period. | It is further recommended to tackle the deprecation and a possible removal of the ''gettype()'' function together with a proper solution for ''settype()'' in a future major release. A possible approach could be to emit an ''E_STRICT'' in PHP 8, deprecate in PHP 9, and remove in PHP 10; or any other combination that results in a long adoption period. |
| |
==== Usage Examples ==== | |
Some legitimate usage examples from real world userland projects that illustrates that a function like ''var_type()'' (as well as the existing ''gettype()'') has its right to exist and does not encourage //stringy programming//: | |
| |
- ''[[https://github.com/drupal/drupal/blob/8.2.x/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php#L96-L114|drupal/drupal]]'' | |
- ''[[https://github.com/doctrine/annotations/blob/master/lib/Doctrine/Common/Annotations/DocParser.php#L756-L789|doctrine/annotations]]'' | |
- ''[[https://github.com/guzzle/guzzle/blob/master/src/functions.php#L33-L54|guzzlehttp/guzzle]]'' | |
- ''[[https://github.com/guzzle/psr7/blob/master/src/functions.php#L89-L110|guzzlehttp/psr7]]'' | |
- ''[[https://github.com/ircmaxell/password_compat/blob/master/lib/password.php#L76-L94|ircmaxell/password-compat]]'' | |
| |
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== |
This RFC will have two polls, one for the introduction of the ''var_type()'' function and one for the new ''TYPE_*'' constants in userland. Both require a 50%+1 majority to be accepted as they do not change the language's syntax. | This RFC will have two polls, one for the introduction of the ''var_type()'' function and one for the new ''TYPE_*'' constants in userland. Both require a 50%+1 majority to be accepted as they do not change the language's syntax. |
| |
| Voting opened on 2016-07-08 and will end on 2016-07-22 for both votes. |
| |
| == Function == |
| <doodle title="Accept var_type function?" auth="fleshgrinder" voteType="single" closed="false"> |
| * Yes |
| * No |
| </doodle> |
| |
| == Constants == |
| <doodle title="Accept type constants?" auth="fleshgrinder" voteType="single" closed="true"> |
| * Yes |
| * No |
| </doodle> |
| |
===== Patches and Tests ===== | ===== Patches and Tests ===== |
The [[https://github.com/php/php-src/pull/1935|GitHub Pull Request #1935]] contains the implementation as well as tests for the new function. The changes in the PR are considered final, however, a thorough code review would be much appreciated and might result in minor changes. | The [[https://github.com/php/php-src/pull/1935|GitHub Pull Request #1935]] contains the implementation as well as tests for the new function. The changes in the PR are considered final, however, a thorough code review would be much appreciated and might result in minor changes. |
| |
===== Implementation ===== | |
- Merged to Version: //?// | |
- Git Commits: //?// | |
- PHP Manual: https://secure.php.net/var_type | |
| |
===== References ===== | ===== References ===== |