Skip to content

Commit

Permalink
Update TinkerCommand and TinkerCaster to use Stringable interface (#621)
Browse files Browse the repository at this point in the history
* Update TinkerCommand and TinkerCaster to use Stringable interface

* feat: Remove unnecessary line in TinkerCaster.php

---------

Co-authored-by: Deeka Wong <[email protected]>
  • Loading branch information
huangdijia and huangdijia authored May 11, 2024
1 parent 0929f29 commit 5552cb9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Command/TinkerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TinkerCommand extends HyperfCommand
'Hyperf\DbConnection\Model\Model' => 'FriendsOfHyperf\Tinker\TinkerCaster::castModel',
'Hyperf\Redis\Redis' => 'FriendsOfHyperf\Tinker\TinkerCaster::castRedis',
'Hyperf\Collection\Collection' => 'FriendsOfHyperf\Tinker\TinkerCaster::castCollection',
'Hyperf\Stringable\Stringable' => 'FriendsOfHyperf\Tinker\TinkerCaster::castStringable',
'Stringable' => 'FriendsOfHyperf\Tinker\TinkerCaster::castStringable',
'Hyperf\ViewEngine\HtmlString' => 'FriendsOfHyperf\Tinker\TinkerCaster::castHtmlString',
'Symfony\Component\Console\Application' => 'FriendsOfHyperf\Tinker\TinkerCaster::castApplication',
];
Expand Down
4 changes: 2 additions & 2 deletions src/TinkerCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use ReflectionException;
use ReflectionObject;
use Stringable;
use Symfony\Component\VarDumper\Caster\Caster;
use Throwable;

Expand Down Expand Up @@ -92,7 +93,7 @@ public static function castHtmlString($htmlString): array

/**
* Get an array representing the properties of a fluent string.
* @param \Hyperf\Stringable\Stringable $stringable
* @param Stringable $stringable
*/
public static function castStringable($stringable): array
{
Expand All @@ -118,7 +119,6 @@ public static function castModel($model): array
);

$hidden = array_flip($model->getHidden());

$appends = (fn () => array_combine($this->appends, $this->appends))->bindTo($model, $model)();

foreach ($appends as $appended) {
Expand Down

0 comments on commit 5552cb9

Please sign in to comment.