rfc:remove_php4_constructors

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
rfc:remove_php4_constructors [2015/02/06 16:55]
levim Update implementation
rfc:remove_php4_constructors [2015/02/23 04:31]
levim Status: Voting
Line 4: Line 4:
   * Author: Levi Morrison <levim@php.net>   * Author: Levi Morrison <levim@php.net>
   * Contributors: Andrea Faulds <ajf@ajf.me>   * Contributors: Andrea Faulds <ajf@ajf.me>
-  * Status: Under Discussion+  * Status: Voting
   * First Published at: http://wiki.php.net/rfc/remove_php4_constructors   * First Published at: http://wiki.php.net/rfc/remove_php4_constructors
  
Line 50: Line 50:
  
 ===== Proposal ===== ===== Proposal =====
-This RFC proposes that for PHP 7 we emit ''E_DEPRECATED'' whenever a PHP 4 constructor is recognizedThese are recognized when the method name matches the class name, the class is not in a namespace, and a PHP 5 constructor (''<nowiki>__construct</nowiki>'') is not present. This RFC proposes that in PHP 8 these will become normal methods and the ''E_DEPRECATED'' will be removed.+PHP 7 will emit ''E_DEPRECATED'' whenever a PHP 4 constructor is definedWhen the method name matches the class name, the class is not in a namespace, and a PHP 5 constructor (''<nowiki>__construct</nowiki>'') is not present then an ''E_DEPRECATED'' will be emitted. PHP 8 will stop emitting ''E_DEPRECATED'' and the methods will not be recognized as constructors.
  
-This RFC also proposes to stop emitting ''E_STRICT'' when a method with the same name as the class is present as well as ''<nowiki>__construct</nowiki>''.+PHP 7 will also stop emitting ''E_STRICT'' when a method with the same name as the class is present as well as ''<nowiki>__construct</nowiki>''.
  
-Some code samples in the [[#examples|Examples]] section show how code is impacted.+Refer to the [[#examples|Examples]] section to see how code is impacted.
  
 ==== Backward Incompatible Changes ==== ==== Backward Incompatible Changes ====
 Since an ''E_DEPRECATED'' will be emitted in PHP 7 there may be some backwards compatibility breaks when people use custom error handlers. Since an ''E_DEPRECATED'' will be emitted in PHP 7 there may be some backwards compatibility breaks when people use custom error handlers.
  
-In PHP 8 recognition for old constructors will be outright removed, meaning that anything without a ''<nowiki>__construct</nowiki>'' will not work. The fix is to rename the constructor to ''<nowiki>__construct</nowiki>''.+In PHP 8 recognition for old constructors will be outright removed, meaning that anything without a ''<nowiki>__construct</nowiki>'' will not work the same way it used to. The old-style constructor will be considered a normal method and will not be called when the object is constructed. The fix is to rename the constructor to ''<nowiki>__construct</nowiki>''.
  
 ==== Examples ==== ==== Examples ====
Line 104: Line 104:
  
 <PHP> <PHP>
-class Filter { +class Filter { 
 +    // PHP 5: filter is a constructor 
 +    // PHP 7: filter is a constructor and E_DEPRECATED is raised 
 +    // PHP 8: filter is a normal method and is not a constructor; no E_DEPRECATED is raised
     function filter() {}     function filter() {}
 } }
Line 123: Line 126:
  
 ===== Voting ===== ===== Voting =====
-This RFC targets PHP 7 and PHP 8. Please read the RFC to understand what is being proposed. Also note that anything proposed for PHP 8 would be subject to any future RFC as per our normal processes.+This RFC targets PHP 7 and PHP 8. Please read the RFC to understand what is being proposed.
  
 This RFC requires 2/3 vote in favor of deprecating and removing PHP 4 style constructors to pass. This RFC requires 2/3 vote in favor of deprecating and removing PHP 4 style constructors to pass.
 +
 +Do you vote to remove PHP 4 constructors as outlined in this RFC?
 +
 +<doodle title="remove_php4_constructors" auth="levim" voteType="single" closed="false">
 +   * Yes
 +   * No
 +</doodle>
 +
 +Voting will close on the evening (UTC-7) of March 6th.
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
 An implementation based on the master branch can be found here: https://github.com/php/php-src/pull/1061 An implementation based on the master branch can be found here: https://github.com/php/php-src/pull/1061
  
rfc/remove_php4_constructors.txt · Last modified: 2017/09/22 13:28 (external edit)