psalm-plugin-symfony icon indicating copy to clipboard operation
psalm-plugin-symfony copied to clipboard

ContainerInterface::get return type could be dynamic, based on second argument.

Open VincentLanglet opened this issue 4 years ago • 0 comments

The containerInterface has the following doc

    /**
     * Gets a service.
     *
     * @param string $id              The service identifier
     * @param int    $invalidBehavior The behavior when the service does not exist
     *
     * @return object|null The associated service
     *
     * @throws ServiceCircularReferenceException When a circular reference is detected
     * @throws ServiceNotFoundException          When the service is not defined
     *
     * @see Reference
     */
    public function get($id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);

When using self::EXCEPTION_ON_INVALID_REFERENCE, the return type should be restricted to object.

VincentLanglet avatar Mar 28 '21 00:03 VincentLanglet