Skip to content

Commit 112bbbb

Browse files
committed
fix: 更新 Tinker 类中的类型转换器,添加更多支持的类
1 parent 7f7c3b6 commit 112bbbb

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/Tinker.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@
1313

1414
use FriendsOfHyperf\Tinker\ClassAliasAutoloader;
1515
use FriendsOfHyperf\WebTinker\OutputModifiers\OutputModifier;
16-
use Hyperf\Collection\Collection;
17-
use Hyperf\Database\Model\Model;
1816
use Psy\Configuration;
1917
use Psy\Shell;
20-
use Symfony\Component\Console\Application;
2118
use Symfony\Component\Console\Output\BufferedOutput;
2219

2320
use function Hyperf\Collection\collect;
@@ -75,10 +72,16 @@ protected function createShell(BufferedOutput $output): Shell
7572
$config->setHistoryFile(defined('PHP_WINDOWS_VERSION_BUILD') ? 'null' : '/dev/null');
7673

7774
$config->getPresenter()->addCasters([
78-
Collection::class => 'FriendsOfHyperf\Tinker\TinkerCaster::castCollection',
79-
Model::class => 'FriendsOfHyperf\Tinker\TinkerCaster::castModel',
80-
Application::class => 'FriendsOfHyperf\Tinker\TinkerCaster::castApplication',
81-
]);
75+
'Hyperf\Collection\Collection' => 'FriendsOfHyperf\Tinker\TinkerCaster::castCollection',
76+
'Hyperf\DbConnection\Model\Model' => 'FriendsOfHyperf\Tinker\TinkerCaster::castModel',
77+
'Hyperf\Redis\Redis' => 'FriendsOfHyperf\Tinker\TinkerCaster::castRedis',
78+
'Hyperf\Support\Fluent' => 'FriendsOfHyperf\Tinker\TinkerCaster::castFluent',
79+
'Hyperf\Support\MessageBag' => 'FriendsOfHyperf\Tinker\TinkerCaster::castMessageBag',
80+
'Hyperf\ViewEngine\HtmlString' => 'FriendsOfHyperf\Tinker\TinkerCaster::castHtmlString',
81+
'Stringable' => 'FriendsOfHyperf\Tinker\TinkerCaster::castStringable',
82+
'Symfony\Component\Console\Application' => 'FriendsOfHyperf\Tinker\TinkerCaster::castApplication',
83+
'FriendsOfHyperf\ValidatedDTO\SimpleDTO' => 'FriendsOfHyperf\Tinker\TinkerCaster::castSimpleDTO',
84+
] + config('tinker.casters', []));
8285

8386
$shell = new Shell($config);
8487

0 commit comments

Comments
 (0)