Skip to content

Commit

Permalink
Support wrapping a RecordingReflector in LazyQueryReflector (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Jun 27, 2023
1 parent 9058bc9 commit 1bd0de3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/QueryReflection/LazyQueryReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use PHPStan\Type\Type;
use staabm\PHPStanDba\Error;

final class LazyQueryReflector implements QueryReflector
final class LazyQueryReflector implements QueryReflector, RecordingReflector
{
/**
* @var callable():QueryReflector
Expand Down Expand Up @@ -51,6 +51,17 @@ public function setupDbaApi(?DbaApi $dbaApi): void
$this->dbaApi = $dbaApi;
}

public function getDatasource()
{
$this->reflector = $this->createReflector();

if ($this->reflector instanceof RecordingReflector) {
return $this->reflector->getDatasource();
}

return null;
}

private function createReflector(): QueryReflector
{
if (null === $this->reflector) {
Expand Down

0 comments on commit 1bd0de3

Please sign in to comment.