Fixes #10372: Fixed console controller including complex typed arguments in help

This commit is contained in:
Sam
2017-03-15 13:47:21 +01:00
committed by Alexander Makarov
parent 8192f84850
commit 9459eaa277
4 changed files with 22 additions and 1 deletions

View File

@ -46,7 +46,7 @@ Yii Framework 2 Change Log
- Enh #13695: `\yii\web\Response::setStatusCode()` method now returns the Response object itself (kyle-mccarthy)
- Enh #13698: `yii\grid\DataColumn` filter is automatically generated as dropdown list in case of `format` set to `boolean` (bizley)
- Enh #13254: Core validators no longer require Yii::$app to be set (sammousa)
- Bug #10372: Fixed console controller including complex typed arguments in help (sammousa)
2.0.11.2 February 08, 2017
--------------------------

View File

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

View File

@ -132,4 +132,18 @@ class ControllerTest extends TestCase
$this->assertFalse(FakeController::getWasActionIndexCalled());
$this->assertEquals(FakeHelpController::getActionIndexLastCallParams(), ['news/posts/index']);
}
/**
* Tests if action help does not include (class) type hinted arguments.
* @see #10372
*/
public function testHelpSkipsTypeHintedArguments()
{
$controller = new FakeController('fake', Yii::$app);
$help = $controller->getActionArgsHelp($controller->createAction('with-complex-type-hint'));
$this->assertArrayNotHasKey('typedArgument', $help);
$this->assertArrayHasKey('simpleArgument', $help);
}
}

View File

@ -84,6 +84,10 @@ class FakeController extends Controller
return $this->testArray;
}
public function actionWithComplexTypeHint(self $typedArgument, $simpleArgument) {
return $simpleArgument;
}
public function actionStatus($status = 0)
{
return $status;