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

Add type declarations and require PHP 7.1+ as a consequence #49

Merged
merged 2 commits into from
Oct 28, 2020
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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ dist: trusty

jobs:
include:
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ $ composer require clue/soap-react:^1.0
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.

This project aims to run on any platform and thus only requires `ext-soap` and
supports running on PHP 7+.
supports running on PHP 7.1+.

## Tests

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
"psr-4": { "Clue\\Tests\\React\\Soap\\": "tests/" }
},
"require": {
"php": ">=7.0",
"php": ">=7.1",
"react/http": "^1.0",
"react/promise": "^2.1 || ^1.2",
"ext-soap": "*"
},
"require-dev": {
"clue/block-react": "^1.0",
"phpunit/phpunit": "^9.3 || ^6.5"
"phpunit/phpunit": "^9.3 || ^7.5"
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.legacy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
Expand Down
12 changes: 6 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Client
* @param string|null $wsdlContents
* @param array $options
*/
public function __construct(Browser $browser, $wsdlContents, array $options = array())
public function __construct(Browser $browser, ?string $wsdlContents, array $options = array())
{
$wsdl = $wsdlContents !== null ? 'data://text/plain;base64,' . base64_encode($wsdlContents) : null;

Expand Down Expand Up @@ -192,7 +192,7 @@ public function __construct(Browser $browser, $wsdlContents, array $options = ar
* @param mixed[] $args
* @return PromiseInterface Returns a Promise<mixed, Exception>
*/
public function soapCall($name, $args)
public function soapCall(string $name, array $args): PromiseInterface
{
try {
$request = $this->encoder->encode($name, $args);
Expand Down Expand Up @@ -226,7 +226,7 @@ function (ResponseInterface $response) use ($decoder, $name) {
*
* @return string[]|null
*/
public function getFunctions()
public function getFunctions(): ?array
{
return $this->encoder->__getFunctions();
}
Expand All @@ -240,7 +240,7 @@ public function getFunctions()
*
* @return string[]|null
*/
public function getTypes()
public function getTypes(): ?array
{
return $this->encoder->__getTypes();
}
Expand Down Expand Up @@ -281,7 +281,7 @@ public function getTypes()
* @throws \SoapFault if given function does not exist
* @see self::getFunctions()
*/
public function getLocation($function)
public function getLocation($function): string
{
if (is_int($function)) {
$functions = $this->getFunctions();
Expand Down Expand Up @@ -315,7 +315,7 @@ public function getLocation($function)
* @return self
* @see self::getLocation()
*/
public function withLocation($location)
public function withLocation(string $location): self
{
$client = clone $this;
$client->encoder = clone $this->encoder;
Expand Down
8 changes: 3 additions & 5 deletions src/Protocol/ClientDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Clue\React\Soap\Protocol;

use \SoapClient;

/**
* @internal
*/
final class ClientDecoder extends SoapClient
final class ClientDecoder extends \SoapClient
{
private $response = null;

Expand All @@ -19,7 +17,7 @@ final class ClientDecoder extends SoapClient
* @return mixed
* @throws \SoapFault if response indicates a fault (error condition) or is invalid
*/
public function decode($function, $response)
public function decode(string $function, string $response)
{
// Temporarily save response internally for further processing
$this->response = $response;
Expand All @@ -42,7 +40,7 @@ public function decode($function, $response)
* the return code in this method. This will implicitly be invoked by the
* call to `pseudoCall()` in the above `decode()` method.
*
* @see SoapClient::__doRequest()
* @see \SoapClient::__doRequest()
*/
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
Expand Down
12 changes: 6 additions & 6 deletions src/Protocol/ClientEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

namespace Clue\React\Soap\Protocol;

use \SoapClient;
use Psr\Http\Message\RequestInterface;
use RingCentral\Psr7\Request;

/**
* @internal
*/
final class ClientEncoder extends SoapClient
final class ClientEncoder extends \SoapClient
{
private $request = null;

/**
* Encodes the given RPC function name and arguments as a SOAP request
*
* @param string $name
* @param array $args
* @return \Psr\Http\Message\RequestInterface
* @param array $args
* @return RequestInterface
* @throws \SoapFault if request is invalid according to WSDL
*/
public function encode($name, $args)
public function encode(string $name, array $args): RequestInterface
{
$this->__soapCall($name, $args);

Expand All @@ -40,7 +40,7 @@ public function encode($name, $args)
* This will implicitly be invoked by the call to `__soapCall()` in the
* above `encode()` method.
*
* @see SoapClient::__doRequest()
* @see \SoapClient::__doRequest()
*/
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(Client $client)
* @param mixed[] $args
* @return PromiseInterface
*/
public function __call($name, $args)
public function __call(string $name, array $args): PromiseInterface
{
return $this->client->soapCall($name, $args);
}
Expand Down
19 changes: 4 additions & 15 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testBlzService()

$result = Block\await($promise, $this->loop);

$this->assertIsTypeObject($result);
$this->assertIsObject($result);
$this->assertTrue(isset($result->details));
$this->assertTrue(isset($result->details->bic));
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public function testBlzServiceWithSoapV12()

$result = Block\await($promise, $this->loop);

$this->assertIsTypeObject($result);
$this->assertIsObject($result);
$this->assertTrue(isset($result->details));
$this->assertTrue(isset($result->details->bic));
}
Expand All @@ -119,7 +119,7 @@ public function testBlzServiceNonWsdlModeReturnedWithoutOuterResultStructure()

$result = Block\await($promise, $this->loop);

$this->assertIsTypeObject($result);
$this->assertIsObject($result);
$this->assertFalse(isset($result->details));
$this->assertTrue(isset($result->bic));
}
Expand Down Expand Up @@ -249,17 +249,6 @@ public function testWithLocationRestoredToOriginalResolves()
$promise = $api->getBank(array('blz' => '12070000'));

$result = Block\await($promise, $this->loop);
$this->assertIsTypeObject($result);
}

public function assertIsTypeObject($actual)
{
if (method_exists($this, 'assertInternalType')) {
// legacy PHPUnit 4 - PHPUnit 7.5
$this->assertInternalType('object', $actual);
} else {
// PHPUnit 7.5+
$this->assertIsObject($actual);
}
$this->assertIsObject($result);
}
}