Преглед на файлове

Support nullable and union responseField types

shalvah преди 3 години
родител
ревизия
1d131b276d
променени са 1 файла, в които са добавени 2 реда и са изтрити 1 реда
  1. 2 1
      src/Extracting/Strategies/ResponseFields/GetFromResponseFieldTag.php

+ 2 - 1
src/Extracting/Strategies/ResponseFields/GetFromResponseFieldTag.php

@@ -52,7 +52,8 @@ class GetFromResponseFieldTag extends Strategy
                 $type = $this->normalizeTypeName($type);
 
                 // Support optional type in annotation
-                if (!$this->isSupportedTypeInDocBlocks($type)) {
+                // The type can also be a union or nullable type (eg ?string or string|null)
+                if (!$this->isSupportedTypeInDocBlocks(explode('|', trim($type, '?'))[0])) {
                     // Then that wasn't a type, but part of the description
                     $description = trim("$type $description");
                     $type = '';