mirror of
https://github.com/flarum/core.git
synced 2025-07-21 16:51:34 +02:00
* chore(deps): bump glob-parent in /extensions/emoji/js Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 3.1.0 to 5.1.2. - [Release notes](https://github.com/gulpjs/glob-parent/releases) - [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md) - [Commits](https://github.com/gulpjs/glob-parent/compare/v3.1.0...v5.1.2) --- updated-dependencies: - dependency-name: glob-parent dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Apply fixes from StyleCI [ci skip] [skip ci] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: StyleCI Bot <bot@styleci.io>
73 lines
1.6 KiB
PHP
73 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* This file is part of Flarum.
|
|
*
|
|
* For detailed copyright and license information, please view the
|
|
* LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Flarum\PHPStan\Concerns;
|
|
|
|
use Illuminate\Container\Container;
|
|
use Illuminate\Contracts\Container\BindingResolutionException;
|
|
use Illuminate\Contracts\Container\Container as ContainerContract;
|
|
use Psr\Container\NotFoundExceptionInterface;
|
|
use ReflectionException;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
trait HasContainer
|
|
{
|
|
/**
|
|
* @var ?\Illuminate\Contracts\Container\Container
|
|
*/
|
|
protected $container;
|
|
|
|
/**
|
|
* @param \Illuminate\Contracts\Container\Container $container
|
|
* @return void
|
|
*/
|
|
public function setContainer(ContainerContract $container): void
|
|
{
|
|
$this->container = $container;
|
|
}
|
|
|
|
/**
|
|
* Returns the current broker.
|
|
*
|
|
* @return \Illuminate\Contracts\Container\Container
|
|
*/
|
|
public function getContainer(): ContainerContract
|
|
{
|
|
return $this->container ?? Container::getInstance();
|
|
}
|
|
|
|
/**
|
|
* Resolve the given type from the container.
|
|
*
|
|
* @param string $abstract
|
|
* @return mixed
|
|
*/
|
|
public function resolve(string $abstract)
|
|
{
|
|
$concrete = null;
|
|
|
|
try {
|
|
$concrete = $this->getContainer()
|
|
->make($abstract);
|
|
} catch (ReflectionException $exception) {
|
|
// ..
|
|
} catch (BindingResolutionException $exception) {
|
|
// ..
|
|
} catch (NotFoundExceptionInterface $exception) {
|
|
// ..
|
|
}
|
|
|
|
return $concrete;
|
|
}
|
|
}
|