瀏覽代碼

ensure has type

Joachim M. Giæver 2 年之前
父節點
當前提交
50af2a5dc5
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/AbstractPostSerializable.php

+ 3 - 2
src/AbstractPostSerializable.php

@@ -31,14 +31,15 @@ abstract class AbstractPostSerializable implements PostSerializableInterface {
         foreach ((new ReflectionClass(static::class))->getConstructor()->getParameters() as $param) {
             if ($short)
                 $vars[$param->getName()] = (object)[
-                    'type' => $param->getType(),
+                    'type' => !is_null($param->getType()) ? $param->getType()->getName() : 'mixed',
                     'required' => !($param->isOptional() || $param->allowsNull())
                 ];
             else
                 $vars[sprintf('%s-%s', static::namespace(), $param->getName())] = (object)[
-                    'type' => $param->getType(),
+                    'type' => !is_null($param->getType()) ? $param->getType()->getName() : 'mixed',
                     'required' => !($param->isOptional() || $param->allowsNull())
                 ];
+
         }
 
         return $vars;