Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed invalid OpenAPI spec when returning no content response #289

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Infer/Definition/ClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getPropertyDefinition($name)
return $this->properties[$name] ?? null;
}

public function getMethodCallType(string $name, ObjectType $calledOn = null)
public function getMethodCallType(string $name, ?ObjectType $calledOn = null)
{
$methodDefinition = $this->methods[$name] ?? null;

Expand Down
2 changes: 1 addition & 1 deletion src/Infer/Scope/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function setType(Node $node, Type $type)
return $type;
}

public function createChildScope(ScopeContext $context = null)
public function createChildScope(?ScopeContext $context = null)
{
return new Scope(
$this->index,
Expand Down
2 changes: 1 addition & 1 deletion src/Infer/Services/ReferenceTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private function getFunctionCallResult(
FunctionLikeDefinition $callee,
array $arguments,
/* When this is a handling for method call */
ObjectType|SelfType $calledOnType = null,
ObjectType|SelfType|null $calledOnType = null,
) {
$returnType = $callee->type->getReturnType();
$isSelf = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Generator/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function toArray()

$content = [];
foreach ($this->content as $mediaType => $schema) {
$content[$mediaType] = $schema ? ['schema' => $schema->toArray()] : [];
$content[$mediaType] = $schema ? ['schema' => $schema->toArray()] : (object) [];
}

$result['content'] = $content;
Expand Down
4 changes: 2 additions & 2 deletions src/Support/Generator/ServerVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ServerVariable
public function __construct(
string $default,
array $enum = [],
string $description = null
?string $description = null
) {
$this->default = $default;
$this->enum = $enum;
Expand All @@ -23,7 +23,7 @@ public function __construct(
public static function make(
string $default,
array $enum = [],
string $description = null
?string $description = null
) {
return new self($default, $enum, $description);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Generator/UniqueNamesOptionsCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function push(UniqueNameOptions $name)
return $this;
}

public function getUniqueName(UniqueNameOptions $name, callable $onNotUniqueFallback = null): string
public function getUniqueName(UniqueNameOptions $name, ?callable $onNotUniqueFallback = null): string
{
if ($name->eloquent && count($this->eloquentNames[$name->eloquent]) === 1) {
return $name->eloquent;
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Type/TypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function createTypeFromTypeNode(Node $typeNode)
* @param Node\Arg[] $args
* @param array{0: string, 1: int} $parameterNameIndex
*/
public static function getArgType(Scope $scope, array $args, array $parameterNameIndex, Type $default = null)
public static function getArgType(Scope $scope, array $args, array $parameterNameIndex, ?Type $default = null)
{
$default = $default ?: new UnknownType("Cannot get a type of the arg #{$parameterNameIndex[1]}($parameterNameIndex[0])");

Expand Down