From 79c0272cec297761727c4b6d5dda6c30c355b0c5 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Sun, 18 Oct 2026 13:31:33 +0200 Subject: [PATCH] workaround for internal stan error --- src/Repository/Repository.php | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/Repository/Repository.php b/src/Repository/Repository.php index 5edaca5..d6fa84d 100644 --- a/src/Repository/Repository.php +++ b/src/Repository/Repository.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Kartierung\Repository; use Kartierung\Analyze\RepositoryAnalyzer; +use Kartierung\Analyze\Result\RepositoryMethod; use Kartierung\Analyze\Result\RepositoryResult; use Kartierung\Repository\ResolutionStrategy\ResolutionStrategyFactory; use PDO; @@ -26,10 +27,10 @@ readonly class Repository $repoResult = (new RepositoryAnalyzer($resolutionStrategyFactory))->analyze($clazz); /** - * @var R of object + * @var R $proxy * @phpstan-ignore varTag.nativeType */ - return new class($repoResult, $this->pdo) { + $proxy = new class($repoResult, $this->pdo) { public function __construct( private readonly RepositoryResult $repoResult, private readonly PDO $pdo @@ -43,17 +44,30 @@ readonly class Repository public function __call(string $methodName, array $arguments): mixed { $repoMethod = $this->repoResult->methods[$methodName]; + $queryArgs = $this->callArgsToQueryArgs($repoMethod, $arguments); - $argCount = 0; - $callParams = []; - foreach ($repoMethod->parameters as $parameter) { - $callParams[$parameter->name] = $arguments[$argCount++]; - } - - $query = $repoMethod->createQuery($callParams); + $query = $repoMethod->createQuery($queryArgs); return $query->execute($this->pdo); } + + /** + * @param RepositoryMethod $method + * @param list $arguments + * @return array + */ + private function callArgsToQueryArgs(RepositoryMethod $method, array $arguments): array + { + $queryArgs = []; + + foreach ($method->parameters as $i => $parameter) { + $queryArgs[$parameter->name] = $arguments[$i]; + } + + return $queryArgs; + } }; + + return $proxy; } }