Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
romalytvynenko authored and github-actions[bot] committed Aug 22, 2022
1 parent 7e4a296 commit d919015
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 26 deletions.
2 changes: 0 additions & 2 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
use Dedoc\Scramble\Support\TypeHandlers\TypeHandlers;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Route as RouteFacade;
use Illuminate\Support\Str;
use Illuminate\Support\Stringable;
use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
Expand Down
1 change: 1 addition & 0 deletions src/Support/Generator/Types/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function setHint(string $hint): Type
public function enum(array $enum): Type
{
$this->enum = $enum;

return $this;
}
}
47 changes: 23 additions & 24 deletions src/Support/Generator/Types/TypeAttributes.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
<?php


namespace Dedoc\Scramble\Support\Generator\Types;

trait TypeAttributes
{
/** @var array<string, mixed> */
private $attributes = [];
/** @var array<string, mixed> */
private $attributes = [];

/**
* @param mixed $value
*/
public function setAttribute(string $key, $value): void
{
$this->attributes[$key] = $value;
}
/**
* @param mixed $value
*/
public function setAttribute(string $key, $value): void
{
$this->attributes[$key] = $value;
}

public function hasAttribute(string $key): bool
{
return array_key_exists($key, $this->attributes);
}
public function hasAttribute(string $key): bool
{
return array_key_exists($key, $this->attributes);
}

/**
* @return mixed
*/
public function getAttribute(string $key)
{
if ($this->hasAttribute($key)) {
return $this->attributes[$key];
}
/**
* @return mixed
*/
public function getAttribute(string $key)
{
if ($this->hasAttribute($key)) {
return $this->attributes[$key];
}

return null;
}
return null;
}
}
1 change: 1 addition & 0 deletions src/Support/RulesExtractor/RulesMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function exists(Type $type, $params)
if (in_array('id', $params)) {
return $this->int($type);
}

return $type;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Support/RulesExtractor/RulesToParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class RulesToParameter
{
private string $name;

private array $rules = [];

const RULES_PRIORITY = [
Expand All @@ -33,6 +34,7 @@ public function generate()
if (is_string($rule)) {
return $this->getTypeFromRule($type, $rule);
}

return method_exists($rule, 'docs')
? $rule->docs($type)
: $type;
Expand Down
1 change: 1 addition & 0 deletions src/Support/TypeHandlers/UnionTypeNodeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function handle(): ?Type

if (count($types) === 2 && collect($types)->contains(fn (Type $t) => $t instanceof NullType)) {
$nonNullType = collect($types)->reject(fn (Type $t) => $t instanceof NullType)->first();

return $nonNullType->nullable(true);
}

Expand Down

0 comments on commit d919015

Please sign in to comment.