diff --git a/src/Command/TinkerCommand.php b/src/Command/TinkerCommand.php index b9ed2ba..a1bb6c8 100644 --- a/src/Command/TinkerCommand.php +++ b/src/Command/TinkerCommand.php @@ -42,11 +42,13 @@ class TinkerCommand extends HyperfCommand * @var string[] */ protected array $defaultCasters = [ + 'Hyperf\Collection\Collection' => 'FriendsOfHyperf\Tinker\TinkerCaster::castCollection', 'Hyperf\DbConnection\Model\Model' => 'FriendsOfHyperf\Tinker\TinkerCaster::castModel', 'Hyperf\Redis\Redis' => 'FriendsOfHyperf\Tinker\TinkerCaster::castRedis', - 'Hyperf\Collection\Collection' => 'FriendsOfHyperf\Tinker\TinkerCaster::castCollection', - 'Stringable' => 'FriendsOfHyperf\Tinker\TinkerCaster::castStringable', + 'Hyperf\Support\Fluent' => 'FriendsOfHyperf\Tinker\TinkerCaster::castFluent', + 'Hyperf\Support\MessageBag' => 'FriendsOfHyperf\Tinker\TinkerCaster::castMessageBag', 'Hyperf\ViewEngine\HtmlString' => 'FriendsOfHyperf\Tinker\TinkerCaster::castHtmlString', + 'Stringable' => 'FriendsOfHyperf\Tinker\TinkerCaster::castStringable', 'Symfony\Component\Console\Application' => 'FriendsOfHyperf\Tinker\TinkerCaster::castApplication', ]; diff --git a/src/TinkerCaster.php b/src/TinkerCaster.php index ee31b50..b4f63bd 100644 --- a/src/TinkerCaster.php +++ b/src/TinkerCaster.php @@ -17,7 +17,7 @@ /** * @property string $poolName - * @property array appends + * @property array $appends */ class TinkerCaster { @@ -160,4 +160,29 @@ public static function castRedis($redis): array Caster::PREFIX_PROTECTED . 'poolName' => $poolName, ]; } + + /** + * Get an array representing the properties of a fluent. + * + * @param \Hyperf\Support\Fluent $fluent + */ + public static function castFluent($fluent): array + { + return [ + Caster::PREFIX_PROTECTED . 'attributes' => $fluent->getAttributes(), + ]; + } + + /** + * Get an array representing the properties of a message bag. + * + * @param \Hyperf\Support\MessageBag $messageBag + */ + public static function castMessageBag($messageBag): array + { + return [ + Caster::PREFIX_PROTECTED . 'messages' => $messageBag->getMessages(), + Caster::PREFIX_PROTECTED . 'format' => $messageBag->getFormat(), + ]; + } }