-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a way to replace types during code generation
- Loading branch information
Showing
17 changed files
with
323 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 0 additions & 69 deletions
69
src/Phpro/SoapClient/CodeGenerator/Config/ConfigInterface.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/Phpro/SoapClient/Soap/Metadata/Manipulators/TypeReplacer/ApacheMapReplacer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Phpro\SoapClient\Soap\Metadata\Manipulators\TypeReplacer; | ||
|
||
use Soap\Engine\Metadata\Model\TypeMeta; | ||
use Soap\Engine\Metadata\Model\XsdType; | ||
use Soap\WsdlReader\Metadata\Detector\ApacheMapDetector; | ||
use Soap\WsdlReader\Metadata\Predicate\IsOfType; | ||
|
||
final class ApacheMapReplacer implements TypeReplacer | ||
{ | ||
public function __invoke(XsdType $xsdType): XsdType | ||
{ | ||
$check = new IsOfType(ApacheMapDetector::NAMESPACE, 'Map'); | ||
if (!$check($xsdType)) { | ||
return $xsdType; | ||
} | ||
|
||
return $xsdType->copy('array') | ||
->withBaseType('array') | ||
->withMeta( | ||
// Mark as simple to make sure no additional types are generated for this type. | ||
static fn (TypeMeta $meta): TypeMeta => $meta->withIsSimple(true) | ||
); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...hpro/SoapClient/Soap/Metadata/Manipulators/TypeReplacer/ReplaceMethodTypesManipulator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Phpro\SoapClient\Soap\Metadata\Manipulators\TypeReplacer; | ||
|
||
use Phpro\SoapClient\Soap\Metadata\Manipulators\MethodsManipulatorInterface; | ||
use Soap\Engine\Metadata\Collection\MethodCollection; | ||
use Soap\Engine\Metadata\Collection\ParameterCollection; | ||
use Soap\Engine\Metadata\Model\Method; | ||
use Soap\Engine\Metadata\Model\Parameter; | ||
use function Psl\Vec\map; | ||
|
||
final class ReplaceMethodTypesManipulator implements MethodsManipulatorInterface | ||
{ | ||
public function __construct( | ||
private readonly TypeReplacer $typeReplacer | ||
) { | ||
} | ||
|
||
public function __invoke(MethodCollection $methods): MethodCollection | ||
{ | ||
return new MethodCollection( | ||
...map($methods, $this->replaceMethodTypes(...)) | ||
); | ||
} | ||
|
||
private function replaceMethodTypes(Method $method): Method | ||
{ | ||
return new Method( | ||
$method->getName(), | ||
new ParameterCollection(...map( | ||
$method->getParameters(), | ||
fn(Parameter $parameter): Parameter => new Parameter( | ||
$parameter->getName(), | ||
($this->typeReplacer)($parameter->getType()), | ||
) | ||
)), | ||
($this->typeReplacer)($method->getReturnType()), | ||
); | ||
} | ||
} |
Oops, something went wrong.