Skip to content

Commit cbea5ba

Browse files
Add PHP types
1 parent 05f2248 commit cbea5ba

File tree

138 files changed

+1993
-2560
lines changed

Some content is hidden

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

138 files changed

+1993
-2560
lines changed

phpstan.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
level: 1
3+
paths:
4+
- src
5+
ignoreErrors:
6+
- '#Unsafe usage of new static\(\)#'

src/Api/Admin/AdminApi.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class AdminApi
4747
/**
4848
* AdminApi constructor.
4949
*
50-
* @param mixed $configuration
50+
* @param mixed|null $configuration
5151
*
5252
* @noinspection UnusedConstructorDependenciesInspection*/
53-
public function __construct($configuration = null)
53+
public function __construct(mixed $configuration = null)
5454
{
5555
$this->apiClient = new ApiClient($configuration);
5656

src/Api/Admin/AnalysisTrait.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,42 @@ trait AnalysisTrait
2626
/**
2727
* Analyzes an asset with the requested analysis type.
2828
*
29-
* @param string $inputType The type of input for the asset to analyze ('uri').
30-
* @param string $analysisType The type of analysis to run ('google_tagging', 'captioning', 'fashion').
31-
* @param string $uri The URI of the asset to analyze.
32-
* @param array $parameters Additional parameters.
29+
* @param string $inputType The type of input for the asset to analyze ('uri').
30+
* @param string $analysisType The type of analysis to run ('google_tagging', 'captioning', 'fashion').
31+
* @param string|null $uri The URI of the asset to analyze.
32+
* @param array|null $parameters Additional parameters.
3333
*
3434
*
35-
* @return ApiResponse
3635
*
3736
* @see AdminApi::analyzeAsync()
3837
*
3938
* @see https://cloudinary.com/documentation/media_analyzer_api_reference
4039
*/
41-
public function analyze($inputType, $analysisType, $uri = null, $parameters = null)
42-
{
40+
public function analyze(
41+
string $inputType,
42+
string $analysisType,
43+
?string $uri = null,
44+
?array $parameters = null
45+
): ApiResponse {
4346
return $this->analyzeAsync($inputType, $analysisType, $uri, $parameters)->wait();
4447
}
4548

4649
/**
4750
* Analyzes an asset with the requested analysis type asynchronously.
4851
*
49-
* @param string $inputType The type of input for the asset to analyze ('uri').
50-
* @param string $analysisType The type of analysis to run ('google_tagging', 'captioning', 'fashion').
51-
* @param string $uri The URI of the asset to analyze.
52-
* @param array $parameters Additional parameters.
53-
*
54-
* @return PromiseInterface
52+
* @param string $inputType The type of input for the asset to analyze ('uri').
53+
* @param string $analysisType The type of analysis to run ('google_tagging', 'captioning', 'fashion').
54+
* @param string|null $uri The URI of the asset to analyze.
55+
* @param array|null $parameters Additional parameters.
5556
*
5657
* @see https://cloudinary.com/documentation/media_analyzer_api_reference
5758
*/
58-
public function analyzeAsync($inputType, $analysisType, $uri = null, $parameters = null)
59-
{
59+
public function analyzeAsync(
60+
string $inputType,
61+
string $analysisType,
62+
?string $uri = null,
63+
?array $parameters = null
64+
): PromiseInterface {
6065
$endPoint = [ApiEndPoint::ANALYSIS, 'analyze', $inputType];
6166

6267
$params = ['analysis_type' => $analysisType, 'uri' => $uri, 'parameters' => $parameters];

src/Api/Admin/ApiEndPoint.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
*/
1616
class ApiEndPoint
1717
{
18-
const PING = 'ping';
19-
const CONFIG = 'config';
20-
const USAGE = 'usage';
21-
const ASSETS = 'resources';
22-
const DERIVED_ASSETS = 'derived_resources';
23-
const RELATED_ASSETS = 'related_assets';
24-
const FOLDERS = 'folders';
25-
const TAGS = 'tags';
26-
const STREAMING_PROFILES = 'streaming_profiles';
27-
const TRANSFORMATIONS = 'transformations';
28-
const UPLOAD_PRESETS = 'upload_presets';
29-
const UPLOAD_MAPPINGS = 'upload_mappings';
30-
const METADATA_FIELDS = 'metadata_fields';
31-
const ANALYSIS = 'analysis';
18+
public const PING = 'ping';
19+
public const CONFIG = 'config';
20+
public const USAGE = 'usage';
21+
public const ASSETS = 'resources';
22+
public const DERIVED_ASSETS = 'derived_resources';
23+
public const RELATED_ASSETS = 'related_assets';
24+
public const FOLDERS = 'folders';
25+
public const TAGS = 'tags';
26+
public const STREAMING_PROFILES = 'streaming_profiles';
27+
public const TRANSFORMATIONS = 'transformations';
28+
public const UPLOAD_PRESETS = 'upload_presets';
29+
public const UPLOAD_MAPPINGS = 'upload_mappings';
30+
public const METADATA_FIELDS = 'metadata_fields';
31+
public const ANALYSIS = 'analysis';
3232
}

0 commit comments

Comments
 (0)