Fix PHPStan errors (#20603)

This commit is contained in:
Maksim Spirkov
2025-10-14 12:38:07 +03:00
committed by GitHub
parent d71f7309ae
commit 287d0fa074
7 changed files with 18 additions and 11 deletions

View File

@ -55,7 +55,7 @@ abstract class ErrorHandler extends Component
public $silentExitOnException;
/**
* @var string Used to reserve memory for fatal error handler.
* @var string|null Used to reserve memory for fatal error handler.
*/
private $_memoryReserve;
/**
@ -67,7 +67,7 @@ abstract class ErrorHandler extends Component
*/
private $_registered = false;
/**
* @var string the current working directory
* @var string|null the current working directory
*/
private $_workingDirectory;

View File

@ -95,11 +95,11 @@ class Model extends Component implements StaticInstanceInterface, IteratorAggreg
public const EVENT_AFTER_VALIDATE = 'afterValidate';
/**
* @var array validation errors (attribute name => array of errors)
* @var array|null validation errors (attribute name => array of errors)
*/
private $_errors;
/**
* @var ArrayObject list of validators
* @var ArrayObject|null list of validators
*/
private $_validators;
/**

View File

@ -68,11 +68,11 @@ class BatchQueryResult extends Component implements \Iterator
public $each = false;
/**
* @var DataReader the data reader associated with this batch query.
* @var DataReader|null the data reader associated with this batch query.
*/
private $_dataReader;
/**
* @var array the data retrieved in the current batch
* @var array|null the data retrieved in the current batch
*/
private $_batch;
/**
@ -80,7 +80,7 @@ class BatchQueryResult extends Component implements \Iterator
*/
private $_value;
/**
* @var string|int the key for the current iteration
* @var string|int|null the key for the current iteration
*/
private $_key;

View File

@ -71,7 +71,9 @@ class Command extends \yii\db\Command
* or `false` if there's a single statement.
* @param string $sql
* @param array $params
* @return string[]|false
* @return array[]|false
*
* @phpstan-return list<array{string, array}>|false
*/
private function splitStatements($sql, $params)
{

View File

@ -436,7 +436,9 @@ class DbManager extends BaseManager
$items = [];
foreach ($query->all($this->db) as $row) {
$items[$row['name']] = $this->populateItem($row);
/** @var Role|Permission */
$item = $this->populateItem($row);
$items[$row['name']] = $item;
}
return $items;

View File

@ -325,7 +325,7 @@ class PhpManager extends BaseManager
$items = [];
foreach ($this->items as $name => $item) {
/** @var Item $item */
/** @var Role|Permission $item */
if ($item->type == $type) {
$items[$name] = $item;
}

View File

@ -149,7 +149,10 @@ class AssetBundle extends BaseObject
*/
public static function register($view)
{
return $view->registerAssetBundle(get_called_class());
/** @var static */
$result = $view->registerAssetBundle(get_called_class());
return $result;
}
/**