Skip to content

Commit ec21679

Browse files
authored
Centralize all pure JSON Schema properties (#1960)
1 parent 9a0a612 commit ec21679

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+785
-581
lines changed

docs/examples/specs/api/attributes/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Product implements ProductInterface
3232
public function __construct(
3333
#[OAT\Property]
3434
public int $quantity,
35-
#[OAT\Property(default: null, example: null)]
35+
#[OAT\Property(example: null, default: null)]
3636
public ?string $brand,
3737
#[OAT\Property(description: 'The colour')]
3838
public Colour $colour,

docs/examples/specs/api/mixed/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getQuantity(): int
4040
return 1;
4141
}
4242

43-
#[OAT\Property(default: null, example: null, nullable: true)]
43+
#[OAT\Property(example: null, nullable: true, default: null)]
4444
public string $brand;
4545

4646
/** @OA\Property(description="The colour") */

docs/examples/specs/polymorphism/attributes/AbstractResponsible.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ abstract class AbstractResponsible
2222
{
2323
protected const TYPE = null;
2424

25-
#[OAT\Property(enum: ['employee', 'assignee', 'fl'], nullable: false)]
25+
#[OAT\Property(nullable: false, enum: ['employee', 'assignee', 'fl'])]
2626
protected string $type;
2727

2828
public function __construct()

src/Analysers/AttributeAnnotationFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function build(\Reflector $reflector, Context $context): array
4242
// no proper way to inject
4343
Generator::$context = $context;
4444

45-
/** @var OA\AbstractAnnotation[] $annotations */
45+
/** @var list<OA\AbstractAnnotation> $annotations */
4646
$annotations = [];
4747
try {
4848
$attributeName = $this->ignoreOtherAttributes

src/Analysers/TokenScanner.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,21 @@
1717
use PhpParser\ParserFactory;
1818

1919
/**
20-
* High level, PHP token based, scanner.
20+
* High-level, PHP-token-based, scanner.
2121
*/
2222
class TokenScanner
2323
{
2424
/**
25-
* Scan file for all classes, interfaces and traits.
25+
* Scan a given file for all classes, interfaces, and traits.
2626
*
27-
* @return string[][] File details
27+
* @return array{
28+
* 'uses': array<string, class-string>,
29+
* 'interfaces': list<class-string>,
30+
* 'traits': list<class-string>,
31+
* 'enums': list<class-string>,
32+
* 'methods': list<string>,
33+
* 'properties': list<string>,
34+
* } File details
2835
*/
2936
public function scanFile(string $filename): array
3037
{

src/Annotations/AbstractAnnotation.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ abstract class AbstractAnnotation implements \JsonSerializable
4646
/**
4747
* The properties which are required by [the spec](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md).
4848
*
49-
* @var string[]
49+
* @var list<string>
5050
*/
5151
public static $_required = [];
5252

@@ -144,10 +144,10 @@ public function __construct(array $properties)
144144
*
145145
* Annotations that couldn't be merged are added to the _unmerged array.
146146
*
147-
* @param AbstractAnnotation[] $annotations
148-
* @param bool $ignore Ignore unmerged annotations
147+
* @param list<AbstractAnnotation> $annotations
148+
* @param bool $ignore Ignore unmerged annotations
149149
*
150-
* @return AbstractAnnotation[] The unmerged annotations
150+
* @return list<AbstractAnnotation> The unmerged annotations
151151
*/
152152
public function merge(array $annotations, bool $ignore = false): array
153153
{
@@ -777,7 +777,7 @@ protected function combine(...$args): array
777777
*
778778
* @param array|object|string $classes Class(es) to shorten
779779
*
780-
* @return string|string[] One or more shortened class names
780+
* @return string|list<string> One or more shortened class names
781781
*/
782782
protected static function shorten($classes)
783783
{

src/Annotations/Components.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ class Components extends AbstractAnnotation
3939
/**
4040
* Reusable Responses.
4141
*
42-
* @var Response[]
42+
* @var list<Response>
4343
*/
4444
public $responses = Generator::UNDEFINED;
4545

4646
/**
4747
* Reusable Parameters.
4848
*
49-
* @var Parameter[]
49+
* @var list<Parameter>
5050
*/
5151
public $parameters = Generator::UNDEFINED;
5252

@@ -60,28 +60,28 @@ class Components extends AbstractAnnotation
6060
/**
6161
* Reusable Request Bodies.
6262
*
63-
* @var RequestBody[]
63+
* @var list<RequestBody>
6464
*/
6565
public $requestBodies = Generator::UNDEFINED;
6666

6767
/**
6868
* Reusable Headers.
6969
*
70-
* @var Header[]
70+
* @var list<Header>
7171
*/
7272
public $headers = Generator::UNDEFINED;
7373

7474
/**
7575
* Reusable Security Schemes.
7676
*
77-
* @var SecurityScheme[]
77+
* @var list<SecurityScheme>
7878
*/
7979
public $securitySchemes = Generator::UNDEFINED;
8080

8181
/**
8282
* Reusable Links.
8383
*
84-
* @var Link[]
84+
* @var list<Link>
8585
*/
8686
public $links = Generator::UNDEFINED;
8787

src/Annotations/Discriminator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Discriminator extends AbstractAnnotation
3232
/**
3333
* An object to hold mappings between payload values and schema names or references.
3434
*
35-
* @var string[]
35+
* @var array<string,string>
3636
*/
3737
public $mapping = Generator::UNDEFINED;
3838

src/Annotations/Encoding.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Encoding extends AbstractAnnotation
3434
/**
3535
* Additional headers.
3636
*
37-
* @var Header[]
37+
* @var list<Header>
3838
*/
3939
public $headers = Generator::UNDEFINED;
4040

src/Annotations/JsonContent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class JsonContent extends Schema
3535
/**
3636
* A map between a property name and its encoding information.
3737
*
38-
* @var Encoding[]
38+
* @var list<Encoding>
3939
*/
4040
public $encoding = Generator::UNDEFINED;
4141

0 commit comments

Comments
 (0)