- Simplified concat assignment logic by checking for Concat instance directly instead of flattening - Changed SelectionExpressionTrait to use parseExprAsValue for ternary branches - Added proper handling of void branch conversion to null in ternary expressions - Added tests for concat assignment to inherited properties - Added tests for ternary expressions with void branches and side effectspull/40/head
parent
9d29aa7a3f
commit
2d4a1b8bb0
4 changed files with 80 additions and 6 deletions
@ -0,0 +1,29 @@ |
|||||||
|
--TEST-- |
||||||
|
concat assignment to an inherited property preserves value and reference arguments |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class QueryConnection |
||||||
|
{ |
||||||
|
protected $query = ''; |
||||||
|
} |
||||||
|
|
||||||
|
class MongoConnection extends QueryConnection |
||||||
|
{ |
||||||
|
public function build(): string |
||||||
|
{ |
||||||
|
$this->query .= '.sort(' . json_encode(['id' => 1]) . ')'; |
||||||
|
$this->query .= '.skip(' . 2 . ')'; |
||||||
|
$this->query .= ';'; |
||||||
|
return $this->query; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
$connection = new MongoConnection(); |
||||||
|
var_dump($connection->build()); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
string(24) ".sort({"id":1}).skip(2);" |
||||||
@ -0,0 +1,48 @@ |
|||||||
|
--TEST-- |
||||||
|
ternary expressions convert void branches to null after their side effects |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class OptimisticLock |
||||||
|
{ |
||||||
|
private int $calls = 0; |
||||||
|
|
||||||
|
public function check(bool $exists) |
||||||
|
{ |
||||||
|
return $exists |
||||||
|
? $this->updateLockVersion() |
||||||
|
: $this->recordLockVersion(); |
||||||
|
} |
||||||
|
|
||||||
|
public function calls(): int |
||||||
|
{ |
||||||
|
return $this->calls; |
||||||
|
} |
||||||
|
|
||||||
|
private function updateLockVersion(): void |
||||||
|
{ |
||||||
|
echo "update\n"; |
||||||
|
$this->calls++; |
||||||
|
} |
||||||
|
|
||||||
|
private function recordLockVersion(): void |
||||||
|
{ |
||||||
|
echo "record\n"; |
||||||
|
$this->calls++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void |
||||||
|
{ |
||||||
|
$lock = new OptimisticLock(); |
||||||
|
var_dump($lock->check(true)); |
||||||
|
var_dump($lock->check(false)); |
||||||
|
var_dump($lock->calls()); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
update |
||||||
|
NULL |
||||||
|
record |
||||||
|
NULL |
||||||
|
int(2) |
||||||
Loading…
Reference in new issue