mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Fixes #10372: Fixed console controller including complex typed arguments in help
This commit is contained in:
@ -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
|
||||
--------------------------
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user