rfc:autovivification_false

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:autovivification_false [2021/06/05 19:32] – Reworked RFC to include NULL too dharmanrfc:autovivification_false [2021/07/20 16:42] (current) – Implemented dharman
Line 1: Line 1:
-====== PHP RFC: Deprecate autovivification on false and/or null ======+====== PHP RFC: Deprecate autovivification on false ======
   * Date: 2021-05-25   * Date: 2021-05-25
   * Author: Kamil Tekiela <dharman@php.net>   * Author: Kamil Tekiela <dharman@php.net>
-  * Status: Under Discussion +  * Status: Implemented in PHP 8.1 
-  * Target VersionPHP 8.1+  * Implementationhttps://github.com/php/php-src/pull/7131
  
 ===== Introduction ===== ===== Introduction =====
Line 11: Line 11:
 <PHP> <PHP>
 // From undefined // From undefined
-unset($arr)+$arr[] = 'some value'
-$arr[] = 2;+$arr['doesNotExist'][] = 2;
 // From false // From false
 $arr = false; $arr = false;
Line 21: Line 21:
 </PHP> </PHP>
  
-This RFC talks **only about autovivification from %%false%% and %%null%%**. +This RFC talks **only about autovivification from %%false%%**. 
  
 ===== Proposal ===== ===== Proposal =====
  
-The proposal is to disallow autovivification from %%false%% values and/or %%null%%. We will continue to allow autovivification from undefined variable, but in every other case an error message will be shown:+The proposal is to disallow autovivification from %%false%% values. We will continue to allow autovivification from undefined variable and %%null%%, but in every other case an error message will be shown:
  
 > Cannot use a scalar value as an array > Cannot use a scalar value as an array
  
-In PHP 8.1, appending to a variable of type false will throw a deprecation error+In PHP 8.1, appending to a variable of type false will display a deprecation noticeFor example:
  
-In PHP 9.0, this will throw a fatal error. +> Deprecated: Automatic conversion of false to array is deprecated in 
 + 
 +In PHP 9.0, this will throw a fatal error, the same as for other scalar types
  
 ===== Rationale ===== ===== Rationale =====
Line 50: Line 52:
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
  
-Every single usage autovivification on false values will throw a deprecation error in PHP 8.1 and throw a fatal error in PHP 9.0. A secondary vote will decide if autovivification should be forbidden from %%null%% values too.+Every single usage autovivification on false will throw a deprecation error in PHP 8.1 and throw a fatal error in PHP 9.0.
  
 ===== Vote ===== ===== Vote =====
  
 Should we deprecate autovivification from false? Should we deprecate autovivification from false?
 +
 +Started: 2021-06-09T20:00:00Z\\
 +Ends: 2021-06-23T20:00:00Z
  
 <doodle title="Deprecate autovivification from false?" auth="dharman" voteType="single" closed="true">  <doodle title="Deprecate autovivification from false?" auth="dharman" voteType="single" closed="true"> 
Line 61: Line 66:
 </doodle> </doodle>
  
-\\ +===== Discussion on internals ====== 
-Should we deprecate autovivification from null?+ 
 +https://externals.io/message/114595
  
-<doodle title="Deprecate autovivification from null?" auth="dharman" voteType="single" closed="true">  
-   * Yes 
-   * No 
-</doodle> 
rfc/autovivification_false.1622921577.txt.gz · Last modified: 2021/06/05 19:32 by dharman