Skip to content

Commit 6bafd22

Browse files
Marvin Durotmarvindurot
Marvin Durot
authored andcommitted
Upgrade to PHP 8.2 with Rector
1 parent 40b3ee1 commit 6bafd22

15 files changed

+18
-18
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
],
1111
"require" : {
12-
"php" : ">=8.1",
12+
"php" : ">=8.2",
1313
"php-curl-class/php-curl-class": "^8.3",
1414
"psr/cache": "^1.0 || ^2.0 || ^3.0"
1515
},

rector.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
__DIR__ . '/src',
1010
__DIR__ . '/tests',
1111
])
12-
->withPhpSets(php81: true)
12+
->withPhpSets(php82: true)
1313
->withTypeCoverageLevel(0)
1414
->withDeadCodeLevel(0)
1515
->withCodeQualityLevel(0);

src/Api.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __call($name, $arguments)
5252
return $this->$name(...$arguments);
5353
}
5454

55-
preg_match('/^(get|create|update|delete)([\w\-_\/]+?)$/', $name, $matches);
55+
preg_match('/^(get|create|update|delete)([\w\-_\/]+?)$/', (string) $name, $matches);
5656

5757
$endpoint = lcfirst($matches[2]);
5858

src/Bridges/BarryvdhLaravelDebugbar/DebugbarTransportDecorator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DebugbarTransportDecorator implements TransportInterface
2929
* @param string $name
3030
* @param LaravelDebugbar $debugbar
3131
*/
32-
public function __construct(private TransportInterface $transport, private string $name, ?LaravelDebugbar $debugbar)
32+
public function __construct(private readonly TransportInterface $transport, private readonly string $name, ?LaravelDebugbar $debugbar)
3333
{
3434
$this->debugbar = $debugbar;
3535
}

src/Bridges/Symfony/Adapter/ApiWrapperPaginatorAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class ApiWrapperPaginatorAdapter implements \IteratorAggregate, ApiPlatformPaginator
99
{
10-
public function __construct(private PaginatorInterface $paginator)
10+
public function __construct(private readonly PaginatorInterface $paginator)
1111
{
1212
}
1313

src/Bridges/Symfony/DataProvider/ApiPlatformDataProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
final class ApiPlatformDataProvider implements ItemDataProviderInterface, CollectionDataProviderInterface, RestrictedDataProviderInterface
1414
{
15-
public function __construct(private ManagerRegistry $managerRegistry)
15+
public function __construct(private readonly ManagerRegistry $managerRegistry)
1616
{
1717
}
1818

src/Bridges/Symfony/Repository.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function getMetadata(): ClassMetadata
7272
public function find($id)
7373
{
7474
return $this->instanciateEntity(
75-
$this->getApi()->{'get' . ucfirst($this->class->getEntity())}($id)
75+
$this->getApi()->{'get' . ucfirst((string) $this->class->getEntity())}($id)
7676
);
7777
}
7878

@@ -96,7 +96,7 @@ public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $
9696
$criteria[static::CRITERIA_LIMIT] = $limit ?? static::DEFAULT_LIMIT;
9797
$criteria[static::CRITERIA_PAGE] = $page ?? 1;
9898

99-
$results = $this->getApi()->{'get' . ucfirst($this->class->getEntities())}(
99+
$results = $this->getApi()->{'get' . ucfirst((string) $this->class->getEntities())}(
100100
$this->filterCriteria($criteria)
101101
);
102102

src/Builder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function findOrFail($field, $value = null)
106106
return $this->where($this->query)->get()[0] ?? null;
107107
}
108108

109-
$data = $this->model->getApi()->{'get'.ucfirst($this->model->getEntity())}($field, $this->getQuery());
109+
$data = $this->model->getApi()->{'get'.ucfirst((string) $this->model->getEntity())}($field, $this->getQuery());
110110

111111
return $this->model->newInstance($data, true);
112112
}

src/Concerns/HasAttributes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ protected function castAttribute($key, $value)
133133
*/
134134
protected function getCastType($key)
135135
{
136-
return trim(strtolower($this->getCasts()[$key]));
136+
return trim(strtolower((string) $this->getCasts()[$key]));
137137
}
138138

139139
/**

src/Exceptions/Handlers/BadRequestErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BadRequestErrorHandler extends AbstractErrorHandler
1414
/**
1515
* {@inheritdoc}
1616
*/
17-
public function handle(ApiException $exception, array $requestArguments)
17+
public function handle(ApiException $exception, array $requestArguments): never
1818
{
1919
throw new ApiBadRequestException(
2020
$exception->getResponse(),

src/Exceptions/Handlers/ForbiddenErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ForbiddenErrorHandler extends AbstractErrorHandler
1414
/**
1515
* {@inheritdoc}
1616
*/
17-
public function handle(ApiException $exception, array $requestArguments)
17+
public function handle(ApiException $exception, array $requestArguments): never
1818
{
1919
throw new ApiForbiddenException(
2020
$exception->getResponse(),

src/Exceptions/Handlers/NotFoundErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class NotFoundErrorHandler extends AbstractErrorHandler
1414
/**
1515
* {@inheritdoc}
1616
*/
17-
public function handle(ApiException $exception, array $requestArguments)
17+
public function handle(ApiException $exception, array $requestArguments): never
1818
{
1919
throw new ApiEntityNotFoundException(
2020
$exception->getResponse(),

src/Exceptions/Handlers/UnauthorizedErrorHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class UnauthorizedErrorHandler extends AbstractErrorHandler
1414
/**
1515
* {@inheritdoc}
1616
*/
17-
public function handle(ApiException $exception, array $requestArguments)
17+
public function handle(ApiException $exception, array $requestArguments): never
1818
{
1919
throw new ApiUnauthorizedException(
2020
$exception->getResponse(),

src/Model.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ protected function performUpdate()
562562
$dirty = $this->getDirty();
563563

564564
if (count($dirty) > 0) {
565-
$updatedField = $this->getApi()->{'update'.ucfirst($this->getEntity())}($this->{$this->primaryKey}, $dirty);
565+
$updatedField = $this->getApi()->{'update'.ucfirst((string) $this->getEntity())}($this->{$this->primaryKey}, $dirty);
566566
$this->fill($updatedField);
567567
$this->syncChanges();
568568
}
@@ -578,7 +578,7 @@ protected function performUpdate()
578578
protected function performInsert()
579579
{
580580
$attributes = $this->getAttributes();
581-
$updatedField = $this->getApi()->{'create'.ucfirst($this->getEntity())}($attributes);
581+
$updatedField = $this->getApi()->{'create'.ucfirst((string) $this->getEntity())}($attributes);
582582
$this->fill($updatedField);
583583
$this->exists = true;
584584
$this->wasRecentlyCreated = true;
@@ -593,7 +593,7 @@ protected function performInsert()
593593
*/
594594
protected function performDeleteOnModel()
595595
{
596-
$this->getApi()->{'delete'.ucfirst($this->getEntity())}(
596+
$this->getApi()->{'delete'.ucfirst((string) $this->getEntity())}(
597597
$this->{$this->primaryKey},
598598
array_merge(...array_values($this->getGlobalScopes()))
599599
);

src/Transports/Transport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function request($endpoint, array $data = [], $method = 'get')
101101
{
102102
$rawResponse = $this->rawRequest($endpoint, $data, $method);
103103
$httpStatusCode = $this->getClient()->httpStatusCode;
104-
$response = json_decode($rawResponse, true);
104+
$response = json_decode((string) $rawResponse, true);
105105

106106
if ($httpStatusCode >= 200 && $httpStatusCode <= 299) {
107107
return $response;

0 commit comments

Comments
 (0)