Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Add a DTO for argument data.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbillion committed Jul 10, 2024
1 parent 1b20c3b commit 5fd8b49
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
14 changes: 14 additions & 0 deletions lib/class-argument-data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace WP_Parser;

final readonly class ArgumentData extends DTO {
/**
* @param array<int, mixed> $tags
*/
public function __construct(
public string $name,
public ?string $default,
public string $type,
) {}
}
12 changes: 6 additions & 6 deletions lib/runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ function export_docblock( Property|Method|Hook|File|Function_|Class_ $element )
/**
* @param \phpDocumentor\Reflection\Php\Argument[] $arguments
*
* @return array
* @return array<int, ArgumentData>
*/
function export_arguments( array $arguments ) {
function export_arguments( array $arguments ) : array {
$output = array();

foreach ( $arguments as $argument ) {
$output[] = array(
'name' => '$' . $argument->getName(),
'default' => $argument->getDefault(),
'type' => (string) $argument->getType(),
$output[] = new ArgumentData(
'$' . $argument->getName(),
$argument->getDefault(),
(string) $argument->getType(),
);
}

Expand Down

0 comments on commit 5fd8b49

Please sign in to comment.