Skip to content

Commit 9fc7396

Browse files
authored
Merge pull request #324 from commercetools/fix-php-deprecations
fix PHP deprecations
2 parents a36a9ec + f24b2f2 commit 9fc7396

17 files changed

+111
-19
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717
phpunit.xml.dist export-ignore
1818
prettify.sh export-ignore
1919
psalm.xml export-ignore
20+
phpstan.neon export-ignore
21+
phpstan-baseline.neon export-ignore

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
"monolog/monolog": "^1.3 || ^2.0",
6464
"phpunit/phpunit": "^9.0 | 8.5.22",
6565
"cache/array-adapter": "^1.0",
66-
"symplify/easy-coding-standard": "12.5.8"
66+
"symplify/easy-coding-standard": "12.5.8",
67+
"phpstan/phpstan": "^2.1.6"
6768
},
6869
"config": {
6970
"allow-plugins": {

lib/commercetools-base/src/Base/CMap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function jsonSerialize(): ?array;
3838
* @psalm-param ?stdClass $data
3939
* @psalm-return static
4040
*/
41-
public static function fromStdClass(stdClass $data = null);
41+
public static function fromStdClass(?stdClass $data = null);
4242

4343
/**
4444
* @template T
@@ -62,7 +62,7 @@ public function at(string $key);
6262
/**
6363
* @return static|mixed
6464
*/
65-
public function with(string $key, callable $callable = null);
65+
public function with(string $key, ?callable $callable = null);
6666

6767
public function getIterator(): MapperIterator;
6868

lib/commercetools-base/src/Base/MapperMap.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ abstract class MapperMap implements CMap
2828
* @psalm-param ?array<string, TObject|stdClass> $data
2929
* @param array|null $data
3030
*/
31-
final public function __construct(array $data = null)
31+
final public function __construct(?array $data = null)
3232
{
3333
if (!is_null($data)) {
3434
$this->index($data);
@@ -72,7 +72,7 @@ public function jsonSerialize(): ?array
7272
* @psalm-param ?stdClass $data
7373
* @psalm-return static
7474
*/
75-
final public static function fromStdClass(stdClass $data = null)
75+
final public static function fromStdClass(?stdClass $data = null)
7676
{
7777
/** @psalm-var array<string, TObject|stdClass> $t */
7878
$t = (array)$data;
@@ -150,7 +150,7 @@ public function at(string $key)
150150
/**
151151
* @return ?TObject|mixed
152152
*/
153-
public function with(string $key, callable $callable = null)
153+
public function with(string $key, ?callable $callable = null)
154154
{
155155
$data = $this->at($key);
156156
if (is_null($callable)) {

lib/commercetools-base/src/Base/MapperScalarSequence.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ abstract class MapperScalarSequence implements CSequence
2828
* @psalm-param ?array<int, TScalar|scalar> $data
2929
* @param array|null $data
3030
*/
31-
final public function __construct(array $data = null)
31+
final public function __construct(?array $data = null)
3232
{
3333
if (!is_null($data)) {
3434
$this->index($data);

lib/commercetools-base/src/Base/MapperSequence.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ abstract class MapperSequence implements CSequence
2828
* @psalm-param ?array<int, TObject|stdClass> $data
2929
* @param array|null $data
3030
*/
31-
final public function __construct(array $data = null)
31+
final public function __construct(?array $data = null)
3232
{
3333
if (!is_null($data)) {
3434
$this->index($data);

lib/commercetools-base/src/Client/CachedTokenProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CachedTokenProvider implements TokenProvider
3030
/**
3131
* @psalm-param CacheItemPoolInterface|CacheInterface|mixed $cache
3232
*/
33-
public function __construct(TokenProvider $provider, $cache, string $cacheKey = null)
33+
public function __construct(TokenProvider $provider, $cache, ?string $cacheKey = null)
3434
{
3535
$this->validateCache($cache);
3636
$this->cache = $cache;

lib/commercetools-base/src/Client/ClientCredentials.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ClientCredentials
3838
* Format: `<the scope name>:<the project key>`.
3939
* Example: `manage_products:project1`.
4040
*/
41-
public function __construct(string $clientId, string $clientSecret, string $scope = null)
41+
public function __construct(string $clientId, string $clientSecret, ?string $scope = null)
4242
{
4343
$this->clientId = $clientId;
4444
$this->clientSecret = $clientSecret;

lib/commercetools-base/src/Client/TokenModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TokenModel implements Token
2626
*/
2727
private $expiresIn;
2828

29-
public function __construct(string $value, int $expiresIn = null)
29+
public function __construct(string $value, ?int $expiresIn = null)
3030
{
3131
$this->value = $value;
3232
$this->expiresIn = $expiresIn ?? 0;

lib/commercetools-base/src/Client/UserAgentProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class UserAgentProvider
2121
private $userAgent;
2222
public const USER_AGENT = 'commercetools-sdk-php-v2';
2323

24-
public function __construct(string $suffix = null)
24+
public function __construct(?string $suffix = null)
2525
{
2626
if (defined('\GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
2727
$clientVersion = (string) constant(ClientInterface::class . '::MAJOR_VERSION');

0 commit comments

Comments
 (0)