From 53bdfc3b2cb2035e25ee95323fb611218bfe66bf Mon Sep 17 00:00:00 2001 From: Maksim Spirkov <63721828+max-s-lab@users.noreply.github.com> Date: Tue, 16 Sep 2025 00:38:06 +0400 Subject: [PATCH] Fix PHPStan errors (#20523) --- build/controllers/ReleaseController.php | 2 +- build/controllers/views/translation/report_html.php | 4 ++++ framework/di/Container.php | 2 ++ framework/requirements/YiiRequirementChecker.php | 2 ++ framework/validators/InlineValidator.php | 2 +- framework/web/Controller.php | 5 ++++- 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/build/controllers/ReleaseController.php b/build/controllers/ReleaseController.php index cec8456309..1e6168a186 100644 --- a/build/controllers/ReleaseController.php +++ b/build/controllers/ReleaseController.php @@ -436,7 +436,7 @@ class ReleaseController extends Controller $this->stdout("done.\n", Console::FG_GREEN, Console::BOLD); $this->stdout('updating mimetype magic file and mime aliases...', Console::BOLD); - $this->dryRun || Yii::$app->runAction('mime-type', ["$frameworkPath/helpers/mimeTypes.php"], ["$frameworkPath/helpers/mimeAliases.php"]); + $this->dryRun || Yii::$app->runAction('mime-type', ["$frameworkPath/helpers/mimeTypes.php"]); $this->stdout("done.\n", Console::FG_GREEN, Console::BOLD); $this->stdout("fixing various PHPDoc style issues...\n", Console::BOLD); diff --git a/build/controllers/views/translation/report_html.php b/build/controllers/views/translation/report_html.php index 302361d23b..17d0a89cda 100644 --- a/build/controllers/views/translation/report_html.php +++ b/build/controllers/views/translation/report_html.php @@ -8,6 +8,10 @@ use yii\helpers\Html; * @var string $sourcePath * @var string $translationPath * @var array $results + * + * @phpstan-var \yii\web\View&object{ + * context: \yii\build\controllers\TranslationController, + * } $this */ ?> diff --git a/framework/di/Container.php b/framework/di/Container.php index 77d456eefa..6ea68a19ba 100644 --- a/framework/di/Container.php +++ b/framework/di/Container.php @@ -675,6 +675,7 @@ class Container extends Component $class = $param->getType(); if ($class instanceof \ReflectionUnionType || (PHP_VERSION_ID >= 80100 && $class instanceof \ReflectionIntersectionType)) { $isClass = false; + /** @var ReflectionNamedType $type */ foreach ($class->getTypes() as $type) { if (!$type->isBuiltin()) { $class = $type; @@ -683,6 +684,7 @@ class Container extends Component } } } else { + /** @var ReflectionNamedType|null $class */ $isClass = $class !== null && !$class->isBuiltin(); } } else { diff --git a/framework/requirements/YiiRequirementChecker.php b/framework/requirements/YiiRequirementChecker.php index a143f47f1e..0982a66ffe 100644 --- a/framework/requirements/YiiRequirementChecker.php +++ b/framework/requirements/YiiRequirementChecker.php @@ -319,6 +319,8 @@ class YiiRequirementChecker } else { require $_viewFile_; } + + return null; } /** diff --git a/framework/validators/InlineValidator.php b/framework/validators/InlineValidator.php index c6425014b3..877d20ac34 100644 --- a/framework/validators/InlineValidator.php +++ b/framework/validators/InlineValidator.php @@ -67,7 +67,7 @@ class InlineValidator extends Validator if (is_string($method)) { $method = [$model, $method]; } elseif ($method instanceof \Closure) { - $method = $this->method->bindTo($model); + $method = $method->bindTo($model); } $current = $this->current; diff --git a/framework/web/Controller.php b/framework/web/Controller.php index 8cd430ccf4..9a469963ef 100644 --- a/framework/web/Controller.php +++ b/framework/web/Controller.php @@ -52,7 +52,10 @@ class Controller extends \yii\base\Controller */ public function renderAjax($view, $params = []) { - return $this->getView()->renderAjax($view, $params, $this); + /** @var View */ + $viewComponent = $this->getView(); + + return $viewComponent->renderAjax($view, $params, $this); } /**