Skip to content

Commit

Permalink
Merge pull request #6 from php-soap/improved-types
Browse files Browse the repository at this point in the history
Improve type-safety
  • Loading branch information
veewee authored Dec 12, 2021
2 parents a4720b5 + c89d933 commit 66d669f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Metadata/MethodsParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function parse(SoapClient $client): MethodCollection
{
return new MethodCollection(...array_map(
fn (string $methodString) => $this->parseMethodFromString($methodString),
array_values($client->__getFunctions())
array_values((array)$client->__getFunctions())
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/TypesParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(XsdTypeCollection $xsdTypes)
public function parse(SoapClient $client): TypeCollection
{
$collected = [];
$soapTypes = $client->__getTypes();
$soapTypes = (array) $client->__getTypes();
foreach ($soapTypes as $soapType) {
$properties = [];
$lines = explode("\n", $soapType);
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/XsdTypesParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function default(): self
public function parse(SoapClient $client): XsdTypeCollection
{
$collected = [];
$soapTypes = $client->__getTypes();
$soapTypes = (array) $client->__getTypes();
foreach ($soapTypes as $soapType) {
if ($type = $this->detectXsdType($soapType)) {
$collected[] = $type;
Expand Down
12 changes: 12 additions & 0 deletions stubs/SoapClient.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,16 @@ class SoapClient
* This can be removed once it is fixed in psalm
*/
public function __doRequest (string $request, string $location, string $action, int $version, bool $one_way = false): ?string {}

/**
* @see https://github.com/vimeo/psalm/pull/7140
* This can be removed once it is fixed in psalm
*/
public function __getTypes (): ?array {}

/**
* @see https://github.com/vimeo/psalm/pull/7140
* This can be removed once it is fixed in psalm
*/
public function __getFunctions (): ?array {}
}

0 comments on commit 66d669f

Please sign in to comment.