This PR updates the type declaration (docblock) of the DefaultContainer::$services to the more specific array<string, object> and removes the resolved phpstan-baseline error. This type is derived as follows: within the DefaultContainer::__construct(), the keys are represented by class-string and mapped to values of type object. Additionally, DefaultContainer::setInstance() uses string type for keys and parameter $service is documented as type object, meaning that only type object occurs as value in DefaultContainer::$services.
As a logical consequence, DefaultContainer::get() returns objects based on the aforementioned, and InjectorInterface::create() which is also said to return type object.
Although the DefaultContainer::get() is inherit from the ContainerInterface::class which has return type mixed, the child is allowed to have a more specific return type based on covariance.
Description
This PR updates the type declaration (docblock) of the
DefaultContainer::$services
to the more specificarray<string, object>
and removes the resolved phpstan-baseline error. This type is derived as follows: within the DefaultContainer::__construct(), the keys are represented byclass-string
and mapped to values of typeobject
. Additionally, DefaultContainer::setInstance() usesstring
type for keys and parameter$service
is documented as typeobject
, meaning that only typeobject
occurs as value inDefaultContainer::$services
.As a logical consequence, DefaultContainer::get() returns objects based on the aforementioned, and InjectorInterface::create() which is also said to return type
object
. Although theDefaultContainer::get()
is inherit from theContainerInterface::class
which has return typemixed
, the child is allowed to have a more specific return type based on covariance.