From a1abb7812b7e3e09b595d1b4f2a52d85601289c9 Mon Sep 17 00:00:00 2001
From: DerManoMann <mano@radebatz.net>
Date: Thu, 25 Jan 2024 10:58:01 +1300
Subject: [PATCH] Enforce strict nullable typehint

---
 .php-cs-fixer.dist.php      | 2 ++
 src/Analysis.php            | 2 +-
 src/Annotations/OpenApi.php | 2 +-
 src/Attributes/Response.php | 2 +-
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index 2c8cc1c3..438004aa 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -63,6 +63,8 @@
         'fully_qualified_strict_types' => true,
         'global_namespace_import' => ['import_classes' => false, 'import_constants' => null, 'import_functions' => null],
 
+        'nullable_type_declaration_for_default_null_value' => true,
+
         'no_empty_phpdoc' => true,
         // 7.3 only 'no_superfluous_phpdoc_tags' => true,
         'phpdoc_align' => true,
diff --git a/src/Analysis.php b/src/Analysis.php
index b3de6b7f..52c6e3ab 100644
--- a/src/Analysis.php
+++ b/src/Analysis.php
@@ -62,7 +62,7 @@ class Analysis
      */
     public $context = null;
 
-    public function __construct(array $annotations = [], Context $context = null)
+    public function __construct(array $annotations = [], ?Context $context = null)
     {
         $this->annotations = new \SplObjectStorage();
         $this->context = $context;
diff --git a/src/Annotations/OpenApi.php b/src/Annotations/OpenApi.php
index d367c1d6..267d607c 100644
--- a/src/Annotations/OpenApi.php
+++ b/src/Annotations/OpenApi.php
@@ -137,7 +137,7 @@ class OpenApi extends AbstractAnnotation
     /**
      * @inheritdoc
      */
-    public function validate(array $stack = null, array $skip = null, string $ref = '', $context = null): bool
+    public function validate(?array $stack = null, ?array $skip = null, string $ref = '', $context = null): bool
     {
         if ($stack !== null || $skip !== null || $ref !== '') {
             $this->_context->logger->warning('Nested validation for ' . $this->identity() . ' not allowed');
diff --git a/src/Attributes/Response.php b/src/Attributes/Response.php
index b79b16d2..56217d08 100644
--- a/src/Attributes/Response.php
+++ b/src/Attributes/Response.php
@@ -22,7 +22,7 @@ class Response extends OA\Response
      */
     public function __construct(
         string|object|null $ref = null,
-        int|string $response = null,
+        int|string|null $response = null,
         ?string $description = null,
         ?array $headers = null,
         MediaType|JsonContent|XmlContent|Attachable|array|null $content = null,