Menu

#4105 PHP static class function errors on type hinting

minor bug
open
nobody
5
2020-12-22
2020-12-22
No
?php
class Foo {
     public static function zzz(string $x): string {
         return $x
}

errors as follows:

/home/jax/sample/foo.php
3:unexpected tokens
3:'}' expected
3:expected function body

with "Sx" highlighted.

Without the argument hint, it errors on ':'

<?php
class Foo {
     public static function zzz( $x): string {
         return $x
}

which throws:

/home/jax/work/herwheel3/src/lib/model/foo.php
3:'}' expected
3:expected function body

with the colon ":" highlighted.

Discussion


Log in to post a comment.