- Fixed evalClosure() missing type which converted EntityField into string

This commit is contained in:
Dave Mc Nicoll 2025-05-16 12:59:31 +00:00
parent 8fff21ecb0
commit c54de30069

View File

@ -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(') ) {