yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework

Home Page:http://www.yiiframework.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ActiveRecord::getRelation("????", false) throw ArgumentCountError exception

webinjaz opened this issue · comments

What steps will reproduce the problem?

1 - add a static function with parameters and it`s name starts with "get" in an ActiveRecored sub class,
ex:
public static function getHint($param)
{
....
}
2- call $model->getRelation("hint", false);// $model is an instance of that ActiveRecord

What is the expected result?

getting null without error throwing

$model->getRelation("hint", false) // return null without error throwing

What do you get instead?

This Exception:
ArgumentCountError
Too few arguments to function getHint(), 0 passed in \vendor\yiisoft\yii2\db\BaseActiveRecord.php on line 1248 and exactly 2 expected

Additional info

Q A
Yii version 2.0.49.3
PHP version 7.4.26
Operating system windows

If you want to use it like that you must make $param optional.