Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/container/src/GenericContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ private function clone(): self
private function resolveChain(): DependencyChain
{
if (! $this->chain instanceof DependencyChain) {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, limit: 2);

$this->chain = new DependencyChain($trace[1]['file'] . ':' . $trace[1]['line']);
}
Expand Down
10 changes: 10 additions & 0 deletions packages/container/tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,16 @@ public function call_function_with_unresolvable_parameters(): void
$container->invoke(fn (string $param) => $param);
}

#[Test]
public function dependency_chain_reports_the_call_site_as_its_origin(): void
{
$this->expectException(DependencyCouldNotBeAutowired::class);
$this->expectExceptionMessageMatches('/Originally called in .*ContainerTest\.php:\d+/');

$container = new GenericContainer();
$container->get(ContainerObjectC::class);
}

#[Test]
public function call_invalid_closure(): void
{
Expand Down
Loading