Skip to content

Commit d30cecc

Browse files
committed
Merge branch 'release/1.0.10'
2 parents 4829b0e + d90364e commit d30cecc

14 files changed

+193
-88
lines changed

.php_cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ return PhpCsFixer\Config::create()
99
->setUsingCache(false)
1010
->setRules(array(
1111
'@PSR2' => true,
12+
'array_syntax' => [
13+
'syntax' => 'short',
14+
],
1215
'binary_operator_spaces' => true,
1316
'no_whitespace_in_blank_line' => true,
1417
'ternary_operator_spaces' => true,

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ language: php
22

33
sudo: false
44

5-
php:
6-
- 5.3
7-
- 5.4
8-
- 5.5
9-
- 5.6
10-
- 7.0
11-
- 7.1
5+
matrix:
6+
include:
7+
- php: 5.4
8+
- php: 5.5
9+
- php: 5.6
10+
- php: 7.0
11+
- php: 7.1
1212

1313
before_install:
1414
- composer self-update

CHANGELOG.md

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

3+
## 1.0.10
4+
- Issue #10 - Improve AbstractStructArrayBase class
5+
- Issue #13 - Feature request: AbstractStructBase implement JsonSerializable
6+
- Add Code of Conduct and Contributing files
7+
38
## 1.0.9
49
- Improve code, remove @ usage in generic __set_State method, add SensioLabs Insight badge
510

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
We accept contributions via pull requests on [Github].
6+
Please make all pull requests to the `develop` branch, not the `master` branch.
7+
8+
## Pull Requests
9+
10+
- **Create an issue** - Explain as detailed as possible the issue you encountered so we can understand the context of your pull request
11+
- **[Symfony Coding Standard]** - The easiest way to apply the conventions is to run `composer lint`
12+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
13+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
14+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
15+
- **Create feature branches** - Don't ask us to pull from your master branch.
16+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
17+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
18+
19+
## Running Tests
20+
21+
``` bash
22+
$ composer test
23+
```
24+
25+
**Happy coding**!
26+
27+
[Github]: https://github.com/wsdltophp/packagebase
28+
[Symfony Coding Standard]: http://symfony.com/doc/current/contributing/code/standards.html

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Package Base
2+
3+
> Classes that are used by the classes generated by the [PackageGenerator](https://github.com/WsdlToPhp/PackageGenerator) project to ease the SoapClient UX.
4+
25
[![Latest Stable Version](https://poser.pugx.org/wsdltophp/packagebase/version.png)](https://packagist.org/packages/wsdltophp/packagebase)
36
[![Total Downloads](https://poser.pugx.org/wsdltophp/packagebase/downloads)](https://packagist.org/packages/wsdltophp/packagebase)
47
[![Build Status](https://api.travis-ci.org/WsdlToPhp/PackageBase.svg)](https://travis-ci.org/WsdlToPhp/PackageBase)
@@ -9,8 +12,11 @@
912
[![StyleCI](https://styleci.io/repos/38760239/shield)](https://styleci.io/repos/38760239)
1013
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/bfbc0c8f-5793-489b-8151-36ea149ec98d/mini.png)](https://insight.sensiolabs.com/projects/bfbc0c8f-5793-489b-8151-36ea149ec98d)
1114

15+
The goal is to provide generic and useful classes that are on top of the classes generated by the [PackageGenerator](https://github.com/WsdlToPhp/PackageGenerator) project.
16+
17+
For example, it allows to easily loop through the array elements of a SOAP result object property, it allows to easily set HTTP and SOAP headers for a SOAP request and it allows to easily populate an object from its array state representation.
18+
1219
## Main features
13-
This project contains base classes used as parent class by the generated classes from [PackageGenerator](https://github.com/WsdlToPhp/PackageGenerator):
1420
- [Interfaces](#the-interfaces)
1521
- [StructInterface](#structinterface)
1622
- [StructArrayInterface](#structarrayinterface)
@@ -93,10 +99,11 @@ Here are the methods that must be implemented and why:
9399
### AbstractStructBase
94100
#### Description
95101
This class is the base class for any ```StructType``` class generated by [PackageGenerator](https://github.com/WsdlToPhp/PackageGenerator). It implements our [StructInterface](#structinterface) interface.
96-
It defines three methods:
102+
It defines four methods:
97103
- **__set_state($array)**: Useful when you load the string representation of an object that you stored using ```var_export```. It also allows you to ease the instanciation of an object that contains many properties which would be hard to instanciate using the ```__construct``` method. You can see ```__set_state``` as an hydratation method.
98104
- **_set($name, $value)**: As magic method ```__set``` but used by the ```__set_state``` method. Plus, defining ```__set``` method on used class by the classmap option for the [SoapClient](http://php.net/manual/en/class.soapclient.php) breaks the correct hydratation of your received objects.
99-
- **_get($name)**: As magic method ```__get```. Used by our [AbstractStructArrayBase](#abstractstructarraybase) class
105+
- **_get($name)**: As magic method ```__get```. Used by our [AbstractStructArrayBase](#abstractstructarraybase) class.
106+
- **jsonSerialize()**: by implementing the [\JsonSerializable](http://php.net/manual/en/class.jsonserializable.php) interface, it implements this method that allows to pass the object to the [json_encode](http://php.net/manual/en/function.json-encode.php) method so it will return the properties of the current object in an array.
100107

101108
#### Usage
102109
```php

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@
2121
"email" : "[email protected]"
2222
},
2323
"require": {
24-
"php" : ">=5.3.3"
24+
"php" : ">=5.4"
25+
},
26+
"scripts": {
27+
"test": "vendor/bin/phpunit",
28+
"lint": "vendor/bin/php-cs-fixer fix"
2529
},
2630
"require-dev": {
2731
"friendsofphp/php-cs-fixer": "~2.0",
28-
"phpunit/phpunit": "~4.0"
32+
"phpunit/phpunit": "^4.8 || ^6.0"
2933
},
3034
"autoload": {
3135
"psr-4": {

src/AbstractSoapClientBase.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ abstract class AbstractSoapClientBase implements SoapClientInterface
2626
* @param array $wsdlOptions
2727
* @param bool $resetSoapClient allows to disable the SoapClient redefinition
2828
*/
29-
public function __construct(array $wsdlOptions = array(), $resetSoapClient = true)
29+
public function __construct(array $wsdlOptions = [], $resetSoapClient = true)
3030
{
31-
$this->setLastError(array());
31+
$this->setLastError([]);
3232
/**
3333
* Init soap Client
3434
* Set default values
@@ -65,7 +65,7 @@ public static function setSoapClient(\SoapClient $soapClient)
6565
*/
6666
public function initSoapClient(array $options)
6767
{
68-
$wsdlOptions = array();
68+
$wsdlOptions = [];
6969
$defaultWsdlOptions = static::getDefaultWsdlOptions();
7070
foreach ($defaultWsdlOptions as $optionName => $optionValue) {
7171
if (array_key_exists($optionName, $options) && !empty($options[$optionName])) {
@@ -131,7 +131,7 @@ public function getSoapClientClassName($soapClientClassName = null)
131131
*/
132132
public static function getDefaultWsdlOptions()
133133
{
134-
return array(
134+
return [
135135
self::WSDL_CLASSMAP => null,
136136
self::WSDL_CACHE_WSDL => WSDL_CACHE_NONE,
137137
self::WSDL_COMPRESSION => null,
@@ -156,7 +156,7 @@ public static function getDefaultWsdlOptions()
156156
self::WSDL_PASSPHRASE => null,
157157
self::WSDL_AUTHENTICATION => null,
158158
self::WSDL_SSL_METHOD => null,
159-
);
159+
];
160160
}
161161
/**
162162
* Allows to set the SoapClient location to call
@@ -270,7 +270,7 @@ public static function getFormatedXml($string, $asDomDocument = false)
270270
public static function convertStringHeadersToArray($headers)
271271
{
272272
$lines = explode("\r\n", $headers);
273-
$headers = array();
273+
$headers = [];
274274
foreach ($lines as $line) {
275275
if (strpos($line, ':')) {
276276
$headerParts = explode(':', $line);
@@ -294,7 +294,7 @@ public static function convertStringHeadersToArray($headers)
294294
public function setSoapHeader($nameSpace, $name, $data, $mustUnderstand = false, $actor = null)
295295
{
296296
if (static::getSoapClient()) {
297-
$defaultHeaders = (isset(static::getSoapClient()->__default_headers) && is_array(static::getSoapClient()->__default_headers)) ? static::getSoapClient()->__default_headers : array();
297+
$defaultHeaders = (isset(static::getSoapClient()->__default_headers) && is_array(static::getSoapClient()->__default_headers)) ? static::getSoapClient()->__default_headers : [];
298298
foreach ($defaultHeaders as $index => $soapHeader) {
299299
if ($soapHeader->name === $name) {
300300
unset($defaultHeaders[$index]);
@@ -326,13 +326,13 @@ public function setHttpHeader($headerName, $headerValue)
326326
if (static::getSoapClient() && !empty($headerName)) {
327327
$streamContext = $this->getStreamContext();
328328
if ($streamContext === null) {
329-
$options = array();
330-
$options['http'] = array();
329+
$options = [];
330+
$options['http'] = [];
331331
$options['http']['header'] = '';
332332
} else {
333333
$options = stream_context_get_options($streamContext);
334334
if (!array_key_exists('http', $options) || !is_array($options['http'])) {
335-
$options['http'] = array();
335+
$options['http'] = [];
336336
$options['http']['header'] = '';
337337
} elseif (!array_key_exists('header', $options['http'])) {
338338
$options['http']['header'] = '';
@@ -343,7 +343,7 @@ public function setHttpHeader($headerName, $headerValue)
343343
/**
344344
* Ensure there is only one header entry for this header name
345345
*/
346-
$newLines = array();
346+
$newLines = [];
347347
foreach ($lines as $line) {
348348
if (!empty($line) && strpos($line, $headerName) === false) {
349349
array_push($newLines, $line);
@@ -386,7 +386,7 @@ public function getStreamContext()
386386
*/
387387
public function getStreamContextOptions()
388388
{
389-
$options = array();
389+
$options = [];
390390
$context = $this->getStreamContext();
391391
if ($context !== null) {
392392
$options = stream_context_get_options($context);

0 commit comments

Comments
 (0)