xp-framework / compiler

Compiles future PHP to today's PHP.
19 stars 0 forks source link

Rewrite `never` return type to `void` in PHP < 8.1 #110

Closed thekid closed 3 years ago

thekid commented 3 years ago

See https://wiki.php.net/rfc/noreturn_type. Implements emitting support for xp-framework/compiler#109

# For PHP 8 (and lower), `never` is emitted as `void`
$ echo 'function bail(): never { exit(); }' | xp compile -t PHP.8.0 -q -
<?php function bail():void{exit();};

# For PHP 8.1, `never` is emitted as-is
$ echo 'function bail(): never { exit(); }' | xp compile -t PHP.8.1 -q -
<?php function bail():never{exit();};
thekid commented 3 years ago

Updated https://github.com/xp-framework/compiler/wiki/Implementation-status