From 50cf8c66551c63d87a5539d0d194387c44026d57 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 21 Jul 2026 20:07:21 +0800 Subject: [PATCH] refactor(phpunit): update SsaAnalysisTest to use PropertyDef objects - Added PropertyDef import statement - Modified canHoistStableObjectProp calls to pass PropertyDef instances - Created PropertyDef objects for properties 'a' and 'b' in test methods - Updated testCanHoistStableObjectProp method signature to accept PropertyDef parameter - Updated testCanHoistStableObjectPropRejectsWildcard method to pass PropertyDef parameter --- phpunit/src/SsaAnalysisTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/phpunit/src/SsaAnalysisTest.php b/phpunit/src/SsaAnalysisTest.php index e0739242..55619ac8 100644 --- a/phpunit/src/SsaAnalysisTest.php +++ b/phpunit/src/SsaAnalysisTest.php @@ -14,6 +14,7 @@ use TypePhp\Analysis\PiConstraint; use TypePhp\CompilerTest; use TypePhp\Entity\ClassDef; use TypePhp\Entity\MethodDef; +use TypePhp\Entity\PropertyDef; use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\FunctionLike; @@ -1050,8 +1051,10 @@ class SsaAnalysisTest extends TestCase $this->setContextProperty('stableObjects', ['obj' => 'App\\MyClass']); $this->setContextProperty('unsafeObjectProps', ['obj' => ['b' => true]]); - $this->assertTrue($this->compiler->canHoistStableObjectProp('obj', 'a')); - $this->assertFalse($this->compiler->canHoistStableObjectProp('obj', 'b')); + $propertyA = new PropertyDef('a', 0, Type::INT); + $propertyB = new PropertyDef('b', 0, Type::INT); + $this->assertTrue($this->compiler->canHoistStableObjectProp('obj', 'a', $propertyA)); + $this->assertFalse($this->compiler->canHoistStableObjectProp('obj', 'b', $propertyB)); } public function testCanHoistStableObjectPropRejectsWildcard(): void @@ -1060,7 +1063,8 @@ class SsaAnalysisTest extends TestCase $this->setContextProperty('stableObjects', ['obj' => 'App\\MyClass']); $this->setContextProperty('unsafeObjectProps', ['obj' => ['*' => true]]); - $this->assertFalse($this->compiler->canHoistStableObjectProp('obj', 'a')); + $property = new PropertyDef('a', 0, Type::INT); + $this->assertFalse($this->compiler->canHoistStableObjectProp('obj', 'a', $property)); } // ========================================================================