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

EWPP-4991: Ensure PHP8.3 compatibility. #85

Open
wants to merge 5 commits into
base: 2.x
Choose a base branch
from
Open
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
44 changes: 32 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,54 @@
name: ci
on: [push, pull_request]

jobs:
automated-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php_version: ["8.1", "8.2"]
composer_command: ["composer install", "composer update --prefer-lowest"]
php_version: ["8.1", "8.3"]
composer_command: ["composer install"]
env:
PHP_VERSION: ${{ matrix.php_version }}
steps:
- name: clone
- name: Clone repository
uses: actions/checkout@v2
- run: docker-compose up -d
- name: build

- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose

- name: Start services with Docker Compose
run: docker-compose up -d

- name: Build dependencies
run: docker-compose exec -T php ${{ matrix.composer_command }}
- name: test

- name: Run tests
run: docker-compose exec -T php ./vendor/bin/phpunit

code-sniffer:
runs-on: ubuntu-latest
strategy:
matrix:
php_version: ["8.1", "8.2"]
php_version: ["8.1", "8.3"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 8.2 is dropped?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is irrelevant to test if we support both 8.1 and 8.3.

env:
PHP_VERSION: ${{ matrix.php_version }}
steps:
- name: clone
- name: Clone repository
uses: actions/checkout@v2
- run: docker-compose up -d
- name: build

- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose

- name: Start services with Docker Compose
run: docker-compose up -d

- name: Install dependencies
run: docker-compose exec -T php composer install
- name: test
run: docker-compose exec -T php ./vendor/bin/grumphp run

- name: Run code sniffer
run: docker-compose exec -T php ./vendor/bin/grumphp run
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"cweagans/composer-patches": "^1 || ^2",
"php-http/logger-plugin": "^1",
"php-http/message": "~1.13",
"phpro/soap-client": "~2.4",
"phpro/soap-client": "~3.4",
"psr/http-client": "^1",
"psr/http-client-implementation": "*",
"psr/http-factory": "^1",
Expand All @@ -21,7 +21,7 @@
"symfony/http-client": "~5.4 || ~6",
"symfony/serializer": "~5.4 || ~6",
"symfony/validator": "~5.4 || ~6",
"veewee/xml": "^2.0"
"veewee/xml": "^3.0"
},
"require-dev": {
"colinodell/psr-testlogger": "^1.1",
Expand Down Expand Up @@ -73,8 +73,7 @@
"extra": {
"patches": {
"phpro/soap-client" : {
"https://github.com/phpro/soap-client/issues/446": "https://patch-diff.githubusercontent.com/raw/phpro/soap-client/pull/448.diff",
"https://github.com/phpro/soap-client/issues/444": "https://patch-diff.githubusercontent.com/raw/phpro/soap-client/pull/445.diff"
"add-anyuri-to-normalizer.patch": "./patches/add-anyuri-to-normalizer.patch"
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions config/soap-client-authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
use Phpro\SoapClient\CodeGenerator\Assembler;
use Phpro\SoapClient\CodeGenerator\Rules;
use Phpro\SoapClient\CodeGenerator\Config\Config;
use Soap\ExtSoapEngine\ExtSoapOptions;
use Phpro\SoapClient\Soap\DefaultEngineFactory;
use Phpro\SoapClient\Soap\CodeGeneratorEngineFactory;

// Generate SOAP client library to perform ECAS client certificate login.
// @link https://citnet.tech.ec.europa.eu/CITnet/confluence/display/IAM/ECAS+Certificate+Login
// WSDL used for generating the SOAP codebase can be found here:
// @link https://webgate.ec.europa.eu/cas/ws/CertLoginService.wsdl
// The content returned by the URL above is stored locally in resources/authentication.wsdl.
$engine = CodeGeneratorEngineFactory::create('./resources/authentication.wsdl');
return Config::create()
->setEngine($engine = DefaultEngineFactory::create(
ExtSoapOptions::defaults(__DIR__.'/../resources/authentication.wsdl', [])
->disableWsdlCache()
))
->setEngine($engine)
->setTypeDestination('src/Authentication/ClientCertificate/Type')
->setTypeNamespace('OpenEuropa\EPoetry\Authentication\ClientCertificate\Type')
->setClientDestination('src/Authentication/ClientCertificate')
Expand Down
15 changes: 8 additions & 7 deletions config/soap-client-notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

use OpenEuropa\EPoetry\CodeGenerator\ConfigProcessor;
use Phpro\SoapClient\CodeGenerator\Config\Config;
use Soap\ExtSoapEngine\ExtSoapOptions;
use Phpro\SoapClient\Soap\DefaultEngineFactory;
use Phpro\SoapClient\CodeGenerator\Rules\RuleSet;
use Phpro\SoapClient\Soap\CodeGeneratorEngineFactory;
use Phpro\SoapClient\CodeGenerator\Rules;
use Phpro\SoapClient\CodeGenerator\Assembler;

$engine = CodeGeneratorEngineFactory::create('./resources/notification.wsdl');
$config = Config::create()
->setEngine($engine = DefaultEngineFactory::create(
ExtSoapOptions::defaults('./resources/notification.wsdl', [])
->disableWsdlCache()
))
->setEngine($engine)
->setTypeDestination('src/Notification/Type')
->setTypeNamespace('OpenEuropa\EPoetry\Notification\Type')
->setClientDestination('src/Notification/')
->setClientNamespace('OpenEuropa\EPoetry\Notification')
->setClassMapDestination('src/Notification/')
->setClassMapName('NotificationClassmap')
->setClassMapNamespace('OpenEuropa\EPoetry\Notification');
->setClassMapNamespace('OpenEuropa\EPoetry\Notification')
;

return ConfigProcessor::addRules($config);
9 changes: 3 additions & 6 deletions config/soap-client-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

use OpenEuropa\EPoetry\CodeGenerator\ConfigProcessor;
use Phpro\SoapClient\CodeGenerator\Config\Config;
use Soap\ExtSoapEngine\ExtSoapOptions;
use Phpro\SoapClient\Soap\DefaultEngineFactory;
use Phpro\SoapClient\Soap\CodeGeneratorEngineFactory;

$engine = CodeGeneratorEngineFactory::create('./resources/request.wsdl');
$config = Config::create()
->setEngine($engine = DefaultEngineFactory::create(
ExtSoapOptions::defaults('./resources/request.wsdl', [])
->disableWsdlCache()
))
->setEngine($engine)
->setTypeDestination('src/Request/Type')
->setTypeNamespace('OpenEuropa\EPoetry\Request\Type')
->setClientDestination('src/Request/')
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: "2"
services:
php:
image: wodby/php:8.1
image: wodby/php:8.3
environment:
# PHP_XDEBUG: 1 # Uncomment to enable XDebug.
PHP_FPM_USER: wodby
Expand Down
12 changes: 12 additions & 0 deletions patches/add-anyuri-to-normalizer.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php b/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php
index 0f33a7f..76bcea5 100644
--- a/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php
+++ b/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php
@@ -15,6 +15,7 @@ class Normalizer
'any' => 'mixed',
'anytype' => 'mixed',
'anyxml' => 'string',
+ 'anyuri' => 'string',
'anysimpletype' => 'mixed',
'long' => 'int',
'short' => 'int',
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ public static function getCollection() : \Soap\ExtSoapEngine\Configuration\Class
);
}
}

12 changes: 9 additions & 3 deletions src/Authentication/ClientCertificate/ClientCertificateClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ public function __construct(\Phpro\SoapClient\Caller\Caller $caller)
}

/**
* @param RequestInterface|Type\GetServiceTicket $getServiceTicketPart
* @return ResultInterface|Type\GetServiceTicketResponse
* @param RequestInterface & Type\GetServiceTicket $getServiceTicketPart
* @return ResultInterface & Type\GetServiceTicketResponse
* @throws SoapException
*/
public function getServiceTicket(\OpenEuropa\EPoetry\Authentication\ClientCertificate\Type\GetServiceTicket $getServiceTicketPart) : \OpenEuropa\EPoetry\Authentication\ClientCertificate\Type\GetServiceTicketResponse
{
return ($this->caller)('getServiceTicket', $getServiceTicketPart);
$response = ($this->caller)('getServiceTicket', $getServiceTicketPart);

\Psl\Type\instance_of(\OpenEuropa\EPoetry\Authentication\ClientCertificate\Type\GetServiceTicketResponse::class)->assert($response);
\Psl\Type\instance_of(\Phpro\SoapClient\Type\ResultInterface::class)->assert($response);

return $response;
}
}

16 changes: 10 additions & 6 deletions src/Authentication/ClientCertificate/Type/GetServiceTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,41 @@
class GetServiceTicket implements RequestInterface
{
/**
* The target service for which you want to obtain a service ticket.
* This must be a valid URL.
*
* @var string
*/
private $service;
private string $service;

/**
* Constructor
*
* @var string $service
* @param string $service
*/
public function __construct($service)
public function __construct(string $service)
{
$this->service = $service;
}

/**
* @return string
*/
public function getService()
public function getService() : string
{
return $this->service;
}

/**
* @param string $service
* @return GetServiceTicket
* @return static
*/
public function withService($service)
public function withService(string $service) : static
{
$new = clone $this;
$new->service = $service;

return $new;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,30 @@
class GetServiceTicketResponse implements ResultInterface
{
/**
* Service ticket for the specified service.
*
* @var string
*/
private $serviceTicket;
private string $serviceTicket;

/**
* @return string
*/
public function getServiceTicket()
public function getServiceTicket() : string
{
return $this->serviceTicket;
}

/**
* @param string $serviceTicket
* @return GetServiceTicketResponse
* @return static
*/
public function withServiceTicket($serviceTicket)
public function withServiceTicket(string $serviceTicket) : static
{
$new = clone $this;
$new->serviceTicket = $serviceTicket;

return $new;
}
}

8 changes: 5 additions & 3 deletions src/CodeGenerator/ConfigProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public static function addRules(Config $config, array $specialClassesAndProperti
// We have to do this as the SOAP handler will erroneously create duplicate
// public properties when a value object extends another one with those
// same properties marked as "private".
$defaultPropertyAssembler = new Assembler\PropertyAssembler(PropertyGenerator::VISIBILITY_PROTECTED);
$defaultPropertyAssemblerOptions = (new Assembler\PropertyAssemblerOptions())
->withVisibility(PropertyGenerator::VISIBILITY_PRIVATE)
->withTypeHints(false);
$defaultPropertyAssembler = new Assembler\PropertyAssembler($defaultPropertyAssemblerOptions);

$arrayPropertyAssembler = new OpenEuropa\Assembler\ArrayPropertyAssembler(
(new OpenEuropa\Assembler\ArrayPropertyAssemblerOptions())
Expand All @@ -57,10 +60,9 @@ public static function addRules(Config $config, array $specialClassesAndProperti
);

$defaultGetterAssembler = new Assembler\GetterAssembler(
(new Assembler\GetterAssemblerOptions())
Assembler\GetterAssemblerOptions::create()
->withReturnType()
->withBoolGetters()
->withReturnNull()
);

$arrayGetterAssembler = new OpenEuropa\Assembler\ArrayGetterAssembler(
Expand Down
1 change: 1 addition & 0 deletions src/Notification/NotificationClassmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ public static function getCollection() : \Soap\ExtSoapEngine\Configuration\Class
);
}
}

Loading
Loading