Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly reject non-expression short function bodies.
- Loading branch information
Showing
3 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--TEST-- | ||
Non-expression statements parse error in short functions. | ||
--FILE-- | ||
<?php | ||
|
||
function test(array $a) => foreach ($a as $v) print $v; | ||
|
||
test([1, 2, 3]); | ||
|
||
?> | ||
--EXPECTF-- | ||
Parse error: syntax error, unexpected token "foreach" in %s on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--TEST-- | ||
Short methods. | ||
--FILE-- | ||
<?php | ||
|
||
class Test { | ||
|
||
public function __construct(private int $b) {} | ||
|
||
public function out(array $a) => foreach ($a as $v) print $v; | ||
} | ||
|
||
$t = new Test(1); | ||
|
||
print $t->out([1, 2, 3]) . PHP_EOL; | ||
|
||
?> | ||
--EXPECTF-- | ||
Parse error: syntax error, unexpected token "foreach" in %s on line %d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters