Both sides previous revisionPrevious revisionNext revision | Previous revision |
rfc:calls_in_constant_expressions_poll [2020/02/17 01:53] – tandre | rfc:calls_in_constant_expressions_poll [2020/03/04 13:53] (current) – Close the poll tandre |
---|
* Date: 2020-02-16 | * Date: 2020-02-16 |
* Author: Tyson Andre, tandre@php.net | * Author: Tyson Andre, tandre@php.net |
* Status: Draft | * Status: Closed (ends 2020-03-04) |
* First Published at: https://wiki.php.net/rfc/calls_in_constant_expressions_poll | * First Published at: https://wiki.php.net/rfc/calls_in_constant_expressions_poll |
| |
The planned ''strict_types'' behavior is to use the ''strict_types'' setting of the file containing the constant expression. | The planned ''strict_types'' behavior is to use the ''strict_types'' setting of the file containing the constant expression. |
| |
===== Proposed Voting Choices ===== | ===== Vote ===== |
| |
The evaluation order and error handling would be as described in https://wiki.php.net/rfc/calls_in_constant_expressions , except where noted otherwise. | The evaluation order and error handling would be as described in https://wiki.php.net/rfc/calls_in_constant_expressions , except where noted otherwise. |
(e.g. ''const X = ["constant value", any_function_call()][0]'' will not throw an error about being an invalid constant even if ''any_function_call()'' contains objects or references, because the final result is the string ''"constant value"'') | (e.g. ''const X = ["constant value", any_function_call()][0]'' will not throw an error about being an invalid constant even if ''any_function_call()'' contains objects or references, because the final result is the string ''"constant value"'') |
| |
| Voting ends March 4th, 2020. |
| |
| <doodle title="Support calls in class constants" auth="tandre" voteType="single" closed="true"> |
<doodle title="Support calls in class constants" auth="tandre" voteType="single" closed="false"> | |
* No | * No |
* Whitelist of global functions | * Whitelist of global functions |
</doodle> | </doodle> |
. | . |
<doodle title="Support calls in global constants" auth="tandre" voteType="single" closed="false"> | <doodle title="Support calls in global constants" auth="tandre" voteType="single" closed="true"> |
* No | * No |
* Whitelist of global functions | * Whitelist of global functions |
* ''function($x) { return $x*$x; }'' | * ''function($x) { return $x*$x; }'' |
| |
<doodle title="Support calls in static property declarations" auth="tandre" voteType="single" closed="false"> | <doodle title="Support calls in static property declarations" auth="tandre" voteType="single" closed="true"> |
* No | * No |
* Whitelist of global functions | * Whitelist of global functions |
</doodle> | </doodle> |
. | . |
<doodle title="Support calls in static variables" auth="tandre" voteType="single" closed="false"> | <doodle title="Support calls in static variables" auth="tandre" voteType="single" closed="true"> |
* No | * No |
* Whitelist of global functions | * Whitelist of global functions |
. | . |
| |
<doodle title="Support calls in parameter defaults" auth="tandre" voteType="single" closed="false"> | <doodle title="Support calls in parameter defaults" auth="tandre" voteType="single" closed="true"> |
* No | * No |
* Whitelist of global functions | * Whitelist of global functions |
===== References ===== | ===== References ===== |
https://wiki.php.net/rfc/calls_in_constant_expressions | https://wiki.php.net/rfc/calls_in_constant_expressions |
| |
| https://externals.io/message/108630 |
| |
===== Rejected Features ===== | ===== Rejected Features ===== |
| |
Changing the behavior of instance properties was rejected. If functions were only invoked once, then ''private $x = generate_unique_id()'' would be unintuitive. If it was invoked for every created object, the implementation would require changes to internals that I'm probably unable to implement (these changes would affect unserialization, ways when object creation can throw, the behavior of internal functions that create and return objects, opcache, etc.) | Changing the behavior of instance properties was rejected. If functions were only invoked once, then ''private $x = generate_unique_id()'' would be unintuitive. If it was invoked for every created object, the implementation would require changes to internals that I'm probably unable to implement (these changes would affect unserialization, ways when object creation can throw, the behavior of internal functions that create and return objects, opcache, etc.) |