Skip to content

Commit

Permalink
Merge pull request #113 from jingu/fix_unbound_message
Browse files Browse the repository at this point in the history
  • Loading branch information
koriym authored Oct 21, 2024
2 parents b4ad323 + 67bcd8e commit 69ad4bf
Show file tree
Hide file tree
Showing 4 changed files with 355 additions and 336 deletions.
2 changes: 1 addition & 1 deletion src/CompileInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private function getInstanceFile(string $dependencyIndex): string

$checkFile = sprintf(self::COMPILE_CHECK, $this->scriptDir);
if (file_exists($checkFile)) {
throw new Unbound(sprintf('See compile log %s', $this->scriptDir . '/_compile.log'));
throw new Unbound(sprintf('[%s] See compile log %s', $dependencyIndex, $this->scriptDir . '/_compile.log'));
}

touch($checkFile);
Expand Down
1 change: 1 addition & 0 deletions src/DependencyCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ private function getProviderCode(DependencyProvider $provider): Code
$isSingleton = $prop($provider, 'isSingleton');
$node[] = $this->getIsSingletonCode($isSingleton);
$node[] = new Stmt\Return_(new MethodCall(new Expr\Variable('instance'), 'get'));
/** @psalm-suppress InvalidArgument */
$node = $this->factory->namespace('Ray\Di\Compiler')->addStmts($node)->getNode();
$qualifer = $this->qualifier;
$this->qualifier = null;
Expand Down
19 changes: 16 additions & 3 deletions tests/DependencyCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public function testInstanceCompileArray(): void
return array(1, 2, 3);
EOT;
$this->assertSame($expected, (string) $code);
$this->assertContains((string) $code, [
str_replace('array(1, 2, 3)', '[1, 2, 3]', $expected),
$expected,
]);
}

public function testDependencyCompile(): void
Expand All @@ -77,7 +80,14 @@ public function testDependencyCompile(): void
return $instance;
EOT;
$expected = str_replace('{ANY}', Name::ANY, $expectedTemplate);
$this->assertSame($expected, (string) $code);
$this->assertContains((string) $code, [
str_replace(
'array(\'Ray\\Compiler\\FakeCar\', \'setHandle\', \'handle\')',
'[\'Ray\\Compiler\\FakeCar\', \'setHandle\', \'handle\']',
str_replace('\\\\', '\\', $expected)
),
$expected,
]);
}

public function testDependencyProviderCompile(): void
Expand Down Expand Up @@ -120,7 +130,10 @@ public function testDependencyObjectInstanceCompile(): void
return unserialize('O:23:"Ray\\Compiler\\FakeEngine":0:{}');
EOT;
$this->assertSame($expected, (string) $code);
$this->assertContains((string) $code, [
str_replace('\\\\', '\\', $expected),
$expected,
]);
}

public function testDomainException(): void
Expand Down
Loading

0 comments on commit 69ad4bf

Please sign in to comment.