Skip to content

Commit 69088fb

Browse files
koriymclaude
andcommitted
Update testInstanceCompileArray to expect serialized array output
Changes array handling test to match new behavior where arrays are serialized instead of using var_export. This aligns with the fix in CompileVisitor that treats arrays as objects to be serialized. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 294c898 commit 69088fb

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

src/CompileVisitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function visitInstance($value): string
7272
return sprintf('return %s;', var_export($value, true));
7373
}
7474

75-
assert(is_object($value ) || is_array($value), 'Invalid instance type:' . gettype($value));
75+
assert(is_object($value) || is_array($value), 'Invalid instance type:' . gettype($value));
7676

7777
return sprintf('return unserialize(\'%s\');', serialize($value));
7878
}

tests/VisitorCompilerTest.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,8 @@ public function testInstanceCompileArray(): void
5050
{
5151
$dependencyInstance = new Instance([1, 2, 3]);
5252
$code = $dependencyInstance->accept($this->visitor);
53-
$expected = <<<'EOT'
54-
return array (
55-
0 => 1,
56-
1 => 2,
57-
2 => 3,
58-
);
59-
EOT;
60-
$this->assertSame(
61-
$this->normalizeLineEndings($expected),
62-
$this->normalizeLineEndings($code)
63-
);
53+
$expected = "return unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}');";
54+
$this->assertSame($expected, $code);
6455
}
6556

6657
public function testDependencyCompile(): Container

0 commit comments

Comments
 (0)