Fix #20485: Fix error Cannot unset string offsets in yii\di\Instance:ensure(['__class' => ...], 'some\class\name'), Integrate PHPStan for static analysis

This commit is contained in:
Maksim Spirkov
2025-08-27 00:01:33 +05:00
committed by GitHub
parent 22889d314a
commit 28b6ca7002
23 changed files with 327 additions and 118 deletions

View File

@ -17,6 +17,7 @@ Yii Framework 2 Change Log
- Enh #20480: Add PHPStan/Psalm annotations for `ServiceLocator::get` (max-s-lab)
- Bug #20447: Fix behavior for `yii\web\Controller::bindActionParams` around `mixed` type (chriscpty)
- Bug #20492: Fix deprecation of `finfo_close()` in PHP `8.5` by conditionally closing the resource (terabytesoftw)
- Bug #20485: Fix error `Cannot unset string offsets` in `yii\di\Instance:ensure(['__class' => ...], 'some\class\name')` (max-s-lab)
2.0.53 June 27, 2025
--------------------

View File

@ -101,9 +101,7 @@ class XCache extends Cache
protected function flushValues()
{
for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) {
if (xcache_clear_cache(XC_TYPE_VAR, $i) === false) {
return false;
}
xcache_clear_cache(XC_TYPE_VAR, $i);
}
return true;

View File

@ -432,9 +432,7 @@ class HelpController extends Controller
];
ksort($options);
if (!empty($options)) {
$this->stdout(' [...options...]', Console::FG_RED);
}
$this->stdout(' [...options...]', Console::FG_RED);
$this->stdout("\n\n");
if (!empty($args)) {
@ -449,21 +447,19 @@ class HelpController extends Controller
}
}
if (!empty($options)) {
$this->stdout("\nOPTIONS\n\n", Console::BOLD);
foreach ($options as $name => $option) {
$this->stdout($this->formatOptionHelp(
$this->ansiFormat(
'--' . $name . $this->formatOptionAliases($controller, $name),
Console::FG_RED,
empty($option['required']) ? Console::FG_RED : Console::BOLD
),
!empty($option['required']),
$option['type'],
$option['default'],
$option['comment']
) . "\n\n");
}
$this->stdout("\nOPTIONS\n\n", Console::BOLD);
foreach ($options as $name => $option) {
$this->stdout($this->formatOptionHelp(
$this->ansiFormat(
'--' . $name . $this->formatOptionAliases($controller, $name),
Console::FG_RED,
empty($option['required']) ? Console::FG_RED : Console::BOLD
),
!empty($option['required']),
$option['type'],
$option['default'],
$option['comment']
) . "\n\n");
}
}

View File

@ -129,7 +129,7 @@ class Instance
}
if (isset($reference['__class'])) {
$class = $reference['__class'];
unset($reference['__class'], $type['class']);
unset($reference['__class'], $reference['class']);
} elseif (isset($reference['class'])) {
$class = $reference['class'];
unset($reference['class']);

View File

@ -1,3 +1,13 @@
<?php
/**
* @var \yii\web\View $this
* @var array $fields
* @var string $table
* @var array $foreignKeys
*/
?>
<?php foreach ($fields as $field): ?>
$this->addColumn('<?=
$table

View File

@ -1,3 +1,11 @@
<?php
/**
* @var array $foreignKeys
* @var string $table
*/
?>
<?php foreach ($foreignKeys as $column => $fkData): ?>
// creates index for column `<?= $column ?>`

View File

@ -3,6 +3,7 @@
/**
* Creates a call for the method `yii\db\Migration::createTable()`.
*
* @var \yii\web\View $this
* @var string $table the name table
* @var array $fields the fields
* @var array $foreignKeys the foreign keys

View File

@ -1,5 +1,12 @@
<?php
/**
* @var \yii\web\View $this
* @var string $table
* @var array $foreignKeys
* @var array $fields
*/
echo $this->render('_dropForeignKeys', [
'table' => $table,
'foreignKeys' => $foreignKeys,

View File

@ -1,3 +1,11 @@
<?php
/**
* @var array $foreignKeys
* @var string $table
*/
?>
<?php foreach ($foreignKeys as $column => $fkData): ?>
// drops foreign key for table `<?= $fkData['relatedTable'] ?>`
$this->dropForeignKey(

View File

@ -3,6 +3,7 @@
/**
* Creates a call for the method `yii\db\Migration::dropTable()`.
*
* @var \yii\web\View $this
* @var string $table the name table
* @var array $foreignKeys the foreign keys
*/

View File

@ -5,10 +5,12 @@
*
* The following variables are available in this view:
*
* @var \yii\web\View $this
* @var string $className the new migration class name without namespace
* @var string $namespace the new migration class namespace
* @var string $table the name table
* @var array $fields the fields
* @var array $foreignKeys
*/
echo "<?php\n";

View File

@ -5,6 +5,7 @@
*
* The following variables are available in this view:
*
* @var \yii\web\View $this
* @var string $className the new migration class name without namespace
* @var string $namespace the new migration class namespace
* @var string $table the name table

View File

@ -5,10 +5,12 @@
*
* The following variables are available in this view:
*
* @var \yii\web\View $this
* @var string $className the new migration class name without namespace
* @var string $namespace the new migration class namespace
* @var string $table the name table
* @var array $fields the fields
* @var array $foreignKeys
*/
echo "<?php\n";

View File

@ -5,10 +5,12 @@
*
* The following variables are available in this view:
*
* @var \yii\web\View $this
* @var string $className the new migration class name without namespace
* @var string $namespace the new migration class namespace
* @var string $table the name table
* @var array $fields the fields
* @var array $foreignKeys
*/
echo "<?php\n";

View File

@ -1,5 +1,6 @@
<?php
/**
* @var \yii\web\View $this
* @var \Throwable $exception
* @var \yii\web\ErrorHandler $handler
*/

View File

@ -253,7 +253,7 @@ class UploadedFile extends BaseObject
{
if (self::$_files === null) {
self::$_files = [];
if (isset($_FILES) && is_array($_FILES)) {
if (is_array($_FILES)) {
foreach ($_FILES as $key => $info) {
self::loadFilesRecursive(
$key,