mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-13 22:06:51 +08:00
Fix yii\base\Controller::bindInjectedParams() to not throw error when argument of ReflectionUnionType
type is passed (#18869)
This commit is contained in:
@ -14,6 +14,7 @@ Yii Framework 2 Change Log
|
||||
- Enh #18783: Add `XmlResponseFormatter::$objectTagToLowercase` option to lowercase object tags (WinterSilence, samdark)
|
||||
- Bug #18845: Fix duplicating `id` in `MigrateController::addDefaultPrimaryKey()` (WinterSilence, samdark)
|
||||
- Bug #17119: Fix `yii\caching\Cache::multiSet()` to use `yii\caching\Cache::$defaultDuration` when no duration is passed (OscarBarrett)
|
||||
- Bug #18842: Fix `yii\base\Controller::bindInjectedParams()` to not throw error when argument of `ReflectionUnionType` type is passed (bizley)
|
||||
|
||||
|
||||
2.0.43 August 09, 2021
|
||||
|
@ -563,6 +563,10 @@ class Controller extends Component implements ViewContextInterface
|
||||
*/
|
||||
final protected function bindInjectedParams(\ReflectionType $type, $name, &$args, &$requestedParams)
|
||||
{
|
||||
if (!$type instanceof \ReflectionNamedType || $type->isBuiltin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Since it is not a builtin type it must be DI injection.
|
||||
$typeName = $type->getName();
|
||||
if (($component = $this->module->get($name, false)) instanceof $typeName) {
|
||||
|
@ -226,7 +226,7 @@ class Controller extends \yii\base\Controller
|
||||
}
|
||||
$args[] = $actionParams[$key] = $params[$key];
|
||||
unset($params[$key]);
|
||||
} elseif (PHP_VERSION_ID >= 70100 && ($type = $param->getType()) !== null && !$type->isBuiltin()) {
|
||||
} elseif (PHP_VERSION_ID >= 70100 && ($type = $param->getType()) !== null) {
|
||||
try {
|
||||
$this->bindInjectedParams($type, $name, $args, $requestedParams);
|
||||
} catch (\yii\base\Exception $e) {
|
||||
|
@ -177,7 +177,7 @@ class Controller extends \yii\base\Controller
|
||||
}
|
||||
$args[] = $actionParams[$name] = $params[$name];
|
||||
unset($params[$name]);
|
||||
} elseif (PHP_VERSION_ID >= 70100 && ($type = $param->getType()) !== null && !$type->isBuiltin()) {
|
||||
} elseif (PHP_VERSION_ID >= 70100 && ($type = $param->getType()) !== null) {
|
||||
try {
|
||||
$this->bindInjectedParams($type, $name, $args, $requestedParams);
|
||||
} catch (HttpException $e) {
|
||||
|
Reference in New Issue
Block a user