rfc:noreturn_type
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:noreturn_type [2021/03/10 17:59] – Add Ondrej's email mattbrown | rfc:noreturn_type [2021/03/10 19:46] – Add extra vote mattbrown | ||
---|---|---|---|
Line 22: | Line 22: | ||
<code php> | <code php> | ||
- | function redirect(string $uri) : noreturn { | + | function redirect(string $uri): noreturn { |
header(' | header(' | ||
exit(); | exit(); | ||
} | } | ||
- | function redirectToLoginPage() : noreturn { | + | function redirectToLoginPage(): |
redirect('/ | redirect('/ | ||
} | } | ||
Line 47: | Line 47: | ||
<code php> | <code php> | ||
- | function redirect(string $uri) : noreturn { | + | function redirect(string $uri): noreturn { |
if ($uri === '' | if ($uri === '' | ||
return; // Fatal error: A noreturn function must not return | return; // Fatal error: A noreturn function must not return | ||
Line 59: | Line 59: | ||
<code php> | <code php> | ||
- | function redirect(string $uri) : noreturn { | + | function redirect(string $uri): noreturn { |
if ($uri !== '' | if ($uri !== '' | ||
header(' | header(' | ||
Line 72: | Line 72: | ||
<code php> | <code php> | ||
- | function generateList(string $uri) : noreturn { | + | function generateList(string $uri): noreturn { |
yield 1; | yield 1; | ||
exit(); | exit(); | ||
Line 100: | Line 100: | ||
abstract class Person | abstract class Person | ||
{ | { | ||
- | abstract public function hasAgreedToTerms() : bool; | + | abstract public function hasAgreedToTerms(): |
} | } | ||
class Kid extends Person | class Kid extends Person | ||
{ | { | ||
- | public function hasAgreedToTerms() : noreturn | + | public function hasAgreedToTerms(): |
{ | { | ||
throw new \Exception(' | throw new \Exception(' | ||
Line 117: | Line 117: | ||
abstract class Redirector | abstract class Redirector | ||
{ | { | ||
- | abstract public function execute() : noreturn; | + | abstract public function execute(): noreturn; |
} | } | ||
class BadRedirector extends Redirector | class BadRedirector extends Redirector | ||
{ | { | ||
- | public function execute() : void {} // Fatal error | + | public function execute(): void {} // Fatal error |
} | } | ||
</ | </ | ||
Line 157: | Line 157: | ||
<code php> | <code php> | ||
- | function sayHello(string $name) : void { | + | function sayHello(string $name): void { |
echo "Hello $name"; | echo "Hello $name"; | ||
} | } | ||
Line 168: | Line 168: | ||
<code php> | <code php> | ||
- | function redirect(string $uri) : noreturn { | + | function redirect(string $uri): noreturn { |
header(' | header(' | ||
exit(); | exit(); | ||
Line 185: | Line 185: | ||
<code php> | <code php> | ||
# | # | ||
- | function redirectToLoginPage() : void {...} | + | function redirectToLoginPage(): |
</ | </ | ||
Line 191: | Line 191: | ||
<code php> | <code php> | ||
- | function redirectToLoginPage() : noreturn {...} | + | function redirectToLoginPage(): |
</ | </ | ||
Line 224: | Line 224: | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Yes/no vote for adding '' | + | Yes/no vote for adding '' |
+ | |||
+ | Vote for '' |
rfc/noreturn_type.txt · Last modified: 2021/04/19 09:31 by nikic