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-5162: Setup project for PHP 8.3 and port Notifications and Authentication classes #87

Merged
merged 14 commits into from
Jan 30, 2025
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
79 changes: 57 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,69 @@
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.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
run: docker-compose exec -T php ./vendor/bin/phpunit
code-sniffer:
runs-on: ubuntu-latest
strategy:
matrix:
php_version: ["8.1", "8.2"]
env:
PHP_VERSION: ${{ matrix.php_version }}
steps:
- name: clone
uses: actions/checkout@v2
- run: docker-compose up -d
- name: build
run: docker-compose exec -T php composer install
- name: test
run: docker-compose exec -T php ./vendor/bin/grumphp run

# - name: Run tests
# run: docker-compose exec -T php ./vendor/bin/phpunit
# While porting to 3.x run each test suite separately.
# We will remove this one the job is done.
- name: CodeGenerator
run: "docker-compose exec -T php ./vendor/bin/phpunit --testsuite CodeGenerator"
- name: ExtSoapEngine
run: "docker-compose exec -T php ./vendor/bin/phpunit --testsuite ExtSoapEngine"
- name: Notification
run: "docker-compose exec -T php ./vendor/bin/phpunit --testsuite Notification"
- name: Request
run: "docker-compose exec -T php ./vendor/bin/phpunit --testsuite Request"
- name: RequestClientFactoryTest
run: "docker-compose exec -T php ./vendor/bin/phpunit --testsuite RequestClientFactoryTest"
- name: SerializerTest
run: "docker-compose exec -T php ./vendor/bin/phpunit --testsuite SerializerTest"

# We will run codesniffer at the end of our refactoring effort.
# code-sniffer:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# php_version: ["8.3"]
# env:
# PHP_VERSION: ${{ matrix.php_version }}
# steps:
# - name: Clone repository
# uses: actions/checkout@v2
#
# - 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: 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",
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need the ^1 version?

"php-http/logger-plugin": "^1",
"php-http/message": "~1.13",
"phpro/soap-client": "~2.4",
"phpro/soap-client": "~3.4",
Copy link
Member

Choose a reason for hiding this comment

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

As I understand php constraint should be updated as we are testing in CI only with 8.3 version.

Copy link
Member Author

Choose a reason for hiding this comment

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

This has been done.

"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",
Comment on lines 21 to 23
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need to keep the support of the ~5.4 versions for symfony-related packages?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll remove this in the next ticket.

"veewee/xml": "^2.0"
"veewee/xml": "^3.0"
},
"require-dev": {
"colinodell/psr-testlogger": "^1.1",
sergepavle marked this conversation as resolved.
Show resolved Hide resolved
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
41 changes: 30 additions & 11 deletions config/soap-client-notification.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
<?php

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;
use Phpro\SoapClient\CodeGenerator\Rules;
use Phpro\SoapClient\CodeGenerator\Assembler;
use OpenEuropa\EPoetry\CodeGenerator as OpenEuropa;

$config = Config::create()
->setEngine($engine = DefaultEngineFactory::create(
ExtSoapOptions::defaults('./resources/notification.wsdl', [])
->disableWsdlCache()
))
$engine = CodeGeneratorEngineFactory::create('./resources/notification.wsdl');
return Config::create()
->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');

return ConfigProcessor::addRules($config);
->setClassMapNamespace('OpenEuropa\EPoetry\Notification')
->setRuleSet(new Rules\RuleSet([
new Rules\AssembleRule(new Assembler\PropertyAssembler(
Assembler\PropertyAssemblerOptions::create()
->withTypeHints(false)
)
),
new Rules\AssembleRule(new Assembler\FluentSetterAssembler(
Assembler\FluentSetterAssemblerOptions::create()
->withTypeHints()
)
),
new Rules\AssembleRule(new Assembler\GetterAssembler(
Assembler\GetterAssemblerOptions::create()
->withReturnType()
->withBoolGetters()
)
),
new Rules\AssembleRule(new OpenEuropa\Assembler\HasPropertyAssembler()),
new Rules\AssembleRule(new Assembler\ClassMapAssembler()),
new Rules\AssembleRule(new Assembler\ClientConstructorAssembler()),
new Rules\AssembleRule(new Assembler\ClientMethodAssembler()),
]));
13 changes: 5 additions & 8 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 All @@ -19,7 +16,7 @@
->setClassMapName('RequestClassmap')
->setClassMapNamespace('OpenEuropa\EPoetry\Request');

$config = ConfigProcessor::addRules($config, [
ConfigProcessor::addRules($config, [
'LinguisticSections' => ['linguisticSection'],
'Contacts' => ['contact'],
'Products' => ['product'],
Expand All @@ -29,7 +26,7 @@
'PrtDocuments' => ['document'],
'InformativeMessages' => ['message']
]);
$config = ConfigProcessor::addConstructorRule($config, [
ConfigProcessor::addConstructorRule($config, [
'ContactPersonIn',
'ContactPersonOut',
'LinguisticSectionOut',
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',
19 changes: 17 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,23 @@
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
</php>
<testsuites>
<testsuite name="unit">
<directory>./tests/</directory>
<testsuite name="CodeGenerator">
<directory>tests/CodeGenerator</directory>
</testsuite>
<testsuite name="ExtSoapEngine">
<directory>tests/ExtSoapEngine</directory>
</testsuite>
<testsuite name="Notification">
<directory>tests/Notification</directory>
</testsuite>
<testsuite name="Request">
<directory>tests/Request</directory>
</testsuite>
<testsuite name="RequestClientFactoryTest">
<file>tests/RequestClientFactoryTest.php</file>
</testsuite>
<testsuite name="SerializerTest">
<file>tests/SerializerTest.php</file>
</testsuite>
</testsuites>
</phpunit>
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
Comment on lines +24 to +25
Copy link

Choose a reason for hiding this comment

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

think we should indicate one or the other, usually its the interface, but if we need it to be the class then lets go with that

Copy link
Member Author

Choose a reason for hiding this comment

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

This code is generated by the library, check the readme here.

* @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;
}
}

Copy link

Choose a reason for hiding this comment

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

double newline

Copy link
Member Author

Choose a reason for hiding this comment

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

This code is generated by the library, check the readme here.

Loading
Loading