Skip to content

CConsoleCommand: Array to string conversion when displaying help #1996

Closed
dInGd0nG opened this Issue Jan 17, 2013 · 6 comments

3 participants

@dInGd0nG

Below command uses anonymous arguments as specified in the definitive guide.

class TestCommand extends CConsoleCommand
{
    public function actionIndex($limit=10, $args=array())
    {
        print_r($args);
    }
}

So when I call the help for this test command
php yiic help test

PHP Error[8]: Array to string conversion
    in file /var/www/yii/framework/console/CConsoleCommand.php at line 313
@samdark
Yii Software LLC member
samdark commented Jan 17, 2013

I think you should add array hint in front of $args. Also is there the same error if you're not using print_r?

@dInGd0nG

I used exactly as said in the definitive guide. the problem is ther without print_r . this line is causing problems as the $defaultValue is an array()

Anonymous action parameters wont work if i use an arry hinting

@samdark
Yii Software LLC member
samdark commented Jan 17, 2013

Ahh, I see. Yes, that seems to be a bug. You must be used very recent PHP versions.

@samdark samdark was assigned Jan 17, 2013
@cebe
Yii Software LLC member
cebe commented Jan 17, 2013

hm... afaik you have to put $args as first param, but didn't check that.

@samdark
Yii Software LLC member
samdark commented Jan 26, 2013

@dInGd0nG can you send a pull-request?

@samdark samdark added a commit that closed this issue Jan 26, 2013
@samdark samdark Fixed #1996: Using yiic help for commands with parameters with array …
…as default value resulted in PHP error with latest PHP versions
0dbccc4
@samdark samdark closed this in 0dbccc4 Jan 26, 2013
@samdark
Yii Software LLC member
samdark commented Jan 26, 2013

Merged manually with some adjustments. Thanks for working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.