Browse Source

Fixes #10372: Fixed console controller including DI arguments in help

tags/2.0.7
Sam Mousa 9 years ago committed by Alexander Makarov
parent
commit
18fc8db32f
  1. 1
      framework/CHANGELOG.md
  2. 5
      framework/console/Controller.php
  3. 23
      tests/framework/console/ControllerTest.php

1
framework/CHANGELOG.md

@ -43,6 +43,7 @@ Yii Framework 2 Change Log
- Bug #10142: Fixed `yii\validators\EmailValidator` to check the length of email properly (silverfire)
- Bug #10278: Fixed `yii\helpers\BaseJson` support \SimpleXMLElement data (SilverFire, LAV45)
- Bug #10302: Fixed JS function `yii.getQueryParams`, which parsed array variables incorrectly (servocoder, silverfire)
- Bug #10372: Fixed console controller including DI arguments in help (sammousa)
- Bug #10385: Fixed `yii\validators\CaptchaValidator` passed incorrect hashKey to JS validator when `captchaAction` begins with `/` (silverfire)
- Bug: Fixed generation of canonical URLs for `ViewAction` pages (samdark)
- Bug: Fixed `mb_*` functions calls to use `UTF-8` or `Yii::$app->charset` (silverfire)

5
framework/console/Controller.php

@ -414,8 +414,13 @@ class Controller extends \yii\base\Controller
$params = isset($tags['param']) ? (array) $tags['param'] : [];
$args = [];
/** @var \ReflectionParameter $reflection */
foreach ($method->getParameters() as $i => $reflection) {
$name = $reflection->getName();
if ($reflection->getClass() !== null) {
continue;
}
$tag = isset($params[$i]) ? $params[$i] : '';
if (preg_match('/^(\S+)\s+(\$\w+\s+)?(.*)/s', $tag, $matches)) {
$type = $matches[1];

23
tests/framework/console/ControllerTest.php

@ -92,4 +92,27 @@ class ControllerTest extends TestCase
$result = $controller->runAction('aksi7', $params);
}
/**
* Tests if action help does not include class-hinted arguments
* @see https://github.com/yiisoft/yii2/issues/10372
*/
public function testHelp()
{
$this->mockApplication([
'components' => [
'barBelongApp' => [
'class' => Bar::className(),
'foo' => 'belong_app'
],
'quxApp' => [
'class' => OtherQux::className(),
'b' => 'belong_app'
]
]
]);
$controller = new FakeController('fake', Yii::$app);
$this->assertArrayNotHasKey('bar', $controller->getActionArgsHelp($controller->createAction('aksi1')));
}
}

Loading…
Cancel
Save