1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace BEAR\Resource; |
6
|
|
|
|
7
|
|
|
use BEAR\Resource\Annotation\Embed; |
8
|
|
|
use BEAR\Resource\Annotation\Link; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Type definitions for BEAR.Resource |
12
|
|
|
* |
13
|
|
|
* @phpcs:disable SlevomatCodingStandard.Commenting.DocCommentSpacing |
14
|
|
|
* |
15
|
|
|
* Domain Types |
16
|
|
|
* @psalm-type ResourceUri = non-empty-string |
17
|
|
|
* @psalm-type ResourceMethod = non-empty-string |
18
|
|
|
* @psalm-type ViewName = non-empty-string |
19
|
|
|
* @psalm-type ResourceClassName = class-string<ResourceObject> |
20
|
|
|
* |
21
|
|
|
* Base Types |
22
|
|
|
* @psalm-type Query = array<string, mixed> |
23
|
|
|
* @psalm-type StringList = list<string> |
24
|
|
|
* @psalm-type Body = array<array-key, mixed> |
25
|
|
|
* @psalm-type ResourceLinks = array<string, mixed> |
26
|
|
|
* @psalm-type Embeds = array<string, mixed> |
27
|
|
|
* @psalm-type Schema = array<array-key, mixed> |
28
|
|
|
* |
29
|
|
|
* Options Method Types |
30
|
|
|
* @psalm-type ParameterMetadata = array{ |
31
|
|
|
* type?: string, |
32
|
|
|
* description?: string, |
33
|
|
|
* default?: string, |
34
|
|
|
* in?: string |
35
|
|
|
* } |
36
|
|
|
* @psalm-type ParametersMap = array<string, ParameterMetadata> |
37
|
|
|
* @psalm-type RequiredParameters = list<string> |
38
|
|
|
* @psalm-type OptionsResponse = array{ |
39
|
|
|
* parameters?: ParametersMap, |
40
|
|
|
* required?: RequiredParameters |
41
|
|
|
* } |
42
|
|
|
* @psalm-type OptionsDocumentation = array{ |
43
|
|
|
* summary?: string, |
44
|
|
|
* description?: string |
45
|
|
|
* } |
46
|
|
|
* @psalm-type OptionsDocBlock = array{ |
47
|
|
|
* 0: OptionsDocumentation, |
48
|
|
|
* 1: array<string, array{type: string, description?: string}> |
49
|
|
|
* } |
50
|
|
|
* @psalm-type EmbedList = non-empty-list<Embed> |
51
|
|
|
* @psalm-type LinkList = non-empty-list<Link> |
52
|
|
|
* @psalm-type SchemaArray = non-empty-array<array-key, mixed> |
53
|
|
|
* @psalm-type OptionsMethodsResponse = array{ |
54
|
|
|
* summary?: string, |
55
|
|
|
* description?: string, |
56
|
|
|
* request?: OptionsResponse, |
57
|
|
|
* links?: LinkList, |
58
|
|
|
* embed?: EmbedList, |
59
|
|
|
* schema?: SchemaArray |
60
|
|
|
* } |
61
|
|
|
* |
62
|
|
|
* HTTP Request/Response Types |
63
|
|
|
* @psalm-type Headers = array<string, string> |
64
|
|
|
* @psalm-type HttpHeaders = array<string, string> |
65
|
|
|
* @psalm-type HttpBody = array<mixed> |
66
|
|
|
* @psalm-type HttpResponse = array{ |
67
|
|
|
* body: HttpBody, |
68
|
|
|
* code: int, |
69
|
|
|
* headers: HttpHeaders, |
70
|
|
|
* view: string |
71
|
|
|
* } |
72
|
|
|
* @psalm-type RequestOptions = array<null>|array{ |
73
|
|
|
* body?: string, |
74
|
|
|
* headers?: HttpHeaders |
75
|
|
|
* } |
76
|
|
|
* |
77
|
|
|
* HAL+JSON Types |
78
|
|
|
* @psalm-type HalLinkData = array{ |
79
|
|
|
* href: string, |
80
|
|
|
* templated?: bool, |
81
|
|
|
* type?: string, |
82
|
|
|
* deprecation?: string, |
83
|
|
|
* name?: string, |
84
|
|
|
* profile?: string, |
85
|
|
|
* title?: string, |
86
|
|
|
* hreflang?: string |
87
|
|
|
* } |
88
|
|
|
* @psalm-type HalLinks = array<string, HalLinkData|list<HalLinkData>> |
89
|
|
|
* @psalm-type HalResource = array{ |
90
|
|
|
* _links?: HalLinks, |
91
|
|
|
* _embedded?: array<string, mixed> |
92
|
|
|
* } |
93
|
|
|
* |
94
|
|
|
* Resource Metadata Types |
95
|
|
|
* @psalm-type PackageMetadata = array{ |
96
|
|
|
* vendor?: string, |
97
|
|
|
* package?: string |
98
|
|
|
* } |
99
|
|
|
* @psalm-type ResourceObjectBody = array{ |
100
|
|
|
* 0: ResourceObject, |
101
|
|
|
* 1: array<array-key, mixed> |
102
|
|
|
* } |
103
|
|
|
* |
104
|
|
|
* Link Relation Types |
105
|
|
|
* @psalm-type MethodUri = array{0: string, 1: string} |
106
|
|
|
* |
107
|
|
|
* Annotation Types |
108
|
|
|
* @psalm-type Annotations = array<class-string, object> |
109
|
|
|
* @psalm-type ClassAnnotations = array<class-string, Annotations> |
110
|
|
|
* @psalm-type MethodAnnotations = array<string, Annotations> |
111
|
|
|
* @psalm-type WebContextParam = class-string |
112
|
|
|
* @psalm-type WebContextName = 'cookie'|'env'|'formData'|'query'|'server'|'files' |
113
|
|
|
* @psalm-type WebContextMap = array<WebContextParam, WebContextName> |
114
|
|
|
* @psalm-type InsMap = array<string, string> |
115
|
|
|
* |
116
|
|
|
* Request Types |
117
|
|
|
* @psalm-type RequestInvoker = callable(ResourceObject, Request): ResourceObject |
118
|
|
|
* @psalm-type RequestQuery = array<string, mixed> |
119
|
|
|
* |
120
|
|
|
* Renderer Types |
121
|
|
|
* @psalm-type RenderView = array{ |
122
|
|
|
* status: string, |
123
|
|
|
* headers: Headers, |
124
|
|
|
* value: mixed, |
125
|
|
|
* view: ViewName |
126
|
|
|
* } |
127
|
|
|
* |
128
|
|
|
* @phpcs:enable |
129
|
|
|
*/ |
130
|
|
|
final class Types |
131
|
|
|
{ |
132
|
|
|
/** @codeCoverageIgnore */ |
133
|
|
|
private function __construct() |
134
|
|
|
{ |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|