Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/bootstrap-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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`

Expand Down
8 changes: 7 additions & 1 deletion docs/unsupported-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |

Expand Down
15 changes: 11 additions & 4 deletions lib/Lint/UnsupportedRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
Expand Down
18 changes: 18 additions & 0 deletions test/unit/LintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ public function testLintCoalesceReportsIssue99(): void
$this->assertStringContainsString('#99', $exit['stdout']);
}

public function testLintShiftAssignReportsIssue136(): void
{
$code = '<?php $x <<= 1;';
$exit = $this->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 = '<?php function f() { yield 1; }';
$exit = $this->runLint(['-r', $code]);
$this->assertSame(1, $exit['code']);
$this->assertStringContainsString('#167', $exit['stdout']);
$this->assertStringNotContainsString('#114', $exit['stdout']);
}

public function testLintCleanScriptExitsZero(): void
{
$code = '<?php echo "ok";';
Expand Down
47 changes: 47 additions & 0 deletions test/unit/UnsupportedRegistryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace PHPCompiler;

use PHPCompiler\Lint\UnsupportedRegistry;
use PHPUnit\Framework\TestCase;

/**
* @see https://github.com/PurHur/php-compiler/issues/258
*/
final class UnsupportedRegistryTest extends TestCase
{
/**
* @return array<string, array{string, int}>
*/
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'));
}
}
Loading