rfc:internal_method_return_types

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:internal_method_return_types [2021/04/18 13:40] kocsismaterfc:internal_method_return_types [2021/05/14 13:57] (current) kocsismate
Line 2: Line 2:
   * Date: 2021-03-06   * Date: 2021-03-06
   * Author: Máté Kocsis <kocsismate@php.net>   * Author: Máté Kocsis <kocsismate@php.net>
-  * Status: Under Discussion+  * Status: Implemented
   * Implementation: https://github.com/php/php-src/pull/6548   * Implementation: https://github.com/php/php-src/pull/6548
 +  * Target Version: PHP 8.1 
  
 ===== Introduction ===== ===== Introduction =====
Line 67: Line 68:
 </code> </code>
  
-Unfortunately, union return types impose a compatibility challenge for libraries: as this construct is only supported since PHP 8.0, libraries would have to accept the fact by default that their code triggers ''E_DEPRECATED'' notices on PHP 8.1 if they also want to support PHP versions below 8.0. As a remedy, this RFC proposes to add a ''SuppressReturnTypeNotice'' attribute which could be used to suppress the related ''E_DEPRECATED'' notices. Thanks to the backward compatible syntax of attributes, this can be done in code which is compatible with PHP 7 and below.+Unfortunately, union return types impose a compatibility challenge for libraries: as this construct is only supported since PHP 8.0, libraries would have to accept the fact by default that their code triggers ''E_DEPRECATED'' notices on PHP 8.1 if they also want to support PHP versions below 8.0. As a remedy, this RFC proposes to add a ''ReturnTypeWillChange'' attribute which could be used to suppress the related ''E_DEPRECATED'' notices. Thanks to the backward compatible syntax of attributes, this can be done in code which is compatible with PHP 7 and below.
  
 <code php> <code php>
Line 75: Line 76:
      * @return DateTime|false      * @return DateTime|false
      */      */
-    #[SuppressReturnTypeNotice]+    #[ReturnTypeWillChange]
     public function modify(string $modifier) { return false; }     public function modify(string $modifier) { return false; }
 } }
Line 102: Line 103:
 ===== Vote ===== ===== Vote =====
  
-Add return type declarations for internal methods in the proposed schedule? The vote requires 2/3 majority to be accepted.+Voting started 2021-04-22 and ends 2021-05-06 UTC. The vote requires 2/3 majority to be accepted. 
 + 
 +<doodle title="Add return type declarations for internal methods in the proposed schedule?" auth="kocsismate" voteType="single" closed="true"> 
 +   * Yes 
 +   * No 
 +</doodle> 
 + 
rfc/internal_method_return_types.1618753242.txt.gz · Last modified: 2021/04/18 13:40 by kocsismate