Skip to content

Commit 71577da

Browse files
committed
Add component phpstan-type
1 parent 5152e31 commit 71577da

2 files changed

Lines changed: 16 additions & 102 deletions

File tree

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -990,11 +990,6 @@ parameters:
990990
count: 1
991991
path: src/Keboola/StorageApi/Components.php
992992

993-
-
994-
message: "#^Method Keboola\\\\StorageApi\\\\Components\\:\\:getComponent\\(\\) has no return type specified\\.$#"
995-
count: 1
996-
path: src/Keboola/StorageApi/Components.php
997-
998993
-
999994
message: "#^Method Keboola\\\\StorageApi\\\\Components\\:\\:getComponent\\(\\) has parameter \\$componentId with no type specified\\.$#"
1000995
count: 1
@@ -1085,11 +1080,6 @@ parameters:
10851080
count: 1
10861081
path: src/Keboola/StorageApi/Components.php
10871082

1088-
-
1089-
message: "#^Method Keboola\\\\StorageApi\\\\Components\\:\\:listComponents\\(\\) has no return type specified\\.$#"
1090-
count: 1
1091-
path: src/Keboola/StorageApi/Components.php
1092-
10931083
-
10941084
message: "#^Method Keboola\\\\StorageApi\\\\Components\\:\\:listConfigurationMetadata\\(\\) has no return type specified\\.$#"
10951085
count: 1

src/Keboola/StorageApi/Components.php

Lines changed: 16 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
use Keboola\StorageApi\Options\Components\ListConfigurationVersionsOptions;
1515
use Keboola\StorageApi\Options\Components\ListConfigurationWorkspacesOptions;
1616

17+
/**
18+
* @phpstan-type Component array{id: string, type: string, name: string, description: string, longDescription: string, version: int, complexity: string, categories: list<string>, hasUI: bool, hasRun: bool, ico32: string, ico64: string, ico128: string, data: array, flags: list<string>, configurationSchema: array, configurationRowSchema: array, emptyConfiguration: array, emptyConfigurationRow: array, createConfigurationRowSchema: array, uiOptions: array, configurationDescription: string, features: list<string>, expiredOn: string, dataTypesConfiguration: array, processorConfiguration: array, uri: string, documentationUrl: string}
19+
* @phpstan-type ComponentListItem array{id: string, type: string, name: string, description: string, longDescription: string, version: int, complexity: string, categories: list<string>, hasUI: bool, hasRun: bool, ico32: string, ico64: string, ico128: string, data: array, flags: list<string>, configurationSchema: array, configurationRowSchema: array, emptyConfiguration: array, emptyConfigurationRow: array, createConfigurationRowSchema: array, uiOptions: array, configurationDescription: string, features: list<string>, expiredOn: string, dataTypesConfiguration: array, configurations: array, processorConfiguration: array, uri: string, documentationUrl: string}
20+
*/
1721
class Components
1822
{
1923
private string $branchPrefix = '';
@@ -118,109 +122,29 @@ public function resetToDefault($componentId, $configurationId)
118122
return $this->client->apiPostJson($this->branchPrefix . "components/{$componentId}/configs/{$configurationId}/reset-to-default");
119123
}
120124

121-
public function listComponents(?ListComponentsOptions $options = null)
125+
/** @return ComponentListItem[] */
126+
public function listComponents(?ListComponentsOptions $options = null): array
122127
{
123128
if (!$options) {
124129
$options = new ListComponentsOptions();
125130
}
126-
return $this->client->apiGet($this->branchPrefix . 'components?' . http_build_query($options->toParamsArray()));
131+
/** @var ComponentListItem[] $result */
132+
$result = $this->client->apiGet($this->branchPrefix . 'components?' . http_build_query($options->toParamsArray()));
133+
return $result;
127134
}
128135

129-
public function getComponent($componentId)
136+
/** @return Component */
137+
public function getComponent($componentId): array
130138
{
131-
return $this->client->apiGet($this->branchPrefix . "components/{$componentId}");
139+
/** @var Component $result */
140+
$result = $this->client->apiGet($this->branchPrefix . "components/{$componentId}");
141+
return $result;
132142
}
133143

134-
/**
135-
* Get public component detail
136-
* @return array{
137-
* id: string,
138-
* type: string,
139-
* name: string,
140-
* description: string,
141-
* longDescription: string,
142-
* hasUI: bool,
143-
* hasRun: bool,
144-
* ico32: string,
145-
* ico64: string,
146-
* ico128: string,
147-
* data: array{
148-
* definition: array{
149-
* type: string,
150-
* uri: string,
151-
* tag: string,
152-
* repository: array{
153-
* region: string
154-
* }
155-
* },
156-
* cpu_shares: int,
157-
* memory: string,
158-
* configuration_format: string,
159-
* process_timeout: int
160-
* },
161-
* flags: array<string>,
162-
* configurationSchema: array{
163-
* title: string,
164-
* type: string,
165-
* properties: array<string, array{
166-
* type: string,
167-
* title: string,
168-
* description: string,
169-
* default?: string
170-
* }>,
171-
* required: array<string>
172-
* },
173-
* emptyConfiguration: array<mixed>,
174-
* uiOptions: array<mixed>,
175-
* configurationDescription: string,
176-
* uri: string
177-
* }
178-
*/
144+
/** @return Component */
179145
public function getPublicComponentDetail(string $componentId): array
180146
{
181-
/** @var array{
182-
* id: string,
183-
* type: string,
184-
* name: string,
185-
* description: string,
186-
* longDescription: string,
187-
* hasUI: bool,
188-
* hasRun: bool,
189-
* ico32: string,
190-
* ico64: string,
191-
* ico128: string,
192-
* data: array{
193-
* definition: array{
194-
* type: string,
195-
* uri: string,
196-
* tag: string,
197-
* repository: array{
198-
* region: string
199-
* }
200-
* },
201-
* cpu_shares: int,
202-
* memory: string,
203-
* configuration_format: string,
204-
* process_timeout: int
205-
* },
206-
* flags: array<string>,
207-
* configurationSchema: array{
208-
* title: string,
209-
* type: string,
210-
* properties: array<string, array{
211-
* type: string,
212-
* title: string,
213-
* description: string,
214-
* default?: string
215-
* }>,
216-
* required: array<string>
217-
* },
218-
* emptyConfiguration: array<mixed>,
219-
* uiOptions: array<mixed>,
220-
* configurationDescription: string,
221-
* uri: string
222-
* } $result
223-
*/
147+
/** @var Component $result */
224148
$result = $this->client->apiGet('components/'.$componentId);
225149
return $result;
226150
}

0 commit comments

Comments
 (0)