diff --git a/docs/bootstrap-inventory.md b/docs/bootstrap-inventory.md index 9bb1f9a3..7179d993 100644 --- a/docs/bootstrap-inventory.md +++ b/docs/bootstrap-inventory.md @@ -1279,8 +1279,8 @@ These `LogicException` messages indicate CFG ops or expressions not yet lowered: ### `lib/JIT/SuperglobalInit.php` **Warnings** (review for bootstrap subset): -- new Variable (line 113) -- new VMVariable (line 137) +- new Variable (line 121) +- new VMVariable (line 145) - 7 class method(s) — PHPCfg Op\Stmt\ClassMethod not lowered in Compiler ### `lib/JIT/ValueEchoHelper.php` @@ -1488,11 +1488,11 @@ These `LogicException` messages indicate CFG ops or expressions not yet lowered: ### `lib/Web/Superglobals.php` **Warnings** (review for bootstrap subset): -- new HashTable (line 257) -- new Variable (line 258) -- new Variable (line 277) -- new Variable (line 327) -- 15 class method(s) — PHPCfg Op\Stmt\ClassMethod not lowered in Compiler +- new HashTable (line 366) +- new Variable (line 367) +- new Variable (line 386) +- new Variable (line 436) +- 20 class method(s) — PHPCfg Op\Stmt\ClassMethod not lowered in Compiler ### `src/macro_functions.php` diff --git a/docs/unsupported-syntax.md b/docs/unsupported-syntax.md index 9f0ae2e7..7349f48a 100644 --- a/docs/unsupported-syntax.md +++ b/docs/unsupported-syntax.md @@ -20,7 +20,13 @@ Exit code `0` when the entry (and best-effort `include`/`require` targets with s | `Stmt_Foreach` | [#53](https://github.com/PurHur/php-compiler/issues/53) | | `Expr_BinaryOp_Coalesce` (`??`) | [#99](https://github.com/PurHur/php-compiler/issues/99) | | `Expr_Throw`, `Stmt_Try`, `Stmt_Catch`, `Stmt_Finally` | [#195](https://github.com/PurHur/php-compiler/issues/195) | -| `Expr_Yield`, `Expr_YieldFrom`, closures | [#114](https://github.com/PurHur/php-compiler/issues/114) | +| `Expr_Ternary` (`?:`) | [#114](https://github.com/PurHur/php-compiler/issues/114) | +| `Expr_AssignOp_*`, `Expr_BinaryOp_ShiftLeft` / `ShiftRight` (compound assign) | [#136](https://github.com/PurHur/php-compiler/issues/136) | +| `Stmt_Break`, `Stmt_Continue` | [#115](https://github.com/PurHur/php-compiler/issues/115) | +| `Expr_Match` | [#143](https://github.com/PurHur/php-compiler/issues/143) | +| `Expr_Yield`, `Expr_YieldFrom` | [#167](https://github.com/PurHur/php-compiler/issues/167) | +| `Expr_Closure` | [#72](https://github.com/PurHur/php-compiler/issues/72) | +| `Expr_ArrowFunction` | [#142](https://github.com/PurHur/php-compiler/issues/142) | | `Expr_New` (non-trivial) | [#136](https://github.com/PurHur/php-compiler/issues/136) | | Named arguments, traits, enums | [#168](https://github.com/PurHur/php-compiler/issues/168), [#169](https://github.com/PurHur/php-compiler/issues/169) | diff --git a/lib/Lint/UnsupportedRegistry.php b/lib/Lint/UnsupportedRegistry.php index d0745197..39f51499 100644 --- a/lib/Lint/UnsupportedRegistry.php +++ b/lib/Lint/UnsupportedRegistry.php @@ -30,11 +30,18 @@ final class UnsupportedRegistry 'Stmt_Try' => 195, 'Stmt_Catch' => 195, 'Stmt_Finally' => 195, - 'Expr_Yield' => 114, - 'Expr_YieldFrom' => 114, + 'Expr_Ternary' => 114, + 'Expr_AssignOp_' => 136, + 'Expr_BinaryOp_ShiftLeft' => 136, + 'Expr_BinaryOp_ShiftRight' => 136, + 'Stmt_Break' => 115, + 'Stmt_Continue' => 115, + 'Expr_Match' => 143, + 'Expr_Yield' => 167, + 'Expr_YieldFrom' => 167, 'Stmt_Enum' => 169, - 'Expr_ArrowFunction' => 114, - 'Expr_Closure' => 114, + 'Expr_ArrowFunction' => 142, + 'Expr_Closure' => 72, 'Stmt_Trait' => 168, 'Expr_NamedArgument' => 168, ]; diff --git a/test/unit/LintTest.php b/test/unit/LintTest.php index c7298b8d..8774395a 100644 --- a/test/unit/LintTest.php +++ b/test/unit/LintTest.php @@ -34,6 +34,24 @@ public function testLintCoalesceReportsIssue99(): void $this->assertStringContainsString('#99', $exit['stdout']); } + public function testLintShiftAssignReportsIssue136(): void + { + $code = 'runLint(['-r', $code]); + $this->assertSame(1, $exit['code']); + $this->assertStringContainsString('#136', $exit['stdout']); + $this->assertStringContainsString('Expr_BinaryOp_ShiftLeft', $exit['stdout']); + } + + public function testLintYieldReportsIssue167(): void + { + $code = 'runLint(['-r', $code]); + $this->assertSame(1, $exit['code']); + $this->assertStringContainsString('#167', $exit['stdout']); + $this->assertStringNotContainsString('#114', $exit['stdout']); + } + public function testLintCleanScriptExitsZero(): void { $code = ' + */ + public static function kindToIssueProvider(): array + { + return [ + 'ternary' => ['Expr_Ternary', 114], + 'compound assign prefix' => ['Expr_AssignOp_Concat', 136], + 'shift left' => ['Expr_BinaryOp_ShiftLeft', 136], + 'shift right' => ['Expr_BinaryOp_ShiftRight', 136], + 'break' => ['Stmt_Break', 115], + 'continue' => ['Stmt_Continue', 115], + 'match' => ['Expr_Match', 143], + 'yield' => ['Expr_Yield', 167], + 'yield from' => ['Expr_YieldFrom', 167], + 'closure' => ['Expr_Closure', 72], + 'arrow function' => ['Expr_ArrowFunction', 142], + ]; + } + + /** + * @dataProvider kindToIssueProvider + */ + public function testTrackingIssueForKind(string $kind, int $issue): void + { + $this->assertSame($issue, UnsupportedRegistry::trackingIssueForKind($kind)); + } + + public function testUnknownKindReturnsNull(): void + { + $this->assertNull(UnsupportedRegistry::trackingIssueForKind('Expr_FooBar')); + } +}