Skip to content

Commit

Permalink
Merge pull request #8 from veewee/php82
Browse files Browse the repository at this point in the history
Add PHP82 + PSL2 Support
  • Loading branch information
veewee authored Nov 25, 2022
2 parents dbc55aa + 60907fa commit c622287
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analyzers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.0', '8.1']
php-versions: ['8.1', '8.2']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.0', '8.1']
php-versions: ['8.1', '8.2']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.0', '8.1']
php-versions: ['8.1', '8.2']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="psalm" version="^4.19.0" installed="4.19.0" location="./tools/psalm.phar" copy="true"/>
<phar name="php-cs-fixer" version="^3.3.2" installed="3.3.2" location="./tools/php-cs-fixer.phar" copy="true"/>
<phar name="psalm" version="^4.30.0" installed="4.30.0" location="./tools/psalm.phar" copy="true"/>
<phar name="php-cs-fixer" version="^3.13.0" installed="3.13.0" location="./tools/php-cs-fixer.phar" copy="true"/>
</phive>
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
"sort-packages": true
},
"require": {
"php": "^8.0",
"php": "~8.1.0 || ~8.2.0",
"ext-dom": "*",
"azjezz/psl": "^1.9",
"azjezz/psl": "^2.1",
"league/uri": "^6.5",
"league/uri-components": "^2.4",
"php-soap/xml": "^1.2",
"php-soap/xml": "^1.4",
"symfony/console": "^5.4|^6.0",
"veewee/xml": "~1.2"
"veewee/xml": "~2.2"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"psalm/plugin-symfony": "^3.1"
"psalm/plugin-symfony": "^4.0"
}
}
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
errorLevel="1"
resolveFromConfigFile="true"
strictBinaryOperands="true"
phpVersion="8.0"
phpVersion="8.1"
allowStringToStandInForClass="true"
rememberPropertyAssignmentsAfterCall="false"
skipChecksOnUnresolvableIncludes="false"
Expand Down
10 changes: 6 additions & 4 deletions src/Console/Command/FlattenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
namespace Soap\Wsdl\Console\Command;

use Exception;
use Psl\Filesystem;
use Psl\File;
use Psl\File\WriteMode;
use Soap\Wsdl\Console\Helper\ConfiguredLoader;
use Soap\Wsdl\Loader\CallbackLoader;
use Soap\Wsdl\Loader\FlatteningLoader;
Expand All @@ -16,6 +17,7 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use function Psl\Type\non_empty_string;

final class FlattenCommand extends Command
{
Expand Down Expand Up @@ -45,16 +47,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$input->getOption('loader'),
fn (WsdlLoader $loader) => $this->configureLoader($loader, $style)
);
$wsdl = $input->getArgument('wsdl');
$output = $input->getArgument('output');
$wsdl = non_empty_string()->coerce($input->getArgument('wsdl'));
$output = non_empty_string()->coerce($input->getArgument('output'));

$style->info('Flattening WSDL "'.$wsdl.'"');
$style->warning('This can take a while...');
$contents = $loader($wsdl);

$style->info('Downloaded the WSDL. Writing it to "'.$output.'".');

Filesystem\write_file($output, $contents);
File\write($output, $contents, WriteMode::TRUNCATE);

$style->success('Succesfully flattened your WSDL!');

Expand Down
4 changes: 2 additions & 2 deletions src/Console/Helper/ConfiguredLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Soap\Wsdl\Loader\StreamWrapperLoader;
use Soap\Wsdl\Loader\WsdlLoader;
use function Psl\invariant;
use function Psl\Type\object;
use function Psl\Type\instance_of;

final class ConfiguredLoader
{
Expand All @@ -31,7 +31,7 @@ public static function createFromConfig(?string $file, callable $configurator =
/** @var WsdlLoader $included */
$included = require $file;

$loader = object(WsdlLoader::class)->assert($included);
$loader = instance_of(WsdlLoader::class)->assert($included);
}

return $configurator ? $configurator($loader) : $loader;
Expand Down
4 changes: 2 additions & 2 deletions src/Xml/Configurator/FlattenXsdImports.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use VeeWee\Xml\Dom\Configurator\Configurator;
use VeeWee\Xml\Dom\Document;
use VeeWee\Xml\Exception\RuntimeException;
use function Psl\Type\instance_of;
use function Psl\Type\nullable;
use function Psl\Type\object;
use function VeeWee\Xml\Dom\Locator\Node\children;
use function VeeWee\Xml\Dom\Manipulator\Element\copy_named_xmlns_attributes;
use function VeeWee\Xml\Dom\Manipulator\Node\append_external_node;
Expand Down Expand Up @@ -183,7 +183,7 @@ private function registerSchemaInTypes(DOMElement $schema): void
$tns = $schema->getAttribute('targetNamespace');

$query = $tns ? './schema:schema[@targetNamespace=\''.$tns.'\']' : './schema:schema[not(@targetNamespace)]';
$existingSchema = nullable(object(DOMElement::class))
$existingSchema = nullable(instance_of(DOMElement::class))
->assert($xpath->query($query, $types)->first());

// If no schema exists yet: Add the newly loaded schema as a completely new schema in the WSDL types.
Expand Down
9 changes: 4 additions & 5 deletions src/Xml/Flattener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace Soap\Wsdl\Xml;

use Closure;
use DOMDocument;
use Soap\Wsdl\Loader\Context\FlatteningContext;
use Soap\Wsdl\Xml\Configurator\FlattenTypes;
Expand Down Expand Up @@ -32,11 +31,11 @@ public function __invoke(
when(
static fn (DOMDocument $document): bool => $document->documentElement->localName === 'definitions',
pipe(
Closure::fromCallable(new FlattenWsdlImports($location, $context)),
Closure::fromCallable(new FlattenTypes()),
Closure::fromCallable(new FlattenXsdImports($location, $context)),
(new FlattenWsdlImports($location, $context))(...),
(new FlattenTypes())(...),
(new FlattenXsdImports($location, $context))(...),
),
Closure::fromCallable(new FlattenXsdImports($location, $context))
(new FlattenXsdImports($location, $context))(...)
)
)
)->toXmlString();
Expand Down
8 changes: 5 additions & 3 deletions tests/Unit/Console/Helper/ConfiguredLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
namespace SoapTest\Wsdl\Unit\Console\Helper;

use PHPUnit\Framework\TestCase;
use Psl\File\WriteMode;
use Soap\Wsdl\Console\Helper\ConfiguredLoader;
use Soap\Wsdl\Loader\CallbackLoader;
use Soap\Wsdl\Loader\StreamWrapperLoader;
use function Psl\File\write;
use function Psl\Filesystem\delete_file;
use function Psl\Filesystem\write_file;

final class ConfiguredLoaderTest extends TestCase
{
Expand Down Expand Up @@ -60,12 +61,13 @@ static function (string $file) {
private function withLoaderFile(callable $execute): void
{
$file = tempnam(sys_get_temp_dir(), 'wsdlloader');
write_file(
write(
$file,
<<<EOPHP
<?php
return new \Soap\Wsdl\Loader\CallbackLoader(static fn () => 'loaded');
EOPHP
EOPHP,
WriteMode::TRUNCATE
);

try {
Expand Down
Binary file modified tools/php-cs-fixer.phar
Binary file not shown.
Binary file modified tools/psalm.phar
Binary file not shown.

0 comments on commit c622287

Please sign in to comment.