rfc:noreturn_type

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
Next revisionBoth sides next revision
rfc:noreturn_type [2021/03/10 18:09] – No space before type mattbrownrfc:noreturn_type [2021/03/30 14:55] – Add __toString example mattbrown
Line 123: Line 123:
 { {
     public function execute(): void {} // Fatal error     public function execute(): void {} // Fatal error
 +}
 +</code>
 +
 +Returning by reference with a ''noreturn'' type is allowed as well.
 +
 +<code php>
 +class A {
 +    public function &test(): int { ... }
 +}
 +class B extends A {
 +    public function &test(): noreturn { throw new Exception; }
 +}
 +</code>
 +
 +Returning ''noreturn'' is also allowed in ''__toString'' methods:
 +
 +<code php>
 +class A implements Stringable {
 +    public function __toString(): string {
 +        return "hello";
 +    }
 +}
 +
 +class B extends A {
 +    public function __toString(): noreturn {
 +        throw new \Exception('not supported');
 +    }
 } }
 </code> </code>
Line 224: Line 251:
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
  
-Yes/no vote for adding ''noreturn''+Yes/no vote for adding ''noreturn'' (2/3 majority) 
 + 
 +Vote for ''noreturn'' vs ''never'' (simple majority)
rfc/noreturn_type.txt · Last modified: 2021/04/19 09:31 by nikic