{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/6845","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/6845/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/6845/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/6845/events","html_url":"https://github.com/yiisoft/yii2/issues/6845","id":54147576,"number":6845,"title":"a bug at yii\\smarty\\Extension::functionRegisterJsFile when set position param in smarty tpl","user":{"login":"TomassunGitHub","id":10161976,"avatar_url":"https://avatars.githubusercontent.com/u/10161976?v=3","gravatar_id":"","url":"https://api.github.com/users/TomassunGitHub","html_url":"https://github.com/TomassunGitHub","followers_url":"https://api.github.com/users/TomassunGitHub/followers","following_url":"https://api.github.com/users/TomassunGitHub/following{/other_user}","gists_url":"https://api.github.com/users/TomassunGitHub/gists{/gist_id}","starred_url":"https://api.github.com/users/TomassunGitHub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomassunGitHub/subscriptions","organizations_url":"https://api.github.com/users/TomassunGitHub/orgs","repos_url":"https://api.github.com/users/TomassunGitHub/repos","events_url":"https://api.github.com/users/TomassunGitHub/events{/privacy}","received_events_url":"https://api.github.com/users/TomassunGitHub/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/ext%3Asmarty","name":"ext:smarty","color":"bfd4f2"}],"state":"closed","locked":false,"assignee":{"login":"samdark","id":47294,"avatar_url":"https://avatars.githubusercontent.com/u/47294?v=3","gravatar_id":"","url":"https://api.github.com/users/samdark","html_url":"https://github.com/samdark","followers_url":"https://api.github.com/users/samdark/followers","following_url":"https://api.github.com/users/samdark/following{/other_user}","gists_url":"https://api.github.com/users/samdark/gists{/gist_id}","starred_url":"https://api.github.com/users/samdark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samdark/subscriptions","organizations_url":"https://api.github.com/users/samdark/orgs","repos_url":"https://api.github.com/users/samdark/repos","events_url":"https://api.github.com/users/samdark/events{/privacy}","received_events_url":"https://api.github.com/users/samdark/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2/milestones/11","labels_url":"https://api.github.com/repos/yiisoft/yii2/milestones/11/labels","id":896106,"number":11,"title":"2.0.3","description":"","creator":{"login":"qiangxue","id":993322,"avatar_url":"https://avatars.githubusercontent.com/u/993322?v=3","gravatar_id":"","url":"https://api.github.com/users/qiangxue","html_url":"https://github.com/qiangxue","followers_url":"https://api.github.com/users/qiangxue/followers","following_url":"https://api.github.com/users/qiangxue/following{/other_user}","gists_url":"https://api.github.com/users/qiangxue/gists{/gist_id}","starred_url":"https://api.github.com/users/qiangxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiangxue/subscriptions","organizations_url":"https://api.github.com/users/qiangxue/orgs","repos_url":"https://api.github.com/users/qiangxue/repos","events_url":"https://api.github.com/users/qiangxue/events{/privacy}","received_events_url":"https://api.github.com/users/qiangxue/received_events","type":"User","site_admin":false},"open_issues":27,"closed_issues":33,"state":"open","created_at":"2014-12-08T18:26:37Z","updated_at":"2015-01-20T19:24:32Z","due_on":"2015-03-01T05:00:00Z","closed_at":null},"comments":1,"created_at":"2015-01-13T03:42:33Z","updated_at":"2015-01-20T19:24:39Z","closed_at":"2015-01-20T19:24:32Z","body":"at the function `yii\\smarty\\Extension::functionRegisterJsFile`\r\nit's call `\\yii\\web\\View::registerJsFile` use 4 params\r\n```php\r\n    $url = ArrayHelper::remove($params, 'url');\r\n    $key = ArrayHelper::remove($params, 'key', null);\r\n    $depends = ArrayHelper::remove($params, 'depends', null);\r\n    if (isset($params['position']))\r\n        $params['position'] = $this->getViewConstVal($params['position'], View::POS_END);\r\n\r\n    //这里使用了4个参数 there use 4 params\r\n    Yii::$app->getView()->registerJsFile($url, $depends, $params, $key);\r\n```\r\nbut the function only 3 params\r\n```php\r\n//这里只有3个参数 there only 3 params \r\npublic function registerJsFile($url, $options = [], $key = null)\r\n```\r\nwhen you set position param in smarty tpl ,has a error\r\n\r\nRepair\r\n```php\r\n    $url = ArrayHelper::remove($params, 'url');\r\n    $key = ArrayHelper::remove($params, 'key', null);\r\n    $position = ArrayHelper::remove($params, 'position');\r\n    if (isset($position))\r\n        $params['position'] = $this->getViewConstVal($position, View::POS_END);\r\n\r\n    Yii::$app->getView()->registerJsFile($url, $params, $key);\r\n```\r\nfunctionRegisterCssFile has same bug\r\n\r\n```php\r\n    $url = ArrayHelper::remove($params, 'url');\r\n    $key = ArrayHelper::remove($params, 'key', null);\r\n    $depends = ArrayHelper::remove($params, 'depends', null);\r\n\r\n    Yii::$app->getView()->registerCssFile($url, $depends, $params, $key);\r\n```\r\n\r\nRepair\r\n```php\r\n    $url = ArrayHelper::remove($params, 'url');\r\n    $key = ArrayHelper::remove($params, 'key', null);\r\n\r\n    Yii::$app->getView()->registerCssFile($url, $params, $key);\r\n```"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/70715369","html_url":"https://github.com/yiisoft/yii2/issues/6845#issuecomment-70715369","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/6845","id":70715369,"user":{"login":"samdark","id":47294,"avatar_url":"https://avatars.githubusercontent.com/u/47294?v=3","gravatar_id":"","url":"https://api.github.com/users/samdark","html_url":"https://github.com/samdark","followers_url":"https://api.github.com/users/samdark/followers","following_url":"https://api.github.com/users/samdark/following{/other_user}","gists_url":"https://api.github.com/users/samdark/gists{/gist_id}","starred_url":"https://api.github.com/users/samdark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samdark/subscriptions","organizations_url":"https://api.github.com/users/samdark/orgs","repos_url":"https://api.github.com/users/samdark/repos","events_url":"https://api.github.com/users/samdark/events{/privacy}","received_events_url":"https://api.github.com/users/samdark/received_events","type":"User","site_admin":false},"created_at":"2015-01-20T19:24:39Z","updated_at":"2015-01-20T19:24:39Z","body":"Thanks! Fixed."}}