src/Container.php
public function has(string $key) : bool
    {
        if (isset($this->items[$key])) {
            return true;
        }

        try {
            $class = new \ReflectionClass($key);
        } catch (\ReflectionException $e) {
            return false;
        }

        $classes = $this->reflectionTools->getClassHierarchy($class);

        foreach ($classes as $class) {
            if ($this->injectionPolicy->isClassInjected($class)) {
                $this->bind($key); // @todo allow to configure scope (singleton) with annotations

                return true;
            }
        }

        return false;
    }
public function has(string $key) : bool
    {
        if (isset($this->items[$key])) {
            return true;
        }

        try {
            $class = new \ReflectionClass($key);
        } catch (\ReflectionException $e) {
            return false;
        }

        $classes = $this->reflectionTools->getClassHierarchy($class);

        foreach ($classes as $class) {
            if ($this->injectionPolicy->isClassInjected($class)) {
                $this->bind($key); // @todo allow to configure scope (singleton) with annotations

                return true;
            }
        }

        return false;
    }
public function has ( string $ key ) : bool { if ( isset ( $ this -> items [ $ key ] ) ) { return true ; } try { $ class = new \ ReflectionClass ( $ key ) ; } catch ( \ ReflectionException $ e ) { return false ; } $ classes = $ this -> reflectionTools -> getClassHierarchy ( $ class ) ; foreach ( $ classes as $ class ) { if ( $ this -> injectionPolicy -> isClassInjected ( $ class ) ) { $ this -> bind ( $ key ) ; // @todo allow to configure scope (singleton) with annotations return true ; } } return false ; }
Returns whether the container has the given key.

@param string $key The key, class or interface name.

@return bool
Returns whether the container has the given key .