Skip to content

Commit 06e4c71

Browse files
committed
fix(php): add PHPStan for static code analysis
1 parent cf37a8f commit 06e4c71

27 files changed

+314
-1075
lines changed

clients/algoliasearch-client-php/composer.lock

Lines changed: 220 additions & 154 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/algoliasearch-client-php/lib/ApiException.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4-
53
namespace Algolia\AlgoliaSearch;
64

75
/**

clients/algoliasearch-client-php/lib/Cache/NullCacheDriver.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@
66

77
final class NullCacheDriver implements CacheInterface
88
{
9-
public function get($key, $default = null)
9+
public function get($key, $default = null): mixed
1010
{
1111
return $default;
1212
}
1313

14-
public function set($key, $value, $ttl = null)
14+
public function set($key, $value, $ttl = null): bool
1515
{
1616
return true;
1717
}
1818

19-
public function delete($key)
19+
public function delete($key): bool
2020
{
2121
return true;
2222
}
2323

24-
public function clear()
24+
public function clear(): bool
2525
{
2626
return true;
2727
}
2828

29-
public function getMultiple($keys, $default = null)
29+
public function getMultiple($keys, $default = null): iterable
3030
{
3131
$return = [];
3232

@@ -37,17 +37,17 @@ public function getMultiple($keys, $default = null)
3737
return $return;
3838
}
3939

40-
public function setMultiple($values, $ttl = null)
40+
public function setMultiple($values, $ttl = null): bool
4141
{
4242
return true;
4343
}
4444

45-
public function deleteMultiple($keys)
45+
public function deleteMultiple($keys): bool
4646
{
4747
return true;
4848
}
4949

50-
public function has($key)
50+
public function has($key): bool
5151
{
5252
return false;
5353
}

clients/algoliasearch-client-php/lib/Configuration/ConfigWithRegion.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4-
53
namespace Algolia\AlgoliaSearch\Configuration;
64

75
abstract class ConfigWithRegion extends Configuration

clients/algoliasearch-client-php/lib/Configuration/Configuration.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4-
53
namespace Algolia\AlgoliaSearch\Configuration;
64

75
use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;

clients/algoliasearch-client-php/lib/Http/Psr7/BufferStream.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,65 +32,65 @@ public function __construct($hwm = 16384)
3232
$this->hwm = $hwm;
3333
}
3434

35-
public function __toString()
35+
public function __toString(): string
3636
{
3737
return $this->getContents();
3838
}
3939

40-
public function getContents()
40+
public function getContents(): string
4141
{
4242
$buffer = $this->buffer;
4343
$this->buffer = '';
4444

4545
return $buffer;
4646
}
4747

48-
public function close()
48+
public function close(): void
4949
{
5050
$this->buffer = '';
5151
}
5252

53-
public function detach()
53+
public function detach(): void
5454
{
5555
$this->close();
5656
}
5757

58-
public function getSize()
58+
public function getSize(): int
5959
{
6060
return mb_strlen($this->buffer);
6161
}
6262

63-
public function isReadable()
63+
public function isReadable(): bool
6464
{
6565
return true;
6666
}
6767

68-
public function isWritable()
68+
public function isWritable(): bool
6969
{
7070
return true;
7171
}
7272

73-
public function isSeekable()
73+
public function isSeekable(): bool
7474
{
7575
return false;
7676
}
7777

78-
public function rewind()
78+
public function rewind(): void
7979
{
8080
$this->seek(0);
8181
}
8282

83-
public function seek($offset, $whence = SEEK_SET)
83+
public function seek($offset, $whence = SEEK_SET): void
8484
{
8585
throw new \RuntimeException('Cannot seek a BufferStream');
8686
}
8787

88-
public function eof()
88+
public function eof(): bool
8989
{
9090
return 0 === mb_strlen($this->buffer);
9191
}
9292

93-
public function tell()
93+
public function tell(): int
9494
{
9595
throw new \RuntimeException('Cannot determine the position of a BufferStream');
9696
}
@@ -100,7 +100,7 @@ public function tell()
100100
*
101101
* @param mixed $length
102102
*/
103-
public function read($length)
103+
public function read($length): string
104104
{
105105
$currentLength = mb_strlen($this->buffer);
106106

@@ -122,7 +122,7 @@ public function read($length)
122122
*
123123
* @param mixed $string
124124
*/
125-
public function write($string)
125+
public function write($string): int
126126
{
127127
$this->buffer .= $string;
128128

clients/algoliasearch-client-php/lib/Http/Psr7/PumpStream.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function __construct(callable $source, array $options = [])
5353
$this->buffer = new BufferStream();
5454
}
5555

56-
public function __toString()
56+
public function __toString(): string
5757
{
5858
try {
5959
return copy_to_string($this);
@@ -62,63 +62,63 @@ public function __toString()
6262
}
6363
}
6464

65-
public function close()
65+
public function close(): void
6666
{
6767
$this->detach();
6868
}
6969

70-
public function detach()
70+
public function detach(): void
7171
{
7272
$this->tellPos = false;
7373
$this->source = null;
7474
}
7575

76-
public function getSize()
76+
public function getSize(): ?int
7777
{
7878
return $this->size;
7979
}
8080

81-
public function tell()
81+
public function tell(): int
8282
{
8383
return $this->tellPos;
8484
}
8585

86-
public function eof()
86+
public function eof(): bool
8787
{
8888
return !$this->source;
8989
}
9090

91-
public function isSeekable()
91+
public function isSeekable(): bool
9292
{
9393
return false;
9494
}
9595

96-
public function rewind()
96+
public function rewind(): void
9797
{
9898
$this->seek(0);
9999
}
100100

101-
public function seek($offset, $whence = SEEK_SET)
101+
public function seek($offset, $whence = SEEK_SET): void
102102
{
103103
throw new \RuntimeException('Cannot seek a PumpStream');
104104
}
105105

106-
public function isWritable()
106+
public function isWritable(): bool
107107
{
108108
return false;
109109
}
110110

111-
public function write($string)
111+
public function write($string): int
112112
{
113113
throw new \RuntimeException('Cannot write to a PumpStream');
114114
}
115115

116-
public function isReadable()
116+
public function isReadable(): bool
117117
{
118118
return true;
119119
}
120120

121-
public function read($length)
121+
public function read($length): string
122122
{
123123
$data = $this->buffer->read($length);
124124
$readLen = mb_strlen($data);
@@ -134,7 +134,7 @@ public function read($length)
134134
return $data;
135135
}
136136

137-
public function getContents()
137+
public function getContents(): string
138138
{
139139
$result = '';
140140
while (!$this->eof()) {

templates/php/ModelInterface.mustache renamed to clients/algoliasearch-client-php/lib/Model/ModelInterface.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
<?php
22

3-
// {{{generationBanner}}}
4-
5-
namespace {{modelPackage}};
3+
namespace Algolia\AlgoliaSearch\Model;
64

75
/**
86
* Interface abstracting model access.
9-
*
10-
* @package {{modelPackage}}
117
*/
128
interface ModelInterface
139
{
1410
/**
15-
* Array of property to type mappings. Used for (de)serialization
11+
* Array of property to type mappings. Used for (de)serialization.
1612
*
1713
* @return array
1814
*/
1915
public static function modelTypes();
2016

2117
/**
22-
* Array of property to format mappings. Used for (de)serialization
18+
* Array of property to format mappings. Used for (de)serialization.
2319
*
2420
* @return array
2521
*/
2622
public static function modelFormats();
2723

2824
/**
29-
* Array of attributes to setter functions (for deserialization of responses)
25+
* Array of attributes to setter functions (for deserialization of responses).
3026
*
3127
* @return array
3228
*/
3329
public static function setters();
3430

3531
/**
36-
* Array of attributes to getter functions (for serialization of requests)
32+
* Array of attributes to getter functions (for serialization of requests).
3733
*
3834
* @return array
3935
*/
@@ -48,7 +44,7 @@ public function listInvalidProperties();
4844

4945
/**
5046
* Validate all the properties in the model
51-
* return true if all passed
47+
* return true if all passed.
5248
*
5349
* @return bool
5450
*/

clients/algoliasearch-client-php/lib/ObjectSerializer.php

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4-
53
namespace Algolia\AlgoliaSearch;
64

5+
use Algolia\AlgoliaSearch\Model\ModelInterface;
6+
77
/**
88
* ObjectSerializer Class Doc Comment.
99
*
@@ -86,23 +86,6 @@ public static function sanitizeForSerialization($data, $type = null, $format = n
8686
return (string) $data;
8787
}
8888

89-
/**
90-
* Sanitize filename by removing path.
91-
* e.g. ../../sun.gif becomes sun.gif.
92-
*
93-
* @param string $filename filename to be sanitized
94-
*
95-
* @return string the sanitized filename
96-
*/
97-
public static function sanitizeFilename($filename)
98-
{
99-
if (preg_match('/.*[\\/\\\\](.*)$/', $filename, $match)) {
100-
return $match[1];
101-
}
102-
103-
return $filename;
104-
}
105-
10689
/**
10790
* Take value and turn it into a string suitable for inclusion in
10891
* the path, by url-encoding.
@@ -154,24 +137,6 @@ public static function toHeaderValue($value)
154137
return self::toString($value);
155138
}
156139

157-
/**
158-
* Take value and turn it into a string suitable for inclusion in
159-
* the http body (form parameter). If it's a string, pass through unchanged
160-
* If it's a datetime object, format it in ISO8601.
161-
*
162-
* @param \SplFileObject|string $value the value of the form parameter
163-
*
164-
* @return string the form string
165-
*/
166-
public static function toFormValue($value)
167-
{
168-
if ($value instanceof \SplFileObject) {
169-
return $value->getRealPath();
170-
}
171-
172-
return self::toString($value);
173-
}
174-
175140
/**
176141
* Take value and turn it into a string suitable for inclusion in
177142
* the parameter. If it's a string, pass through unchanged
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
excludePaths:
3+
- vendor/*
4+
level: max

0 commit comments

Comments
 (0)