Browse Source

ensure has type

Joachim M. Giæver 2 years ago
parent
commit
50af2a5dc5
1 changed files with 3 additions and 2 deletions
  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;