Skip to content

Commit d2ac19e

Browse files
committed
Merge branch 'release/5.0.4'
2 parents f59c085 + 3816218 commit d2ac19e

File tree

7 files changed

+63
-3
lines changed

7 files changed

+63
-3
lines changed

.github/workflows/sonars.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Monitor coverage
3434
uses: slavcodev/coverage-monitor-action@v1
3535
with:
36-
github_token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
3737
coverage_path: coverage.xml
3838
threshold_alert: 95
3939
threshold_warning: 90
@@ -44,5 +44,5 @@ jobs:
4444
- name: SonarCloud Scan
4545
uses: SonarSource/sonarcloud-github-action@master
4646
env:
47-
GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4848
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOG
22

3+
## 5.0.4 - 2024/02/05
4+
- PR #51 - Fix overriding the custom SoapClient class
5+
36
## 5.0.3 - 2023/02/09
47
- PR #38 - type checking exception raised in php8
58

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
{
4949
"name": "maurobn",
5050
"role": "Contributor"
51+
},
52+
{
53+
"name": "Christo Yovev",
54+
"role": "Contributor"
5155
}
5256
],
5357
"support" : {

src/AbstractSoapClientBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected static function canInstantiateSoapClientWithOptions(array $wsdlOptions
100100
*/
101101
public function getSoapClientClassName(?string $soapClientClassName = null): string
102102
{
103-
$className = self::DEFAULT_SOAP_CLIENT_CLASS;
103+
$className = static::DEFAULT_SOAP_CLIENT_CLASS;
104104
if (!empty($soapClientClassName) && is_subclass_of($soapClientClassName, SoapClient::class)) {
105105
$className = $soapClientClassName;
106106
}

tests/CustomSoapClientService.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WsdlToPhp\PackageBase\Tests;
6+
7+
use WsdlToPhp\PackageBase\AbstractSoapClientBase;
8+
9+
/**
10+
* Services can specify a custom SoapClient class
11+
* to be used instead of PHP default by overriding
12+
* the constant below.
13+
*
14+
* @see \WsdlToPhp\PackageBase\SoapClientInterface
15+
* @see \WsdlToPhp\PackageBase\AbstractSoapClientBase :: getSoapClientClassName()
16+
*/
17+
18+
class CustomSoapClientService extends AbstractSoapClientBase
19+
{
20+
21+
/**
22+
* Custom SoapClient class used for current service.
23+
*/
24+
const DEFAULT_SOAP_CLIENT_CLASS = Client::class;
25+
26+
}

tests/DefaultSoapClientService.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WsdlToPhp\PackageBase\Tests;
6+
7+
use WsdlToPhp\PackageBase\AbstractSoapClientBase;
8+
9+
/**
10+
* By default all services extending the packagebase's
11+
* abstract class rely on PHP's default SoapClient.
12+
*/
13+
14+
class DefaultSoapClientService extends AbstractSoapClientBase
15+
{
16+
17+
}

tests/SoapClientTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ public function testSoapClientNameDefault(): void
2525
$this->assertSame(Client::class, $soapClient->getSoapClientClassName(Client::class));
2626
}
2727

28+
public function testCustomSoapClientNameReadFromConstant()
29+
{
30+
$defaultService = new DefaultSoapClientService();
31+
$customService = new CustomSoapClientService();
32+
33+
$this->assertSame(SoapClientBase::class, $defaultService->getSoapClientClassName());
34+
$this->assertSame(Client::class, $customService->getSoapClientClassName());
35+
}
36+
2837
public function testSoapClient(): void
2938
{
3039
$soapClient = new SoapClient([
@@ -489,4 +498,5 @@ public function testGetOutputHeadersWithoutRequestMustReturnAnEmptyArray(): void
489498
$this->assertTrue(is_array($soapClient->getOutputHeaders()));
490499
$this->assertEmpty($soapClient->getOutputHeaders());
491500
}
501+
492502
}

0 commit comments

Comments
 (0)