slickframework /
di
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * This file is part of slick/di package |
||
| 5 | * |
||
| 6 | * For the full copyright and license information, please view the LICENSE.md |
||
| 7 | * file that was distributed with this source code. |
||
| 8 | */ |
||
| 9 | |||
| 10 | namespace Slick\Di\Definition; |
||
| 11 | |||
| 12 | use Psr\Container\ContainerInterface; |
||
| 13 | use Slick\Di\DefinitionInterface; |
||
|
0 ignored issues
–
show
|
|||
| 14 | use Slick\Di\Exception\ContainerNotSetException; |
||
| 15 | use Slick\Di\Exception\NotFoundException; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Alias Definition |
||
| 19 | * |
||
| 20 | * @package Slick\Di\Definition |
||
| 21 | * @author Filipe Silva <[email protected]> |
||
| 22 | */ |
||
| 23 | class Alias extends AbstractDefinition implements DefinitionInterface |
||
|
0 ignored issues
–
show
The type
Slick\Di\Definition\AbstractDefinition was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 24 | { |
||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $alias; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Alias needs a name and the definition name to look for in the container |
||
| 32 | * |
||
| 33 | * @param string $alias |
||
| 34 | */ |
||
| 35 | public function __construct($alias) |
||
| 36 | { |
||
| 37 | $alias = str_replace('@', '', $alias); |
||
| 38 | |||
| 39 | $this->alias = $alias; |
||
| 40 | } |
||
| 41 | 2 | ||
| 42 | /** |
||
| 43 | 2 | * Resolves the definition into a scalar or object |
|
| 44 | * |
||
| 45 | * @return mixed |
||
| 46 | * |
||
| 47 | * @throws NotFoundException No entry was found for alias |
||
| 48 | * in current container. |
||
| 49 | * @throws ContainerNotSetException If no container is set before |
||
| 50 | * calling resolve(). |
||
| 51 | */ |
||
| 52 | public function resolve(): mixed |
||
| 53 | { |
||
| 54 | if (!$this->container instanceof ContainerInterface) { |
||
| 55 | throw new ContainerNotSetException( |
||
| 56 | "No container was set for definition. ". |
||
| 57 | "It is not possible to look for alias '{$this->alias}'" |
||
| 58 | ); |
||
| 59 | } |
||
| 60 | |||
| 61 | return $this->container->get($this->alias); |
||
| 62 | } |
||
| 63 | } |
||
| 64 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths