File tree Expand file tree Collapse file tree 4 files changed +31
-31
lines changed
Expand file tree Collapse file tree 4 files changed +31
-31
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 44
55use Psy \Configuration as ConfigurationAlias ;
66use Psy \VersionUpdater \Checker ;
7- use TweakPHP \Client \Casters \LaravelCaster ;
87use TweakPHP \Client \OutputModifiers \CustomOutputModifier ;
98use TweakPHP \Client \Psy \Configuration ;
109use TweakPHP \Client \Tinker ;
@@ -28,7 +27,7 @@ public function init(): void
2827 $ config ->setHistoryFile (defined ('PHP_WINDOWS_VERSION_BUILD ' ) ? 'null ' : '/dev/null ' );
2928 $ config ->setUsePcntl (false );
3029
31- $ config ->getPresenter ()->addCasters (LaravelCaster:: casters ());
30+ $ config ->getPresenter ()->addCasters ($ this -> casters ());
3231
3332 $ this ->tinker = new Tinker (new CustomOutputModifier , $ config );
3433 }
@@ -37,4 +36,9 @@ public function execute(string $code): array
3736 {
3837 return $ this ->tinker ->execute ($ code );
3938 }
39+
40+ public function casters (): array
41+ {
42+ return [];
43+ }
4044}
Original file line number Diff line number Diff line change @@ -27,4 +27,27 @@ public function version(): string
2727 {
2828 return $ this ->app ->version ();
2929 }
30+
31+ public function casters (): array
32+ {
33+ $ casters = [
34+ 'Illuminate\Support\Collection ' => 'Laravel\Tinker\TinkerCaster::castCollection ' ,
35+ 'Illuminate\Support\HtmlString ' => 'Laravel\Tinker\TinkerCaster::castHtmlString ' ,
36+ 'Illuminate\Support\Stringable ' => 'Laravel\Tinker\TinkerCaster::castStringable ' ,
37+ ];
38+
39+ if (class_exists ('Illuminate\Database\Eloquent\Model ' )) {
40+ $ casters ['Illuminate\Database\Eloquent\Model ' ] = 'Laravel\Tinker\TinkerCaster::castModel ' ;
41+ }
42+
43+ if (class_exists ('Illuminate\Process\ProcessResult ' )) {
44+ $ casters ['Illuminate\Process\ProcessResult ' ] = 'Laravel\Tinker\TinkerCaster::castProcessResult ' ;
45+ }
46+
47+ if (class_exists ('Illuminate\Foundation\Application ' )) {
48+ $ casters ['Illuminate\Foundation\Application ' ] = 'Laravel\Tinker\TinkerCaster::castApplication ' ;
49+ }
50+
51+ return $ casters ;
52+ }
3053}
Original file line number Diff line number Diff line change @@ -13,4 +13,6 @@ public function version(): string;
1313 public function init (): void ;
1414
1515 public function execute (string $ code ): array ;
16+
17+ public function casters (): array ;
1618}
You can’t perform that action at this time.
0 commit comments