src/Container/Container.php
public function alias(string $alias, string $abstract): void
    {
        if (\array_key_exists($alias, $this->values) || isset($this->factory[$alias])) {
            throw new InvalidArgumentException("Already defined in container: $alias");
        }

        if ($alias === $abstract) {
            throw new InvalidArgumentException('Alias cannot be the same as the original name');
        }

        $this->alias[$alias] = $abstract;

        if (!isset($this->abstractAlias[$abstract])) {
            $this->abstractAlias[$abstract] = [];
        }

        $this->abstractAlias[$abstract][] = $alias;
    }
public function alias(string $alias, string $abstract): void
    {
        if (\array_key_exists($alias, $this->values) || isset($this->factory[$alias])) {
            throw new InvalidArgumentException("Already defined in container: $alias");
        }

        if ($alias === $abstract) {
            throw new InvalidArgumentException('Alias cannot be the same as the original name');
        }

        $this->alias[$alias] = $abstract;

        if (!isset($this->abstractAlias[$abstract])) {
            $this->abstractAlias[$abstract] = [];
        }

        $this->abstractAlias[$abstract][] = $alias;
    }
public function alias ( string $ alias , string $ abstract ) : void { if ( \ array_key_exists ( $ alias , $ this -> values ) || isset ( $ this -> factory [ $ alias ] ) ) { throw new InvalidArgumentException ( "Already defined in container: $alias" ) ; } if ( $ alias === $ abstract ) { throw new InvalidArgumentException ( 'Alias cannot be the same as the original name' ) ; } $ this -> alias [ $ alias ] = $ abstract ; if ( ! isset ( $ this -> abstractAlias [ $ abstract ] ) ) { $ this -> abstractAlias [ $ abstract ] = [ ] ; } $ this -> abstractAlias [ $ abstract ] [ ] = $ alias ; }
Register a component as an alias of another registered component.

@param string $alias    new component name
@param string $abstract referenced existing component name

@throws InvalidArgumentException
Register a component as an alias of another registered component .