DS
Size: a a a
DS
AM
AM
AM
DS
AM
AM
AM
AM
А
yii-di
и меня смутило некоторое подозрение в том, что контейнер то не совсем PSR-ненький. Поминится, я уже писал примерно тоже самое про ларовский, ну и вот.// returns false as provider wasn't registeredЧитаем описание
$container->has(EngineInterface::class);
// returns SolarEngine, registered in the provider
$engine = $container->get(EngineInterface::class);
// returns true as provider was registered when EngineInterface was requested from the container
$container->has(EngineInterface::class);
has()
на php.fig:has
takes one unique parameter: an entry identifier, which MUST be a string. has
MUST return true
if an entry identifier is known to the container and false
if it is not. If has($id)
returns false, get($id)
MUST throw a NotFoundExceptionInterface
./**Важно >> Returns true if the container can return an entry for the given identifier
* Returns true if the container can return an entry for the given identifier.
* Returns false otherwise.
*
* `has($id)` returning true does not mean that `get($id)` will not throw an exception.
* It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
*
* @param string $id Identifier of the entry to look for.
*
* @return bool
*/
public function has($id);
get()
может вернуть запрошенную сущность, то has()
обязана вернуть true
, ибо если has()
вернёт false
, то get()
должен выкинуть исключение.А
AM
А
DS
AM
DS
А
AM
А
DS