No errors
yii\base\ErrorException get_class() expects parameter 1 to be object, null given

As of 7.2, http://php.net/manual/en/function.get-class.php:
Explicitly passing NULL as the object is no longer allowed as of PHP 7.2.0. The parameter is still optional and calling get_class() without a parameter from inside a class will work, but passing NULL now emits an E_WARNING notice.
| Q | A
| ---------------- | ---
| Yii version | All
| PHP version | 7.2 alpha|
$component should never be null in that path.
Line 315 guarantees it is instantiated.
Could it be you have a component defined via a Closure that is not returning an object.
Side note: should \Yii::createObject() check the result of callable definitions to ensure that it is an object and not another type?
I have reviewed the usage of get_class() in the framework and I see no place where we rely on it to work with null.
Side note: should \Yii::createObject() check the result of callable definitions to ensure that it is an object and not another type?
that's unnecessary overhead imo.
@cebe, I think the overhead is negligible.
doing:
````
if (!is_object($result)) {
throw SomeException();
````
I think that's worth it. I'd rather have an exception thrown than get a hard to find error for some perceived performance gain...
After discussion with @dynasource the issue is about Closure support in Application::$bootstrap, which was not offically supported but worked because of Yii::createObject() supporting closures.
To fix this, we should add an instanceof Closure check to Application::bootstrap() and avoid calling get_class in that case.
@SamMousa returning a non-object in case where an object is expected the error message is normally very clear, i.e. "calling ... on a non-object" or "getting property from non-object". The error message in this case has a different cause.
@cebe There is another path that will throw the same error:
["test"].
'components' => [
"test" => function() { return "not an object"; }
]
This will get the same error.
Most helpful comment
After discussion with @dynasource the issue is about Closure support in Application::$bootstrap, which was not offically supported but worked because of Yii::createObject() supporting closures.
To fix this, we should add an instanceof Closure check to Application::bootstrap() and avoid calling get_class in that case.
@SamMousa returning a non-object in case where an object is expected the error message is normally very clear, i.e. "calling ... on a non-object" or "getting property from non-object". The error message in this case has a different cause.