Skip to content

Commit

Permalink
Remove yiisoft/aliases dependency (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Dec 28, 2024
1 parent b9bc49b commit 911877c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"psr/log": "^1.0|^2.0|^3.0",
"symfony/console": "^5.4|^6.0",
"symfony/var-dumper": "^5.4|^6.4",
"yiisoft/aliases": "^3.0",
"yiisoft/arrays": "^2.0|^3.0",
"yiisoft/config": "^1.3",
"yiisoft/di": "^1.0",
Expand Down
17 changes: 15 additions & 2 deletions config/di.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,24 @@
*/

$common = [
StorageInterface::class => static function (ContainerInterface $container, Aliases $aliases) use ($params) {
StorageInterface::class => static function (ContainerInterface $container, ?Aliases $aliases = null) use ($params) {
$params = $params['yiisoft/yii-debug'];
$debuggerIdGenerator = $container->get(DebuggerIdGenerator::class);
$excludedClasses = $params['dumper.excludedClasses'];
$fileStorage = new FileStorage($aliases->get($params['path']), $debuggerIdGenerator, $excludedClasses);

$path = $params['path'];
if (str_starts_with($path, '@')) {
if ($aliases === null) {
throw new LogicException(
sprintf(
'yiisoft/aliases dependency is required to resolve path "%s".',
$path
)
);
}
$path = $aliases->get($path);
}
$fileStorage = new FileStorage($path, $debuggerIdGenerator, $excludedClasses);

if (isset($params['historySize'])) {
$fileStorage->setHistorySize((int) $params['historySize']);
Expand Down
6 changes: 1 addition & 5 deletions tests/Unit/Storage/FileStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Yiisoft\Yii\Debug\Tests\Unit\Storage;

use Yiisoft\Aliases\Aliases;
use Yiisoft\Files\FileHelper;
use Yiisoft\Yii\Debug\DebuggerIdGenerator;
use Yiisoft\Yii\Debug\Storage\FileStorage;
Expand Down Expand Up @@ -79,9 +78,6 @@ public function testClear(array $data): void

public function getStorage(DebuggerIdGenerator $idGenerator): FileStorage
{
return new FileStorage(
(new Aliases())->get($this->path),
$idGenerator,
);
return new FileStorage($this->path, $idGenerator);
}
}

0 comments on commit 911877c

Please sign in to comment.