cloudcreativity / laravel-json-api

JSON API (jsonapi.org) package for Laravel applications.
http://laravel-json-api.readthedocs.io/en/latest/
Apache License 2.0
780 stars 109 forks source link

Api::getContainer() return type fixed #475

Closed zlodes closed 4 years ago

zlodes commented 4 years ago
if (!$this->container) {
    $this->container = $this->factory->createExtendedContainer($this->resolver);
}

return $this->container;

Factory::createExtendedContainer() always returns Container instance:

/**
 * @inheritdoc
 */
public function createExtendedContainer(ResolverInterface $resolver)
{
    return new Container($this->container, $resolver);
}

This generates phpstan errors:

-------------------------------------------------------------------------
 Line   Base/Schema.php
-------------------------------------------------------------------------
  48     Cannot call method getAdapterByResourceType() on
         CloudCreativity\LaravelJsonApi\Contracts\ContainerInterface|null.
-------------------------------------------------------------------------

On this code:

/** @var Adapter $adapter */
$adapter = json_api()->getContainer()->getAdapterByResourceType(
    $this->resourceType
);
lindyhopchris commented 4 years ago

Thanks!