Merge pull request '支持数组、属性数组链式赋值和追加同时链式赋值' (#8) from fix-multi-var-assign into master
Reviewed-on: #8pull/11/head
commit
1e774af718
4 changed files with 107 additions and 5 deletions
@ -0,0 +1,45 @@ |
|||||||
|
--TEST-- |
||||||
|
Chained assignment with array append ([]), property write, and variable write as rvalue inside constructor argument |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
class Test2 |
||||||
|
{ |
||||||
|
public function __construct($value2) |
||||||
|
{ |
||||||
|
var_dump($value2); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class Test |
||||||
|
{ |
||||||
|
public $arr = []; |
||||||
|
|
||||||
|
public $value; |
||||||
|
|
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
$arr = [0]; |
||||||
|
new Test2($this->arr[] = $arr[] = $this->value = $value = 1); |
||||||
|
var_dump($this->value, $value, $this->arr, $arr); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main() |
||||||
|
{ |
||||||
|
new Test; |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
int(1) |
||||||
|
int(1) |
||||||
|
int(1) |
||||||
|
array(1) { |
||||||
|
[0]=> |
||||||
|
int(1) |
||||||
|
} |
||||||
|
array(2) { |
||||||
|
[0]=> |
||||||
|
int(0) |
||||||
|
[1]=> |
||||||
|
int(1) |
||||||
|
} |
||||||
@ -0,0 +1,50 @@ |
|||||||
|
--TEST-- |
||||||
|
Multi-variable assignment: property assignment as rvalue in constructor argument expression |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
class Test2 |
||||||
|
{ |
||||||
|
public function __construct($value2) |
||||||
|
{ |
||||||
|
var_dump($value2); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class Test |
||||||
|
{ |
||||||
|
public $value; |
||||||
|
|
||||||
|
public $value2; |
||||||
|
|
||||||
|
public $value3; |
||||||
|
|
||||||
|
public $arr = [1]; |
||||||
|
|
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
$this->value = new Test2($this->arr[0] = $this->value2 = 123); |
||||||
|
var_dump($this->value2, $this->arr); |
||||||
|
$this->value = new Test2($this->arr[0] = $this->value3 = $this->value2 = 456); |
||||||
|
var_dump($this->value2, $this->value3, $this->arr); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main() |
||||||
|
{ |
||||||
|
new Test; |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
int(123) |
||||||
|
int(123) |
||||||
|
array(1) { |
||||||
|
[0]=> |
||||||
|
int(123) |
||||||
|
} |
||||||
|
int(456) |
||||||
|
int(456) |
||||||
|
int(456) |
||||||
|
array(1) { |
||||||
|
[0]=> |
||||||
|
int(456) |
||||||
|
} |
||||||
Loading…
Reference in new issue