-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Fix PHPStan errors #20523
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
Fix PHPStan errors #20523
Conversation
max-s-lab
commented
Sep 13, 2025
Q | A |
---|---|
Is bugfix? | ✔️ |
New feature? | ❌ |
Breaks BC? | ❌ |
Fixed issues |
framework/web/Controller.php
Outdated
public function renderAjax($view, $params = []) | ||
{ | ||
return $this->getView()->renderAjax($view, $params, $this); | ||
return $this->view->renderAjax($view, $params, $this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it? 1. There's initialization happens. 2. One may extend and override the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I fixed it using annotations
$method = [$model, $method]; | ||
} elseif ($method instanceof \Closure) { | ||
$method = $this->method->bindTo($model); | ||
$method = $method->bindTo($model); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #20523 +/- ##
=============================================
- Coverage 64.49% 21.07% -43.42%
+ Complexity 11574 11473 -101
=============================================
Files 433 433
Lines 37605 37519 -86
=============================================
- Hits 24253 7907 -16346
- Misses 13352 29612 +16260 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
framework/di/Container.php
Outdated
} | ||
} else { | ||
$isClass = $class !== null && !$class->isBuiltin(); | ||
$isClass = $class instanceof \ReflectionNamedType && !$class->isBuiltin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you achieve the same with some annotations instead? Adding more checks, which aren't useful, to DI container costs performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
$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"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure it works after the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | ||
* @phpstan-var \yii\web\View&object{ | ||
* context: \yii\build\controllers\TranslationController, | ||
* } $this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
$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"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure it works after the change?
framework/di/Container.php
Outdated
} | ||
} else { | ||
$isClass = $class !== null && !$class->isBuiltin(); | ||
$isClass = $class instanceof \ReflectionNamedType && !$class->isBuiltin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you achieve the same with some annotations instead? Adding more checks, which aren't useful, to DI container costs performance.
framework/web/Controller.php
Outdated
public function renderAjax($view, $params = []) | ||
{ | ||
return $this->getView()->renderAjax($view, $params, $this); | ||
return $this->view->renderAjax($view, $params, $this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it? 1. There's initialization happens. 2. One may extend and override the method.