Skip to content

Commit 2a2a1e4

Browse files
committed
Start container cleanup
- Rename `IContainer` to `ContainerInterface` and move to `Lkrms\Container\Contract` - Rename `IApplication` to `ApplicationInterface` and move to `Lkrms\Container\Contract`
1 parent 54d3ebe commit 2a2a1e4

40 files changed

+160
-144
lines changed

src/Cli/Contract/CliApplicationInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Lkrms\Cli\Contract;
44

5-
use Lkrms\Contract\IApplication;
5+
use Lkrms\Container\Contract\ApplicationInterface;
66
use LogicException;
77

88
/**
99
* A service container for CLI applications
1010
*
1111
* @api
1212
*/
13-
interface CliApplicationInterface extends IApplication
13+
interface CliApplicationInterface extends ApplicationInterface
1414
{
1515
/**
1616
* Get the command invoked by run()

src/Concept/Builder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Lkrms\Concept;
44

5+
use Lkrms\Container\Contract\ContainerInterface;
56
use Lkrms\Container\Container;
6-
use Lkrms\Contract\IContainer;
77
use Lkrms\Contract\IImmutable;
88
use Lkrms\Support\Introspector;
99
use Lkrms\Support\ProviderContext;
@@ -33,7 +33,7 @@ protected static function getTerminators(): array
3333
return [];
3434
}
3535

36-
protected IContainer $Container;
36+
protected ContainerInterface $Container;
3737

3838
/**
3939
* @var Introspector<object,Provider,Entity,ProviderContext>
@@ -53,7 +53,7 @@ protected static function getTerminators(): array
5353
/**
5454
* Creates a new Builder object
5555
*/
56-
final public function __construct(?IContainer $container = null)
56+
final public function __construct(?ContainerInterface $container = null)
5757
{
5858
$this->Container = $container ?? Container::getGlobalContainer();
5959
$this->Introspector = Introspector::getService($this->Container, static::getService());
@@ -75,7 +75,7 @@ final public function __construct(?IContainer $container = null)
7575
*
7676
* @return static
7777
*/
78-
final public static function build(?IContainer $container = null)
78+
final public static function build(?ContainerInterface $container = null)
7979
{
8080
return new static($container);
8181
}

src/Concept/Facade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace Lkrms\Concept;
44

55
use Lkrms\Concern\ResolvesServiceLists;
6+
use Lkrms\Container\Contract\ContainerInterface;
67
use Lkrms\Container\Event\GlobalContainerSetEvent;
78
use Lkrms\Container\Container;
89
use Lkrms\Contract\FacadeAwareInterface;
910
use Lkrms\Contract\FacadeInterface;
10-
use Lkrms\Contract\IContainer;
1111
use Lkrms\Contract\Unloadable;
1212
use Lkrms\Facade\Event;
1313
use Lkrms\Support\EventDispatcher;
@@ -224,7 +224,7 @@ static function (GlobalContainerSetEvent $event) use ($serviceName, $instance):
224224
* @return TService
225225
*/
226226
private static function getInstanceFromContainer(
227-
IContainer $container,
227+
ContainerInterface $container,
228228
string $serviceName
229229
) {
230230
// If one of the services returned by the facade has been bound to the

src/Concept/Provider.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Lkrms\Concept;
44

5-
use Lkrms\Contract\IContainer;
5+
use Lkrms\Container\Contract\ContainerInterface;
66
use Lkrms\Contract\IProvider;
77
use Lkrms\Exception\MethodNotImplementedException;
88
use Lkrms\Support\Date\DateFormatterInterface;
@@ -15,14 +15,14 @@
1515
*/
1616
abstract class Provider implements IProvider
1717
{
18-
protected IContainer $App;
18+
protected ContainerInterface $App;
1919

2020
private DateFormatterInterface $DateFormatter;
2121

2222
/**
2323
* Creates a new Provider object
2424
*/
25-
public function __construct(IContainer $app)
25+
public function __construct(ContainerInterface $app)
2626
{
2727
$this->App = $app;
2828
}
@@ -39,7 +39,7 @@ abstract protected function getDateFormatter(): DateFormatterInterface;
3939
/**
4040
* @inheritDoc
4141
*/
42-
public function getContext(?IContainer $container = null): ProviderContext
42+
public function getContext(?ContainerInterface $container = null): ProviderContext
4343
{
4444
if (!$container) {
4545
$container = $this->App;
@@ -63,15 +63,15 @@ public function checkHeartbeat(int $ttl = 300)
6363
/**
6464
* @inheritDoc
6565
*/
66-
final public function app(): IContainer
66+
final public function app(): ContainerInterface
6767
{
6868
return $this->App;
6969
}
7070

7171
/**
7272
* @inheritDoc
7373
*/
74-
final public function container(): IContainer
74+
final public function container(): ContainerInterface
7575
{
7676
return $this->App;
7777
}

src/Concern/HasBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Lkrms\Concern;
44

55
use Lkrms\Concept\Builder;
6+
use Lkrms\Container\Contract\ContainerInterface;
67
use Lkrms\Contract\Buildable;
7-
use Lkrms\Contract\IContainer;
88

99
/**
1010
* Implements Buildable
@@ -18,7 +18,7 @@ public static function getBuilder(): string
1818
return static::class . 'Builder';
1919
}
2020

21-
final public static function build(?IContainer $container = null): Builder
21+
final public static function build(?ContainerInterface $container = null): Builder
2222
{
2323
return static::getBuilder()::build($container);
2424
}

src/Concern/RequiresContainer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace Lkrms\Concern;
44

5+
use Lkrms\Container\Contract\ContainerInterface;
56
use Lkrms\Container\Container;
6-
use Lkrms\Contract\IContainer;
77

88
trait RequiresContainer
99
{
10-
final protected static function requireContainer(?IContainer $container = null): IContainer
10+
final protected static function requireContainer(?ContainerInterface $container = null): ContainerInterface
1111
{
1212
return $container ?: Container::requireGlobalContainer();
1313
}

src/Concern/TConstructible.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Lkrms\Concern;
44

5+
use Lkrms\Container\Contract\ContainerInterface;
56
use Lkrms\Container\Container;
67
use Lkrms\Contract\IConstructible;
7-
use Lkrms\Contract\IContainer;
88
use Lkrms\Contract\IExtensible;
99
use Lkrms\Contract\ITreeable;
1010
use Lkrms\Support\Catalog\ArrayKeyConformity;
@@ -30,13 +30,14 @@ trait TConstructible
3030
* normalised for comparison.
3131
*
3232
* @param mixed[] $data
33-
* @param IContainer|null $container Used to create the instance if set.
33+
* @param ContainerInterface|null $container Used to create the instance if
34+
* set.
3435
* @param (ITreeable&static)|null $parent If the class implements
3536
* {@see ITreeable}, pass `$parent` to the instance via
3637
* {@see ITreeable::setParent()}.
3738
* @return static
3839
*/
39-
final public static function construct(array $data, ?IContainer $container = null, $parent = null)
40+
final public static function construct(array $data, ?ContainerInterface $container = null, $parent = null)
4041
{
4142
if (!$container) {
4243
$container = Container::requireGlobalContainer();
@@ -54,7 +55,8 @@ final public static function construct(array $data, ?IContainer $container = nul
5455
* @param iterable<mixed[]> $list
5556
* @param ArrayKeyConformity::* $conformity Use `COMPLETE` or `PARTIAL`
5657
* wherever possible to improve performance.
57-
* @param IContainer|null $container Used to create each instance if set.
58+
* @param ContainerInterface|null $container Used to create each instance if
59+
* set.
5860
* @param (ITreeable&static)|null $parent If the class implements
5961
* {@see ITreeable}, pass `$parent` to each instance via
6062
* {@see ITreeable::setParent()}.
@@ -63,7 +65,7 @@ final public static function construct(array $data, ?IContainer $container = nul
6365
final public static function constructList(
6466
iterable $list,
6567
$conformity = ArrayKeyConformity::NONE,
66-
?IContainer $container = null,
68+
?ContainerInterface $container = null,
6769
$parent = null
6870
): Generator {
6971
if (!$container) {

src/Concern/TProvidable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Lkrms\Concern;
44

5-
use Lkrms\Contract\IContainer;
5+
use Lkrms\Container\Contract\ContainerInterface;
66
use Lkrms\Contract\IExtensible;
77
use Lkrms\Contract\IProvidable;
88
use Lkrms\Contract\IProvider;
@@ -143,7 +143,7 @@ final public static function provide(
143143
IProvider $provider,
144144
?IProviderContext $context = null
145145
) {
146-
/** @var IContainer */
146+
/** @var ContainerInterface */
147147
$container = $context
148148
? $context->container()
149149
: $provider->container();
@@ -195,7 +195,7 @@ private static function _provideList(
195195
$conformity,
196196
?IProviderContext $context
197197
): Generator {
198-
/** @var IContainer */
198+
/** @var ContainerInterface */
199199
$container = $context
200200
? $context->container()
201201
: $provider->container();

src/Container/Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Lkrms\Console\Catalog\ConsoleLevelGroup as LevelGroup;
77
use Lkrms\Console\Catalog\ConsoleMessageType as MessageType;
88
use Lkrms\Console\Target\StreamTarget;
9-
use Lkrms\Contract\IApplication;
9+
use Lkrms\Container\Contract\ApplicationInterface;
1010
use Lkrms\Exception\FilesystemErrorException;
1111
use Lkrms\Exception\InvalidEnvironmentException;
1212
use Lkrms\Facade\Cache;
@@ -33,7 +33,7 @@
3333
/**
3434
* A service container for applications
3535
*/
36-
class Application extends Container implements IApplication
36+
class Application extends Container implements ApplicationInterface
3737
{
3838
private const DIR_CONFIG = 'CONFIG';
3939
private const DIR_DATA = 'DATA';

src/Container/Container.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
use Dice\Dice;
66
use Dice\DiceException;
77
use Lkrms\Concept\FluentInterface;
8+
use Lkrms\Container\Contract\ContainerInterface;
89
use Lkrms\Container\Event\GlobalContainerSetEvent;
910
use Lkrms\Container\Exception\ContainerNotLocatedException;
1011
use Lkrms\Container\Exception\ContainerServiceNotFoundException;
1112
use Lkrms\Container\Exception\InvalidContainerBindingException;
12-
use Lkrms\Contract\IContainer;
1313
use Lkrms\Contract\IService;
1414
use Lkrms\Contract\IServiceShared;
1515
use Lkrms\Contract\IServiceSingleton;
1616
use Lkrms\Contract\ReceivesContainer;
1717
use Lkrms\Contract\ReceivesService;
1818
use Lkrms\Facade\DI;
1919
use Lkrms\Facade\Event;
20-
use Psr\Container\ContainerInterface;
20+
use Psr\Container\ContainerInterface as PsrContainerInterface;
2121
use Closure;
2222
use ReflectionClass;
2323

@@ -26,9 +26,9 @@
2626
*
2727
* A static interface to the global service container is provided by {@see DI}.
2828
*/
29-
class Container extends FluentInterface implements IContainer
29+
class Container extends FluentInterface implements ContainerInterface
3030
{
31-
private static ?IContainer $GlobalContainer = null;
31+
private static ?ContainerInterface $GlobalContainer = null;
3232

3333
private Dice $Dice;
3434

@@ -76,7 +76,7 @@ private function bindContainer(): void
7676

7777
// Bind any interfaces that extend PSR-11's ContainerInterface
7878
foreach ($class->getInterfaces() as $name => $interface) {
79-
if ($interface->implementsInterface(ContainerInterface::class)) {
79+
if ($interface->implementsInterface(PsrContainerInterface::class)) {
8080
$this->instance($name, $this);
8181
}
8282
}
@@ -118,7 +118,7 @@ final public static function hasGlobalContainer(): bool
118118
/**
119119
* @inheritDoc
120120
*/
121-
final public static function getGlobalContainer(): IContainer
121+
final public static function getGlobalContainer(): ContainerInterface
122122
{
123123
if (self::$GlobalContainer !== null) {
124124
return self::$GlobalContainer;
@@ -130,7 +130,7 @@ final public static function getGlobalContainer(): IContainer
130130
/**
131131
* Get the global container if it exists
132132
*/
133-
final public static function maybeGetGlobalContainer(): ?IContainer
133+
final public static function maybeGetGlobalContainer(): ?ContainerInterface
134134
{
135135
return self::$GlobalContainer;
136136
}
@@ -141,7 +141,7 @@ final public static function maybeGetGlobalContainer(): ?IContainer
141141
* @throws ContainerNotLocatedException if the global container does not
142142
* exist.
143143
*/
144-
final public static function requireGlobalContainer(): IContainer
144+
final public static function requireGlobalContainer(): ContainerInterface
145145
{
146146
if (self::$GlobalContainer === null) {
147147
throw new ContainerNotLocatedException();
@@ -153,7 +153,7 @@ final public static function requireGlobalContainer(): IContainer
153153
/**
154154
* @inheritDoc
155155
*/
156-
final public static function setGlobalContainer(?IContainer $container): ?IContainer
156+
final public static function setGlobalContainer(?ContainerInterface $container): ?ContainerInterface
157157
{
158158
Event::dispatch(new GlobalContainerSetEvent($container));
159159

0 commit comments

Comments
 (0)