I am reading yii2’s source code right now. I found that this method yii\di\Instance::ensure something werid。
I changed the code as following:
public static function ensure($reference, $type = null, $container = null)
{
// I added three lines
$container = null;
var_dump(get_class($container));
die;
// original code
}
I got output as :
string(15) “yii\di\Instance”
Can anyone explain?
#Answer
Just now(2016-04-12 15:20:58),I asked Laruence about this questing in qq group. He answered me that get_calss(null) will return current scope. Then I read the php documetation , It says:
If
objectis omitted when inside a class, the name of that class is returned.
So, RTFM si right.