Can be shortened "Yii::$app->db->createCommand()"?

i try:




/**

 * Creates a command for execution.

 * @param string $sql the SQL statement to be executed

 * @param array $params the parameters to be bound to the SQL statement

 * @return Command the DB command

 */

function db($sql = null, $params = [])

{

	return new \Yii::$app->db->createCommand($sql, $params);

}



and then




db()->....



But autocomplete code in PHPStorm does not work in this example.

Does it have any solution? Any ideas?

(sorry for my bad English)

I think this discussion can help you

http://www.yiiframework.com/forum/index.php/topic/51101-yii2-and-phpstorm/

My bad:


@return Command the DB command

correctly should be:


@return \yii\db\Command the DB command

So, this is how it works for me, including autocomplete in PHPStorm:




/**

 * Creates a command for execution.

 * @param string $sql the SQL statement to be executed

 * @param array $params the parameters to be bound to the SQL statement

 * @return \yii\db\Command the DB command

 */

function db($sql = null, $params = [])

{

	return new \Yii::$app->db->createCommand($sql, $params);

}


...


db()->...