Skip to content

Commit

Permalink
Add support for PHP 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sprain committed Apr 15, 2023
1 parent 67dbbc8 commit feb34d2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
php: ['7.4', '8.0', '8.1']
php: ['7.4', '8.0', '8.1', '8.2']
stability: ['prefer-lowest', 'prefer-stable']

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
],
"require": {
"php": "^7.4|^8.0.0|^8.1.0",
"doctrine/annotations": "^1.11",
"doctrine/annotations": "^1.11|^2.0",
"jms/serializer": "^3.16",
"guzzlehttp/guzzle": "^6.3|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpstan/phpstan": "^1.6",
"friendsofphp/php-cs-fixer": "^3.8"
"friendsofphp/php-cs-fixer": "^3.16"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 5 additions & 13 deletions lib/SaferpayJson/Request/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,7 @@ abstract class Request
*/
private $requestConfig;

/**
* We want the implementation to define the exact return type hint of the response.
* In PHP 7.4 the return type hint here in the abstraction would therefore be Ticketpark\SaferpayJson\Response\Response,
* as all other responses inherit from that class.
* In PHP 7.3 this is not yet allowed. Therefore the return type is omitted and only provided as a PhpDoc in
* order to satisfy static code analysis by PhpStan.
*
* @link https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters
* @link https://stitcher.io/blog/new-in-php-74#improved-type-variance-rfc
* @return mixed
*/
abstract public function execute();
abstract public function execute(): Response;

abstract public function getApiPath(): string;

Expand Down Expand Up @@ -153,7 +142,10 @@ private function getContent(): string

private function getSerializer(): SerializerInterface
{
AnnotationRegistry::registerLoader('class_exists');
// Support for doctrine/annotations 1.x
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader('class_exists');
}

return SerializerBuilder::create()->build();
}
Expand Down
6 changes: 5 additions & 1 deletion tests/SaferpayJson/Tests/Request/CommonRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ private function getResponseMock(): MockObject

private function getFakedApiResponse(string $class): string
{
AnnotationRegistry::registerLoader('class_exists');
// Support for doctrine/annotations 1.x
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader('class_exists');
}

$serializer = SerializerBuilder::create()->build();

$response = new $class();
Expand Down

0 comments on commit feb34d2

Please sign in to comment.