Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8f25ea5
Make compatible with PHP's pattern matching RFC
thekid Dec 21, 2025
93cd1a0
Bump compiler and AST versions
thekid Dec 21, 2025
69a25b7
Fix "Trying to access array offset on value of type int"
thekid Dec 21, 2025
89e6dce
QA: Apidocs
thekid Dec 21, 2025
a5c0217
Simplify code in last.ast.syntax.php.IsBinding's toString() method
thekid Dec 21, 2025
ddbcf1d
Refactor: Rename IsComparable -> IsComparison
thekid Dec 21, 2025
c76a39c
Support patterns in match() expressions
thekid Dec 21, 2025
33899a0
Merge compound types with the same operators
thekid Dec 21, 2025
b4c2b72
Verify input for numeric comparison with is_numeric()
thekid Dec 21, 2025
bad13af
Test delayed binding
thekid Dec 21, 2025
2bcf0fc
Add tests with global constants
thekid Dec 21, 2025
bb4079b
Check with array_key_exists() instead of null-coalescing
thekid Dec 21, 2025
453f7c9
Fix expected "Undefined variable" error (differs in PHP 8)
thekid Dec 21, 2025
eff2a7e
Add closure
thekid Dec 21, 2025
ab0fe52
Fix binding to variables containing arrays
thekid Dec 21, 2025
e96c78a
Add examples inspired by Python's PEP 636
thekid Dec 21, 2025
020d918
Test "mixed" placeholder inside array
thekid Dec 21, 2025
8d27595
Use IsIdentical instead of IsComparison
thekid Dec 22, 2025
9f26ec3
QA: Remove commented out debug code
thekid Dec 22, 2025
57d5da2
Do not assign temporary variables to variable expressions
thekid Dec 22, 2025
34c7aa0
Refactor code, extracting temporary variable handling
thekid Dec 22, 2025
d770ec8
Simplify emitted expression for variable binding
thekid Dec 23, 2025
fb152b0
Test nested destructuring (`... is [[$a, $b], $c]`)
thekid Dec 23, 2025
398315e
Add test for nested map destructuring
thekid Dec 23, 2025
372058b
Make ORing a variable binding a syntax error
thekid Dec 24, 2025
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"keywords": ["language", "module", "xp"],
"require" : {
"xp-framework/core": "^12.0 | ^11.0 | ^10.0",
"xp-framework/compiler": "^9.0 | ^8.0",
"xp-framework/compiler": "^9.0",
"xp-framework/ast": "^11.8",
"php" : ">=7.4.0"
},
"require-dev" : {
Expand Down
24 changes: 24 additions & 0 deletions src/main/php/lang/ast/syntax/php/IsArrayStructure.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php namespace lang\ast\syntax\php;

use lang\ast\Type;
use util\Objects;

class IsArrayStructure extends Type {
public $patterns, $rest;

/**
* Creates a array structure "type"
*
* @param lang.ast.Type[] $patterns
* @param bool $rest
*/
public function __construct($patterns= [], $rest= false) {
$this->patterns= $patterns;
$this->rest= $rest;
}

/** @return string */
public function toString() {
return nameof($this).'('.($this->rest ? '>=' : '===').' '.Objects::stringOf($this->patterns).')';
}
}
23 changes: 23 additions & 0 deletions src/main/php/lang/ast/syntax/php/IsBinding.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php namespace lang\ast\syntax\php;

use lang\ast\Type;

class IsBinding extends Type {
public $variable;
public $restriction= null;

/**
* Creates a binding "type"
*
* @param lang.ast.nodes.Variable $variable
*/
public function __construct($variable) {
$this->variable= $variable;
}

/** @return string */
public function toString() {
$restriction= $this->restriction ? ' & '.Objects::stringOf($this->restriction) : '';
return nameof($this).'('.$this->variable->pointer.$restriction.')';
}
}
24 changes: 24 additions & 0 deletions src/main/php/lang/ast/syntax/php/IsComparison.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php namespace lang\ast\syntax\php;

use lang\ast\Type;
use util\Objects;

class IsComparison extends Type {
public $value, $operator;

/**
* Creates a comparison "type"
*
* @param lang.ast.Node $value
* @param string $operator
*/
public function __construct($value, $operator) {
$this->value= $value;
$this->operator= $operator;
}

/** @return string */
public function toString() {
return nameof($this).'('.$this->operator.' '.Objects::stringOf($this->value).')';
}
}
24 changes: 24 additions & 0 deletions src/main/php/lang/ast/syntax/php/IsCompound.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php namespace lang\ast\syntax\php;

use lang\ast\Type;
use util\Objects;

class IsCompound extends Type {
public $patterns, $operator;

/**
* Creates a compound "type"
*
* @param lang.ast.Type[] $patterns
* @param string $operator
*/
public function __construct($patterns, $operator) {
$this->patterns= $patterns;
$this->operator= $operator;
}

/** @return string */
public function toString() {
return nameof($this).'('.$this->operator.' '.Objects::stringOf($this->patterns).')';
}
}
22 changes: 22 additions & 0 deletions src/main/php/lang/ast/syntax/php/IsIdentical.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php namespace lang\ast\syntax\php;

use lang\ast\Type;
use util\Objects;

class IsIdentical extends Type {
public $value;

/**
* Creates a identical "type"
*
* @param lang.ast.Node $value
*/
public function __construct($value) {
$this->value= $value;
}

/** @return string */
public function toString() {
return nameof($this).'('.Objects::stringOf($this->value).')';
}
}
24 changes: 24 additions & 0 deletions src/main/php/lang/ast/syntax/php/IsObjectStructure.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php namespace lang\ast\syntax\php;

use lang\ast\Type;
use util\Objects;

class IsObjectStructure extends Type {
public $type, $patterns;

/**
* Creates a object structure "type"
*
* @param lang.ast.Type $type
* @param lang.ast.Type[] $patterns
*/
public function __construct($type, $patterns= []) {
$this->type= $type;
$this->patterns= $patterns;
}

/** @return string */
public function toString() {
return nameof($this).'('.Objects::stringOf($this->type).' '.Objects::stringOf($this->patterns).')';
}
}
Loading
Loading