Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for PHP 8.2 #70

Merged
merged 3 commits into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 0 additions & 19 deletions .scrutinizer.yml

This file was deleted.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# SaferpayJsonApi

[![Build Status](https://github.com/Ticketpark/SaferpayJsonApi/actions/workflows/tests.yml/badge.svg)](https://github.com/Ticketpark/SaferpayJsonApi/actions)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ticketpark/saferpayjsonapi/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ticketpark/saferpayjsonapi/?branch=master)


A php library to use the [Saferpay Json API](http://saferpay.github.io/jsonapi/).

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
20 changes: 7 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,12 @@ private function getContent(): string

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

return SerializerBuilder::create()->build();
}
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ parameters:
paths:
- lib
checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: false
ignoreErrors:
-
message: '#Property [a-zA-Z0-9\\]+::\$[a-zA-Z0-9]+ is never written, only read.#'
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