Skip to content

Commit

Permalink
Add Connection parameter to Closure
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Jun 22, 2024
1 parent a824e27 commit 03e05ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ public function getARClassName(): string
}

if ($this->arClass instanceof Closure) {
return ($this->arClass)()::class;
return ($this->arClass)($this->db)::class;
}

return $this->arClass;
Expand All @@ -996,7 +996,7 @@ public function getARInstance(): ActiveRecordInterface
}

if ($this->arClass instanceof Closure) {
return ($this->arClass)();
return ($this->arClass)($this->db);
}

/** @psalm-var class-string<ActiveRecordInterface> $class */
Expand Down
3 changes: 2 additions & 1 deletion src/ActiveQueryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Closure;
use ReflectionException;
use Throwable;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Exception\Exception;
use Yiisoft\Db\Exception\InvalidArgumentException;
use Yiisoft\Db\Exception\InvalidConfigException;
Expand All @@ -23,7 +24,7 @@
*
* A class implementing this interface should also use {@see ActiveQueryTrait} and {@see ActiveRelationTrait}.
*
* @psalm-type ARClass = class-string<ActiveRecordInterface>|ActiveRecordInterface|Closure():ActiveRecordInterface
* @psalm-type ARClass = class-string<ActiveRecordInterface>|ActiveRecordInterface|Closure(ConnectionInterface):ActiveRecordInterface
*/
interface ActiveQueryInterface extends QueryInterface
{
Expand Down

0 comments on commit 03e05ba

Please sign in to comment.