diff --git a/src/TinkerCaster.php b/src/TinkerCaster.php index 4dc8b8f..ee31b50 100644 --- a/src/TinkerCaster.php +++ b/src/TinkerCaster.php @@ -11,12 +11,14 @@ namespace FriendsOfHyperf\Tinker; -use ReflectionException; -use ReflectionObject; use Stringable; use Symfony\Component\VarDumper\Caster\Caster; use Throwable; +/** + * @property string $poolName + * @property array appends + */ class TinkerCaster { /** @@ -149,15 +151,13 @@ public static function castModel($model): array * * @param \Hyperf\Redis\Redis $redis * @return string[] - * @throws ReflectionException */ public static function castRedis($redis): array { - $refObject = new ReflectionObject($redis); - $refProperty = $refObject->getProperty('poolName'); + $poolName = (fn () => $this->poolName ?? 'default')->call($redis); return [ - Caster::PREFIX_PROTECTED . 'poolName' => (string) $refProperty->getValue($redis), + Caster::PREFIX_PROTECTED . 'poolName' => $poolName, ]; } }