Skip to content

Commit

Permalink
Enforce strict nullable typehint (#1538)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann authored Jan 24, 2024
1 parent 9443abf commit e397ca8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Analysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Annotations/OpenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Attributes/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e397ca8

Please sign in to comment.