diff --git a/src/Repository.php b/src/Repository.php index d5c3a72..937f424 100644 --- a/src/Repository.php +++ b/src/Repository.php @@ -425,7 +425,7 @@ class Repository implements RepositoryInterface } # @TODO Apply FILTER annotation to this too ! - foreach(array_filter((array) $fields, fn($e) => ! isset($this->joined[$e])) as $item) { + foreach(array_filter((array) $fields, fn($e) => $e && ! isset($this->joined[$e]) ) as $item) { $this->joined[$item] = true; $attribute = $this->entityResolver->searchFieldAnnotation($item, [ Join::class ]) ?: @@ -480,7 +480,6 @@ class Repository implements RepositoryInterface $this->close(); $key = is_string($attribute->key) ? $this->entityClass::field($attribute->key) : $attribute->key; - $foreignKey = $this->evalClosure($attribute->foreignKey, $entity, $alias); $this->join($isRelation ? "LEFT" : $attribute->type, $entity::resolveEntity()->tableName(), $key, $foreignKey, $alias, function($join) use ($item, $entity, $alias, $options) { @@ -647,7 +646,7 @@ class Repository implements RepositoryInterface } ## AWAITING THE Closures in constant expression from PHP 8.5 ! - protected function evalClosure(string $content, string $entityClass, mixed $alias = self::DEFAULT_ALIAS) : mixed + protected function evalClosure(\Stringable|string $content, string $entityClass, mixed $alias = self::DEFAULT_ALIAS) : mixed { if (is_string($content)) { if ( str_starts_with($content, 'fn(') ) {