Skip to content

Commit c0142e4

Browse files
committed
Merge branch 'release/2.0.3'
2 parents 41a71b5 + 0c7889e commit c0142e4

File tree

9 files changed

+49
-54
lines changed

9 files changed

+49
-54
lines changed

.travis.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

CHANGELOG.md

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

3+
## 2.0.3 - 2022/03/24
4+
- Update badges
5+
- Remove Travis CI settings
6+
- Add PHPStan analyze
7+
- Minor source code improvements
8+
39
## 2.0.2 - 2021/02/03
410
- Review .php_cs settings, apply PHP CS Fixer
511
- Fix minor typo

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
55
[![License](https://poser.pugx.org/wsdltophp/wssecurity/license)](https://packagist.org/packages/wsdltophp/wssecurity)
66
[![Latest Stable Version](https://poser.pugx.org/wsdltophp/wssecurity/version.png)](https://packagist.org/packages/wsdltophp/wssecurity)
7-
[![Build Status](https://travis-ci.com/WsdlToPhp/WsSecurity.svg)](https://travis-ci.com/github/WsdlToPhp/WsSecurity)
7+
[![TeamCity build status](https://teamcity.mikael-delsol.fr/app/rest/builds/buildType:id:WsSecurity_Build/statusIcon.svg)](https://github.com/WsdlToPhp/WsSecurity)
88
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/WsdlToPhp/WsSecurity/badges/quality-score.png)](https://scrutinizer-ci.com/g/WsdlToPhp/WsSecurity/)
99
[![Code Coverage](https://scrutinizer-ci.com/g/WsdlToPhp/WsSecurity/badges/coverage.png)](https://scrutinizer-ci.com/g/WsdlToPhp/WsSecurity/)
1010
[![Total Downloads](https://poser.pugx.org/wsdltophp/wssecurity/downloads)](https://packagist.org/packages/wsdltophp/wssecurity)
1111
[![StyleCI](https://styleci.io/repos/43811404/shield)](https://styleci.io/repos/43811404)
12-
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/1cc28292-0f49-47eb-b2ca-4bdd6c0223f1/mini.png)](https://insight.sensiolabs.com/projects/1cc28292-0f49-47eb-b2ca-4bdd6c0223f1)
12+
[![SymfonyInsight](https://insight.symfony.com/projects/57dd432d-3d42-449f-baa0-4568abeb3a32/mini.svg)](https://insight.symfony.com/projects/57dd432d-3d42-449f-baa0-4568abeb3a32)
1313

1414
## How to use it
1515
This repository contains multiple classes that may be used indepdently but for now it is easier/better to only use the WsSecurity class.

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@
3535
"email" : "contact@wsdltophp.com"
3636
},
3737
"require" : {
38-
"php" : ">=7.4",
39-
"ext-soap": "*",
40-
"ext-dom": "*"
38+
"php": ">=7.4",
39+
"ext-dom": "*",
40+
"ext-soap": "*"
4141
},
4242
"scripts": {
4343
"test": "vendor/bin/phpunit",
44-
"lint": "vendor/bin/php-cs-fixer fix --ansi --diff --verbose"
44+
"lint": "vendor/bin/php-cs-fixer fix --ansi --diff --verbose",
45+
"phpstan": "vendor/bin/phpstan analyze src --level=6"
4546
},
4647
"require-dev": {
4748
"friendsofphp/php-cs-fixer": "^2.0",
49+
"phpstan/phpstan": "^1.4",
4850
"phpunit/phpunit": "^9"
4951
},
5052
"autoload" : {
@@ -61,4 +63,3 @@
6163
"sort-packages": true
6264
}
6365
}
64-

src/Element.php

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class Element
3535

3636
/**
3737
* Array of attributes that must contains the element.
38+
*
39+
* @var array<string, mixed>
3840
*/
3941
protected array $attributes = [];
4042

@@ -58,6 +60,10 @@ class Element
5860
*/
5961
protected static ?DOMDocument $dom = null;
6062

63+
/**
64+
* @param mixed $value
65+
* @param array<string, mixed> $attributes
66+
*/
6167
public function __construct(string $name, string $namespace, $value = null, array $attributes = [])
6268
{
6369
$this
@@ -73,7 +79,7 @@ public function __construct(string $name, string $namespace, $value = null, arra
7379
*
7480
* @param bool $asDomElement returns elements as a \DOMElement or as a string
7581
*
76-
* @return DOMElement|string
82+
* @return DOMElement|string|false
7783
*/
7884
protected function __toSend(bool $asDomElement = false)
7985
{
@@ -87,38 +93,46 @@ protected function __toSend(bool $asDomElement = false)
8793
->appendAttributesToElementToSend($element)
8894
;
8995

90-
// Returns element content
91-
if ($asDomElement) {
92-
return $element;
93-
}
94-
95-
return self::getDom()->saveXML($element);
96+
return $asDomElement ? $element : self::getDom()->saveXML($element);
9697
}
9798

9899
public function getName(): string
99100
{
100101
return $this->name;
101102
}
102103

103-
public function setName($name): self
104+
public function setName(string $name): self
104105
{
105106
$this->name = $name;
106107

107108
return $this;
108109
}
109110

111+
/**
112+
* @return array<string, mixed>
113+
*/
110114
public function getAttributes(): array
111115
{
112116
return $this->attributes;
113117
}
114118

119+
/**
120+
* @param array<string, mixed> $attributes
121+
*
122+
* @return Element
123+
*/
115124
public function setAttributes(array $attributes): self
116125
{
117126
$this->attributes = $attributes;
118127

119128
return $this;
120129
}
121130

131+
/**
132+
* @param mixed $value
133+
*
134+
* @return $this
135+
*/
122136
public function setAttribute(string $name, $value): self
123137
{
124138
$this->attributes[$name] = $value;
@@ -192,8 +206,10 @@ public function setTimestampValue(int $timestampValue): self
192206

193207
/**
194208
* Returns the element to send as WS-Security header.
209+
*
210+
* @return DOMElement|string|false
195211
*/
196-
public function toSend(): string
212+
public function toSend()
197213
{
198214
self::setDom(new DOMDocument('1.0', 'UTF-8'));
199215

@@ -228,6 +244,9 @@ protected function appendElementToElementToSend(Element $value, DOMElement $elem
228244
}
229245
}
230246

247+
/**
248+
* @param array<mixed> $values
249+
*/
231250
protected function appendValuesToElementToSend(array $values, DOMElement $element): void
232251
{
233252
foreach ($values as $value) {

src/Security.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(bool $mustUnderstand = false, ?string $actor = null,
3838
*
3939
* @param bool $asDomElement returns elements as a DOMElement or as a string
4040
*
41-
* @return DOMElement|string
41+
* @return DOMElement|string|false
4242
*/
4343
protected function __toSend(bool $asDomElement = false)
4444
{

src/Timestamp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(string $namespace = self::NS_WSSU)
2424
*
2525
* @param bool $asDomElement returns elements as a DOMElement or as a string
2626
*
27-
* @return DOMElement|string
27+
* @return DOMElement|string|false
2828
*/
2929
protected function __toSend(bool $asDomElement = false)
3030
{

src/UsernameToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(?string $id = null, string $namespace = self::NS_WSS
3232
*
3333
* @param bool $asDomElement returns elements as a DOMElement or as a string
3434
*
35-
* @return DOMElement|string
35+
* @return DOMElement|string|false
3636
*/
3737
protected function __toSend(bool $asDomElement = false)
3838
{

src/WsSecurity.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public function getSecurity(): ?Security
3838
return $this->security;
3939
}
4040

41+
/**
42+
* @return SoapHeader|SoapVar
43+
*/
4144
public static function createWsSecuritySoapHeader(
4245
string $username,
4346
string $password,
@@ -81,7 +84,7 @@ protected function setUsernameToken(string $username, ?string $usernameId = null
8184

8285
protected function setPassword(string $password, bool $passwordDigest = false, int $addCreated = 0): self
8386
{
84-
$this->getUsernameToken()->setPassword(new Password($password, $passwordDigest ? Password::TYPE_PASSWORD_DIGEST : Password::TYPE_PASSWORD_TEXT, is_bool($addCreated) ? 0 : ($addCreated > 0 ? $addCreated : 0)));
87+
$this->getUsernameToken()->setPassword(new Password($password, $passwordDigest ? Password::TYPE_PASSWORD_DIGEST : Password::TYPE_PASSWORD_TEXT, $addCreated));
8588

8689
return $this;
8790
}

0 commit comments

Comments
 (0)