Skip to content

Commit 4576557

Browse files
authored
Merge pull request #10 from veewee/configurable-wsdl-tools
Make WSDL tools configurable by other packages
2 parents c622287 + 1974af9 commit 4576557

File tree

10 files changed

+100324
-11
lines changed

10 files changed

+100324
-11
lines changed

.github/workflows/analyzers.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
- name: Install dependencies
2323
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }}
2424
- name: Run the tests
25-
run: ./tools/psalm.phar
25+
run: ./vendor/bin/psalm

.phive/phars.xml

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="psalm" version="^4.30.0" installed="4.30.0" location="./tools/psalm.phar" copy="true"/>
43
<phar name="php-cs-fixer" version="^3.13.0" installed="3.13.0" location="./tools/php-cs-fixer.phar" copy="true"/>
54
</phive>

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ The final result is stored in a single WSDL file.
131131
This command performs some basic validations on the provided WSDL file.
132132
If your WSDL contains any imports, you'll have to flatten the WSDL into a single file first.
133133

134+
### Extensions
135+
136+
By installing additional packages from `php-soap`, additional commands will be added to the WSDL tools:
137+
138+
* [wsdl-reader](https://github.com/php-soap/wsdl-reader): Will install inspect commands that will give you a human-readable version of all information inside your WSDL.
139+
134140
### Custom WSDL Loader
135141

136142
By default, all CLI tools use the StreamWrapperLoader.

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
},
3838
"require-dev": {
3939
"phpunit/phpunit": "^9.5",
40-
"psalm/plugin-symfony": "^4.0"
40+
"psalm/plugin-symfony": "^5.0",
41+
"vimeo/psalm": "^5.9.0"
4142
}
4243
}

src/Console/AppFactory.php

+21
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99
final class AppFactory
1010
{
11+
/**
12+
* @psalm-suppress UndefinedClass
13+
* @var list<class-string>
14+
*/
15+
private static array $configurators = [
16+
\Soap\WsdlReader\Console\WsdlReaderConfigurator::class
17+
];
18+
1119
/**
1220
* @throws LogicException
1321
*/
@@ -19,6 +27,19 @@ public static function create(): Application
1927
new Command\ValidateCommand(),
2028
]);
2129

30+
self::configure($app);
31+
2232
return $app;
2333
}
34+
35+
private static function configure(Application $app): void
36+
{
37+
foreach (self::$configurators as $configurator) {
38+
if (!class_exists($configurator) || !is_a($configurator, Configurator::class, true)) {
39+
continue;
40+
}
41+
42+
$configurator::configure($app);
43+
}
44+
}
2445
}

src/Console/Configurator.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Soap\Wsdl\Console;
5+
6+
use Symfony\Component\Console\Application;
7+
8+
interface Configurator
9+
{
10+
public static function configure(Application $application): void;
11+
}

src/Xml/Configurator/FlattenWsdlImports.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __invoke(DOMDocument $document): DOMDocument
4242
$xml = Document::fromUnsafeDocument($document);
4343
$xpath = $xml->xpath(new WsdlPreset($xml));
4444

45-
$imports = $xpath->query('wsdl:import');
45+
$imports = $xpath->query('wsdl:import')->expectAllOfType(DOMElement::class);
4646
$imports->forEach(fn (DOMElement $import) => $this->importWsdlImportElement($import));
4747

4848
return $document;

src/Xml/Validator/SchemaSyntaxValidator.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@ public function __invoke(DOMDocument $document): IssueCollection
3030
$xml = Document::fromUnsafeDocument($document);
3131
$xpath = $xml->xpath(new WsdlPreset($xml));
3232

33-
return $xpath->query('//schema:schema')->reduce(
34-
fn (IssueCollection $issues, DOMElement $schema) => new IssueCollection(
35-
...$issues,
36-
...Document::fromXmlNode($schema)->validate(xsd_validator($this->xsd))
37-
),
38-
new IssueCollection()
39-
);
33+
return $xpath
34+
->query('//schema:schema')
35+
->expectAllOfType(DOMElement::class)
36+
->reduce(
37+
fn (IssueCollection $issues, DOMElement $schema) => new IssueCollection(
38+
...$issues,
39+
...Document::fromXmlNode($schema)->validate(xsd_validator($this->xsd))
40+
),
41+
new IssueCollection()
42+
);
4043
}
4144
}

tools/phpunit.phar

+100,272
Large diffs are not rendered by default.

tools/psalm.phar

-11.5 MB
Binary file not shown.

0 commit comments

Comments
 (0)