vendor/nelmio/api-doc-bundle/src/PropertyDescriber/NullablePropertyDescriber.php line 21

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the NelmioApiDocBundle package.
  4. *
  5. * (c) Nelmio
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Nelmio\ApiDocBundle\PropertyDescriber;
  11. use OpenApi\Annotations as OA;
  12. use OpenApi\Generator;
  13. final class NullablePropertyDescriber implements PropertyDescriberInterface, PropertyDescriberAwareInterface
  14. {
  15. use PropertyDescriberAwareTrait;
  16. public function describe(array $types, OA\Schema $property, array $groups = null, ?OA\Schema $schema = null, array $context = [])
  17. {
  18. if (Generator::UNDEFINED === $property->nullable) {
  19. $property->nullable = true;
  20. }
  21. $this->propertyDescriber->describe($types, $property, $groups, $schema, $context);
  22. }
  23. public function supports(array $types): bool
  24. {
  25. foreach ($types as $type) {
  26. if ($type->isNullable()) {
  27. return true;
  28. }
  29. }
  30. return false;
  31. }
  32. }