Skip to content

Sync master branch to 2.2. #20365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 15 additions & 26 deletions framework/db/ActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@
* @since 2.0
*
* @template T of (ActiveRecord|array)
*
* @phpstan-method T|null one($db = null)
* @psalm-method T|null one($db = null)
*
* @phpstan-method T[] all($db = null)
* @psalm-method T[] all($db = null)
*
* @phpstan-method ($value is true ? (T is array ? self<T> : self<array>) : self<T>) asArray($value = true)
* @psalm-method ($value is true ? (T is array ? self<T> : self<array>) : self<T>) asArray($value = true)
*
* @phpstan-method BatchQueryResult<int, T[]> batch($batchSize = 100, $db = null)
* @psalm-method BatchQueryResult<int, T[]> batch($batchSize = 100, $db = null)
*
* @phpstan-method BatchQueryResult<int, T> each($batchSize = 100, $db = null)
* @psalm-method BatchQueryResult<int, T> each($batchSize = 100, $db = null)
*/
class ActiveQuery extends Query implements ActiveQueryInterface
{
Expand Down Expand Up @@ -316,32 +331,6 @@ public function one($db = null)
return null;
}

/**
* {@inheritdoc}
*
* @return BatchQueryResult
* @psalm-return T[][]|BatchQueryResult
* @phpstan-return T[][]|BatchQueryResult
* @codeCoverageIgnore
*/
public function batch($batchSize = 100, $db = null)
{
return parent::batch($batchSize, $db);
}

/**
* {@inheritdoc}
*
* @return BatchQueryResult
* @psalm-return T[]|BatchQueryResult
* @phpstan-return T[]|BatchQueryResult
* @codeCoverageIgnore
*/
public function each($batchSize = 100, $db = null)
{
return parent::each($batchSize, $db);
}

/**
* Creates a DB command that can be used to execute this query.
* @param Connection|null $db the DB connection used to create the DB command.
Expand Down
6 changes: 6 additions & 0 deletions framework/db/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public static function getDb()
* @param string $sql the SQL statement to be executed
* @param array $params parameters to be bound to the SQL statement during execution.
* @return ActiveQuery the newly created [[ActiveQuery]] instance
*
* @phpstan-return ActiveQuery<static>
* @psalm-return ActiveQuery<static>
*/
public static function findBySql($sql, $params = [])
{
Expand Down Expand Up @@ -408,6 +411,9 @@ public static function deleteAll($condition = null, $params = [])
/**
* {@inheritdoc}
* @return ActiveQuery the newly created [[ActiveQuery]] instance.
*
* @phpstan-return ActiveQuery<static>
* @psalm-return ActiveQuery<static>
*/
public static function find()
{
Expand Down
11 changes: 5 additions & 6 deletions framework/di/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,11 @@ class Container extends Component
* @throws InvalidConfigException if the class cannot be recognized or correspond to an invalid definition
* @throws NotInstantiableException If resolved to an abstract class or an interface (since 2.0.9)
*
*
* @template T of class-string
* @psalm-param class-string<T>|array{class: class-string<T>} $class
* @phpstan-param class-string<T>|array{class: class-string<T>} $class
* @psalm-return T
* @phpstan-return T
* @template T of object
* @psalm-param string|class-string<T>|Instance $class
* @phpstan-param string|class-string<T>|Instance $class
* @psalm-return ($class is class-string<T> ? T : object)
* @phpstan-return ($class is class-string<T> ? T : object)
*/
public function get($class, $params = [], $config = [])
{
Expand Down
6 changes: 6 additions & 0 deletions framework/di/Instance.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ public static function of($id, $optional = false)
* @param ServiceLocator|Container|null $container the container. This will be passed to [[get()]].
* @return object the object referenced by the Instance, or `$reference` itself if it is an object.
* @throws InvalidConfigException if the reference is invalid
*
* @template T of object
* @psalm-param class-string<T>|null $type
* @phpstan-param class-string<T>|null $type
* @psalm-return ($type is null ? object : T)
* @phpstan-return ($type is null ? object : T)
*/
public static function ensure($reference, $type = null, $container = null)
{
Expand Down