mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-12-12 09:29:47 +01:00
89 lines
1.1 KiB
Plaintext
89 lines
1.1 KiB
Plaintext
Matches
|
|
-----
|
|
<?php
|
|
$value = match (1) {
|
|
1
|
|
=>
|
|
'one'
|
|
};
|
|
-----
|
|
$stmts[0]->expr->expr->arms[] = new Node\MatchArm(null, new Scalar\String_('two'));
|
|
-----
|
|
<?php
|
|
$value = match (1) {
|
|
1
|
|
=>
|
|
'one',
|
|
default => 'two',
|
|
};
|
|
-----
|
|
<?php
|
|
$value = match (1) {
|
|
1, 2 =>
|
|
'test',
|
|
};
|
|
-----
|
|
$stmts[0]->expr->expr->arms[0]->conds[] = new Scalar\LNumber(3);
|
|
-----
|
|
<?php
|
|
$value = match (1) {
|
|
1, 2, 3 =>
|
|
'test',
|
|
};
|
|
-----
|
|
<?php
|
|
$value = match (1) {
|
|
1
|
|
=>
|
|
'one',
|
|
2
|
|
=>
|
|
'two',
|
|
3
|
|
=>
|
|
'three',
|
|
};
|
|
-----
|
|
array_splice($stmts[0]->expr->expr->arms, 1, 1, []);
|
|
-----
|
|
<?php
|
|
$value = match (1) {
|
|
1
|
|
=>
|
|
'one',
|
|
3
|
|
=>
|
|
'three',
|
|
};
|
|
-----
|
|
<?php
|
|
// TODO: Preserve formatting?
|
|
$value = match (1) {
|
|
default
|
|
=>
|
|
'test',
|
|
};
|
|
-----
|
|
$stmts[0]->expr->expr->arms[0]->conds = [new Scalar\LNumber(1)];
|
|
-----
|
|
<?php
|
|
// TODO: Preserve formatting?
|
|
$value = match (1) {
|
|
1 => 'test',
|
|
};
|
|
-----
|
|
<?php
|
|
// TODO: Preserve formatting?
|
|
$value = match (1) {
|
|
1
|
|
=>
|
|
'test',
|
|
};
|
|
-----
|
|
$stmts[0]->expr->expr->arms[0]->conds = null;
|
|
-----
|
|
<?php
|
|
// TODO: Preserve formatting?
|
|
$value = match (1) {
|
|
default => 'test',
|
|
}; |