Skip to content

Commit

Permalink
feat: Update OpenAPI implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Oct 22, 2024
1 parent 2d4a5e9 commit 5817f4d
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 108 deletions.
5 changes: 2 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[*.html]
indent_size = 2
indent_size = 4
indent_style = space

[*.php]
indent_size = 2
tab_width = 2
indent_size = 4
indent_style = space
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/Elements/ArrayStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ArrayStructureElement extends BasicStructureElement
*
* @return self Self reference
*/
public function parse(?object $object, array &$dependencies): StructureElement
public function parse(?object $object, array &$dependencies): self
{
$this->element = $object->element ?? 'array';

Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/Elements/BasicStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class BasicStructureElement implements StructureElement
*
* @return self self reference
*/
abstract public function parse(?object $object, array &$dependencies): StructureElement;
abstract public function parse(?object $object, array &$dependencies): self;

/**
* Print a string representation.
Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Model/Elements/EnumStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class EnumStructureElement extends BasicStructureElement
*
* @return self
*/
public function parse(?object $object, array &$dependencies): StructureElement
public function parse(?object $object, array &$dependencies): self
{
$this->element = $object->element;

Expand Down
4 changes: 2 additions & 2 deletions src/PHPDraft/Model/Elements/ObjectStructureElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function __clearForTest(): void
* @param object|null $object An object to parse
* @param string[] $dependencies Dependencies of this object
*
* @return ObjectStructureElement self reference
* @return self self reference
*/
public function parse(?object $object, array &$dependencies): StructureElement
public function parse(?object $object, array &$dependencies): self
{
$this->object = $object;
if (is_null($object) || !isset($object->element) || !(isset($object->content) || isset($object->meta) )) {
Expand Down
4 changes: 2 additions & 2 deletions src/PHPDraft/Model/HTTPRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class HTTPRequest implements Comparable
/**
* Description of the request.
*
* @var string
* @var string|null
*/
public string $description = '';
public ?string $description = NULL;

/**
* Parent class.
Expand Down
14 changes: 5 additions & 9 deletions src/PHPDraft/Model/Transition.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ class Transition extends HierarchyElement
/**
* URL variables.
*
* @var StructureElement[]
* @var BasicStructureElement[]
*/
public array $url_variables = [];

/**
* Data variables.
*
* @var StructureElement|null
* @var ObjectStructureElement|BasicStructureElement|null
*/
public ?StructureElement $data_variables = null;
public ?BasicStructureElement $data_variables = null;

/**
* The request.
Expand All @@ -65,7 +65,7 @@ class Transition extends HierarchyElement
/**
* Structures used (if any).
*
* @var StructureElement[]
* @var BasicStructureElement[]
*/
public array $structures = [];

Expand Down Expand Up @@ -94,7 +94,7 @@ public function parse(object $object): self
$this->href = $href->content ?? $href;

if (isset($object->attributes->hrefVariables)) {
$deps = [];
$deps = [];
foreach ($object->attributes->hrefVariables->content as $variable) {
$struct = (new ObjectStructureElement())->get_class($variable->element);
$this->url_variables[] = $struct->parse($variable, $deps);
Expand Down Expand Up @@ -165,10 +165,6 @@ public function build_url(string $base_url = '', bool $clean = false): string
$vars = [];
if ($this->url_variables !== []) {
foreach ($this->url_variables as $item) {
if (!is_subclass_of($item, BasicStructureElement::class)) {
continue;
}

$vars[$item->key->value] = $item->string_value(true);
}
}
Expand Down
Loading

0 comments on commit 5817f4d

Please sign in to comment.