From c5c2d6e4fb77aef3ccec261fe2dcde55bac9c8ac Mon Sep 17 00:00:00 2001 From: Jean Baptiste Noblot Date: Fri, 24 Nov 2017 13:36:53 +0100 Subject: [PATCH] Fix Issue #26 Strict Typing (#80) Added strict typing --- src/Phpro/SoapClient/Client.php | 10 ++--- src/Phpro/SoapClient/ClientBuilder.php | 4 +- src/Phpro/SoapClient/ClientFactory.php | 7 ++-- .../SoapClient/ClientFactoryInterface.php | 2 +- .../Assembler/AssemblerInterface.php | 2 +- .../Assembler/ClassMapAssembler.php | 6 +-- .../Assembler/ClientMethodAssembler.php | 9 ++-- .../Assembler/ConstructorAssembler.php | 4 +- .../Assembler/ExtendAssembler.php | 2 +- .../Assembler/FinalClassAssembler.php | 2 +- .../Assembler/FluentSetterAssembler.php | 2 +- .../Assembler/ImmutableSetterAssembler.php | 2 +- .../Assembler/InterfaceAssembler.php | 2 +- .../Assembler/IteratorAssembler.php | 4 +- .../Assembler/JsonSerializableAssembler.php | 2 +- .../Assembler/PropertyAssembler.php | 4 +- .../Assembler/RequestAssembler.php | 2 +- .../Assembler/ResultAssembler.php | 2 +- .../Assembler/ResultProviderAssembler.php | 6 +-- .../Assembler/SetterAssembler.php | 2 +- .../Assembler/TraitAssembler.php | 8 ++-- .../CodeGenerator/Assembler/UseAssembler.php | 14 +++++-- .../CodeGenerator/ClassMapGenerator.php | 2 +- .../CodeGenerator/ClientGenerator.php | 4 +- .../CodeGenerator/Config/Config.php | 28 ++++++------- .../CodeGenerator/Config/ConfigInterface.php | 12 +++--- .../CodeGenerator/Context/ClassMapContext.php | 4 +- .../CodeGenerator/Context/PropertyContext.php | 6 +-- .../CodeGenerator/Context/TypeContext.php | 4 +- .../CodeGenerator/GeneratorInterface.php | 2 +- .../CodeGenerator/Model/Property.php | 10 ++--- .../SoapClient/CodeGenerator/Model/Type.php | 20 +++++---- .../CodeGenerator/Model/TypeMap.php | 8 ++-- .../CodeGenerator/Rules/AssembleRule.php | 2 +- .../CodeGenerator/Rules/MultiRule.php | 2 +- .../Rules/PropertynameMatchesRule.php | 6 +-- .../CodeGenerator/Rules/RuleInterface.php | 2 +- .../CodeGenerator/Rules/TypeMapRule.php | 4 +- .../Rules/TypenameMatchesRule.php | 4 +- .../CodeGenerator/TypeGenerator.php | 2 +- .../CodeGenerator/Util/Normalizer.php | 38 +++++++++-------- src/Phpro/SoapClient/Console/Application.php | 2 +- .../Console/Command/GenerateTypesCommand.php | 10 ++--- src/Phpro/SoapClient/Event/FaultEvent.php | 6 +-- src/Phpro/SoapClient/Event/RequestEvent.php | 8 ++-- src/Phpro/SoapClient/Event/ResponseEvent.php | 6 +-- .../Exception/AssemblerException.php | 2 +- .../Exception/InvalidArgumentException.php | 6 +-- .../SoapClient/Exception/RuntimeException.php | 4 ++ .../SoapClient/Exception/SoapException.php | 2 +- .../SoapClient/Exception/WsdlException.php | 6 +-- .../SoapClient/Middleware/Middleware.php | 2 +- .../Middleware/RemoveEmptyNodesMiddleware.php | 2 +- .../SoapClient/Middleware/WsseMiddleware.php | 2 +- src/Phpro/SoapClient/Plugin/LogPlugin.php | 2 +- .../SoapClient/Plugin/ValidatorPlugin.php | 2 +- .../SoapClient/Soap/ClassMap/ClassMap.php | 10 ++--- .../Soap/ClassMap/ClassMapCollection.php | 16 +++---- .../Soap/ClassMap/ClassMapInterface.php | 4 +- .../Builder/Psr7RequestBuilder.php | 18 ++++---- .../Soap/HttpBinding/LastRequestInfo.php | 10 +++-- src/Phpro/SoapClient/Soap/SoapClient.php | 42 +++++++++---------- .../SoapClient/Soap/SoapClientFactory.php | 2 +- .../TypeConverter/DateTimeTypeConverter.php | 8 ++-- .../Soap/TypeConverter/DateTypeConverter.php | 8 ++-- .../TypeConverter/DecimalTypeConverter.php | 8 ++-- .../TypeConverter/DoubleTypeConverter.php | 8 ++-- .../TypeConverter/TypeConverterCollection.php | 10 ++--- .../TypeConverter/TypeConverterInterface.php | 8 ++-- .../SoapClient/Type/MultiArgumentRequest.php | 2 +- .../Type/MultiArgumentRequestInterface.php | 2 +- .../Type/ResultProviderInterface.php | 2 +- src/Phpro/SoapClient/Util/Filesystem.php | 20 ++++----- .../Wsdl/Provider/LocalWsdlProvider.php | 2 +- .../Wsdl/Provider/MixedWsdlProvider.php | 2 +- .../Wsdl/Provider/WsdlProviderInterface.php | 2 +- src/Phpro/SoapClient/Xml/SoapXml.php | 8 ++-- src/Phpro/SoapClient/Xml/WsdlXml.php | 2 +- src/Phpro/SoapClient/Xml/Xml.php | 10 ++--- 79 files changed, 276 insertions(+), 248 deletions(-) diff --git a/src/Phpro/SoapClient/Client.php b/src/Phpro/SoapClient/Client.php index b5057c15..cd069e89 100644 --- a/src/Phpro/SoapClient/Client.php +++ b/src/Phpro/SoapClient/Client.php @@ -10,7 +10,7 @@ use Phpro\SoapClient\Type\ResultInterface; use Phpro\SoapClient\Type\ResultProviderInterface; use SoapClient; -use SoapFault; + use SoapHeader; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -45,7 +45,7 @@ public function __construct(SoapClient $soapClient, EventDispatcherInterface $di * @param SoapHeader|SoapHeader[] $soapHeaders * @return $this */ - public function applySoapHeaders($soapHeaders) + public function applySoapHeaders($soapHeaders): self { $this->soapClient->__setSoapHeaders($soapHeaders); return $this; @@ -56,7 +56,7 @@ public function applySoapHeaders($soapHeaders) * * @return array */ - public function debugLastSoapRequest() + public function debugLastSoapRequest(): array { return [ 'request' => [ @@ -73,7 +73,7 @@ public function debugLastSoapRequest() /** * @param string $location */ - public function changeSoapLocation($location) + public function changeSoapLocation(string $location) { $this->soapClient->__setLocation($location); } @@ -85,7 +85,7 @@ public function changeSoapLocation($location) * @return ResultInterface * @throws SoapException */ - protected function call($method, RequestInterface $request) + protected function call(string $method, RequestInterface $request): ResultInterface { $requestEvent = new Event\RequestEvent($this, $method, $request); $this->dispatcher->dispatch(Events::REQUEST, $requestEvent); diff --git a/src/Phpro/SoapClient/ClientBuilder.php b/src/Phpro/SoapClient/ClientBuilder.php index ca579c00..e9a6a263 100644 --- a/src/Phpro/SoapClient/ClientBuilder.php +++ b/src/Phpro/SoapClient/ClientBuilder.php @@ -89,7 +89,7 @@ class ClientBuilder * @param string $wsdl * @param array $soapOptions */ - public function __construct(ClientFactoryInterface $clientFactory, $wsdl, array $soapOptions = []) + public function __construct(ClientFactoryInterface $clientFactory, string $wsdl, array $soapOptions = []) { $this->classMaps = new ClassMapCollection(); $this->converters = new TypeConverterCollection(); @@ -190,7 +190,7 @@ public function addMiddleware(MiddlewareInterface $middleware) * @return ClientInterface * @throws \Phpro\SoapClient\Exception\InvalidArgumentException */ - public function build() + public function build(): ClientInterface { $soapClientFactory = new SoapClientFactory($this->classMaps, $this->converters); $soapClient = $soapClientFactory->factory($this->wsdlProvider->provide($this->wsdl), $this->soapOptions); diff --git a/src/Phpro/SoapClient/ClientFactory.php b/src/Phpro/SoapClient/ClientFactory.php index 5f5c5d64..c95c9e12 100644 --- a/src/Phpro/SoapClient/ClientFactory.php +++ b/src/Phpro/SoapClient/ClientFactory.php @@ -2,8 +2,8 @@ namespace Phpro\SoapClient; -use SoapClient; use ReflectionClass; +use SoapClient; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -22,13 +22,13 @@ class ClientFactory implements ClientFactoryInterface /** * @param string $className */ - public function __construct($className) + public function __construct(string $className) { $this->className = $className; } /** - * @param SoapClient $soapClient + * @param SoapClient $soapClient * @param EventDispatcherInterface $dispatcher * * @return object @@ -36,6 +36,7 @@ public function __construct($className) public function factory(SoapClient $soapClient, EventDispatcherInterface $dispatcher) { $rc = new ReflectionClass($this->className); + return $rc->newInstance($soapClient, $dispatcher); } } diff --git a/src/Phpro/SoapClient/ClientFactoryInterface.php b/src/Phpro/SoapClient/ClientFactoryInterface.php index 27484941..645b70a8 100644 --- a/src/Phpro/SoapClient/ClientFactoryInterface.php +++ b/src/Phpro/SoapClient/ClientFactoryInterface.php @@ -14,7 +14,7 @@ interface ClientFactoryInterface { /** - * @param SoapClient $soapClient + * @param SoapClient $soapClient * @param EventDispatcherInterface $dispatcher * * @return ClientInterface diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/AssemblerInterface.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/AssemblerInterface.php index 55983480..17a0b28a 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/AssemblerInterface.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/AssemblerInterface.php @@ -18,7 +18,7 @@ interface AssemblerInterface * * @return bool */ - public function canAssemble(ContextInterface $context); + public function canAssemble(ContextInterface $context): bool; /** * Assembles pieces of code. diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/ClassMapAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/ClassMapAssembler.php index 23eba461..6fc3d095 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/ClassMapAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/ClassMapAssembler.php @@ -21,7 +21,7 @@ class ClassMapAssembler implements AssemblerInterface * * @return bool */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof ClassMapContext; } @@ -56,7 +56,7 @@ public function assemble(ContextInterface $context) * * @return string */ - private function assembleClassMap(TypeMap $typeMap, $linefeed, $indentation) + private function assembleClassMap(TypeMap $typeMap, string $linefeed, string $indentation): string { $classMap = []; foreach ($typeMap->getTypes() as $type) { @@ -77,7 +77,7 @@ private function assembleClassMap(TypeMap $typeMap, $linefeed, $indentation) * * @return string */ - private function assembleClassMapCollection($classMap, $linefeed) + private function assembleClassMapCollection(string $classMap, string $linefeed): string { $code = [ 'new ClassMapCollection([', diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/ClientMethodAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/ClientMethodAssembler.php index 9358ffd0..80234346 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/ClientMethodAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/ClientMethodAssembler.php @@ -19,7 +19,7 @@ class ClientMethodAssembler implements AssemblerInterface /** * {@inheritdoc} */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof ClientMethodContext; } @@ -27,9 +27,10 @@ public function canAssemble(ContextInterface $context) /** * @param ContextInterface|ClientMethodContext $context * + * @return bool * @throws AssemblerException */ - public function assemble(ContextInterface $context) + public function assemble(ContextInterface $context): bool { $class = $context->getClass(); $class->setExtendedClass(Client::class); @@ -50,12 +51,14 @@ public function assemble(ContextInterface $context) $param->getName() ), // TODO: Use normalizer once https://github.com/phpro/soap-client/pull/61 is merged - 'returntype' => '\\'.$method->getParameterNamespace().'\\'.$method->getReturnType(), + 'returntype' => '\\'.$method->getParameterNamespace().'\\'.$method->getReturnType(), ] ) ); } catch (\Exception $e) { throw AssemblerException::fromException($e); } + + return true; } } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/ConstructorAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/ConstructorAssembler.php index a0fe6fbb..08bf481a 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/ConstructorAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/ConstructorAssembler.php @@ -21,7 +21,7 @@ class ConstructorAssembler implements AssemblerInterface * * @return bool */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext; } @@ -49,7 +49,7 @@ public function assemble(ContextInterface $context) * @return MethodGenerator * @throws \Zend\Code\Generator\Exception\InvalidArgumentException */ - private function assembleConstructor(Type $type) + private function assembleConstructor(Type $type): MethodGenerator { $body = []; $constructor = MethodGenerator::fromArray([ diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/ExtendAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/ExtendAssembler.php index 9640d924..b523973b 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/ExtendAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/ExtendAssembler.php @@ -34,7 +34,7 @@ public function __construct(string $extendedClassName) * * @return bool */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/FinalClassAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/FinalClassAssembler.php index 92d4aef3..8c92bc01 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/FinalClassAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/FinalClassAssembler.php @@ -18,7 +18,7 @@ class FinalClassAssembler implements AssemblerInterface * * @return bool */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/FluentSetterAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/FluentSetterAssembler.php index 50883978..46609460 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/FluentSetterAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/FluentSetterAssembler.php @@ -36,7 +36,7 @@ public function __construct(FluentSetterAssemblerOptions $options) /** * {@inheritdoc} */ - public function canAssemble(ContextInterface $context) : bool + public function canAssemble(ContextInterface $context): bool { return $context instanceof PropertyContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/ImmutableSetterAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/ImmutableSetterAssembler.php index 247372cc..bbceec61 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/ImmutableSetterAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/ImmutableSetterAssembler.php @@ -22,7 +22,7 @@ class ImmutableSetterAssembler implements AssemblerInterface * * @return bool */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof PropertyContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/InterfaceAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/InterfaceAssembler.php index efb11696..0b85a789 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/InterfaceAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/InterfaceAssembler.php @@ -34,7 +34,7 @@ public function __construct($interfaceName) * * @return bool */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext || $context instanceof PropertyContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/IteratorAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/IteratorAssembler.php index 9d275dd0..bf4d11fa 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/IteratorAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/IteratorAssembler.php @@ -22,7 +22,7 @@ class IteratorAssembler implements AssemblerInterface * * @return bool */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext; } @@ -58,7 +58,7 @@ public function assemble(ContextInterface $context) * * @throws \Zend\Code\Generator\Exception\InvalidArgumentException */ - private function implementGetIterator($class, $firstProperty) + private function implementGetIterator(ClassGenerator $class, Property $firstProperty) { $methodName = 'getIterator'; $class->removeMethod($methodName); diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/JsonSerializableAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/JsonSerializableAssembler.php index e22f5529..2fffe7e0 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/JsonSerializableAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/JsonSerializableAssembler.php @@ -21,7 +21,7 @@ class JsonSerializableAssembler implements AssemblerInterface /** * {@inheritdoc} */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/PropertyAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/PropertyAssembler.php index 27783225..b45b54da 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/PropertyAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/PropertyAssembler.php @@ -24,7 +24,7 @@ class PropertyAssembler implements AssemblerInterface * PropertyAssembler constructor. * @param string $visibility */ - public function __construct($visibility = PropertyGenerator::VISIBILITY_PRIVATE) + public function __construct(string $visibility = PropertyGenerator::VISIBILITY_PRIVATE) { $this->visibility = $visibility; } @@ -32,7 +32,7 @@ public function __construct($visibility = PropertyGenerator::VISIBILITY_PRIVATE) /** * {@inheritdoc} */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof PropertyContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/RequestAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/RequestAssembler.php index 339204e8..2844737f 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/RequestAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/RequestAssembler.php @@ -17,7 +17,7 @@ class RequestAssembler implements AssemblerInterface /** * {@inheritdoc} */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/ResultAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/ResultAssembler.php index 8f4514cf..ffa38f03 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/ResultAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/ResultAssembler.php @@ -17,7 +17,7 @@ class ResultAssembler implements AssemblerInterface /** * {@inheritdoc} */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/ResultProviderAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/ResultProviderAssembler.php index 6c26d708..bed1f275 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/ResultProviderAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/ResultProviderAssembler.php @@ -38,7 +38,7 @@ public function __construct($wrapperClass = null) /** * {@inheritdoc} */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext; } @@ -107,7 +107,7 @@ private function implementGetResult(ContextInterface $context, ClassGenerator $c * * @return string */ - private function generateGetResultBody(Property $property) + private function generateGetResultBody(Property $property): string { if ($this->wrapperClass === null) { return sprintf('return $this->%s;', $property->getName()); @@ -125,7 +125,7 @@ private function generateGetResultBody(Property $property) * * @return string */ - private function generateGetResultReturnTag(Property $property) + private function generateGetResultReturnTag(Property $property): string { if ($this->wrapperClass === null) { return $property->getType() . '|' . Normalizer::getClassNameFromFQN(ResultInterface::class); diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/SetterAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/SetterAssembler.php index 07d69f00..677e7cbb 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/SetterAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/SetterAssembler.php @@ -20,7 +20,7 @@ class SetterAssembler implements AssemblerInterface /** * {@inheritdoc} */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof PropertyContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/TraitAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/TraitAssembler.php index c8f35598..6f75885c 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/TraitAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/TraitAssembler.php @@ -26,10 +26,10 @@ class TraitAssembler implements AssemblerInterface /** * TraitAssembler constructor. - * @param $traitName - * @param $traitAlias + * @param string $traitName + * @param string $traitAlias */ - public function __construct($traitName, $traitAlias = null) + public function __construct(string $traitName, $traitAlias = null) { $this->traitName = Normalizer::normalizeNamespace($traitName); $this->traitAlias = $traitAlias; @@ -39,7 +39,7 @@ public function __construct($traitName, $traitAlias = null) * @param ContextInterface $context * @return bool */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext || $context instanceof PropertyContext; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Assembler/UseAssembler.php b/src/Phpro/SoapClient/CodeGenerator/Assembler/UseAssembler.php index d88ad206..d132eb20 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Assembler/UseAssembler.php +++ b/src/Phpro/SoapClient/CodeGenerator/Assembler/UseAssembler.php @@ -30,7 +30,7 @@ class UseAssembler implements AssemblerInterface * @param $useName * @param $useAlias */ - public function __construct($useName, $useAlias = null) + public function __construct(string $useName, $useAlias = null) { $this->useName = $useName; $this->useAlias = $useAlias; @@ -40,7 +40,7 @@ public function __construct($useName, $useAlias = null) * @param ContextInterface $context * @return bool */ - public function canAssemble(ContextInterface $context) + public function canAssemble(ContextInterface $context): bool { return $context instanceof TypeContext || $context instanceof PropertyContext; } @@ -73,7 +73,7 @@ public function assemble(ContextInterface $context) * @param ClassGenerator $class * @return bool */ - private function usesTheSameNamespace(ClassGenerator $class) + private function usesTheSameNamespace(ClassGenerator $class): bool { $namespaceName = (string) $class->getNamespaceName(); @@ -84,11 +84,19 @@ private function usesTheSameNamespace(ClassGenerator $class) return in_array($namespaceName, [$this->useName, $this->getClassUseNamespaceName()]); } + /** + * @param string $namespaceName + * + * @return bool + */ private function usesGlobalNamespace(string $namespaceName): bool { return '' === $namespaceName && false === strpos($this->useName, '\\'); } + /** + * @return string + */ private function getClassUseNamespaceName(): string { return substr($this->useName, 0, strrpos($this->useName, '\\')); diff --git a/src/Phpro/SoapClient/CodeGenerator/ClassMapGenerator.php b/src/Phpro/SoapClient/CodeGenerator/ClassMapGenerator.php index 5270afb4..47405efc 100644 --- a/src/Phpro/SoapClient/CodeGenerator/ClassMapGenerator.php +++ b/src/Phpro/SoapClient/CodeGenerator/ClassMapGenerator.php @@ -35,7 +35,7 @@ public function __construct(RuleSetInterface $ruleSet) * * @return string */ - public function generate(FileGenerator $file, $typeMap) + public function generate(FileGenerator $file, $typeMap): string { $this->ruleSet->applyRules(new ClassMapContext($file, $typeMap)); diff --git a/src/Phpro/SoapClient/CodeGenerator/ClientGenerator.php b/src/Phpro/SoapClient/CodeGenerator/ClientGenerator.php index 0dc24b7e..c451c674 100644 --- a/src/Phpro/SoapClient/CodeGenerator/ClientGenerator.php +++ b/src/Phpro/SoapClient/CodeGenerator/ClientGenerator.php @@ -35,11 +35,11 @@ public function __construct(RuleSetInterface $ruleSet) /** * @param FileGenerator $file - * @param Client $client + * @param Client $client * * @return string */ - public function generate(FileGenerator $file, $client) + public function generate(FileGenerator $file, $client): string { $class = $file->getClass() ?: new ClassGenerator(); $class->setNamespaceName($client->getNamespace()); diff --git a/src/Phpro/SoapClient/CodeGenerator/Config/Config.php b/src/Phpro/SoapClient/CodeGenerator/Config/Config.php index db59f2ca..b090253f 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Config/Config.php +++ b/src/Phpro/SoapClient/CodeGenerator/Config/Config.php @@ -77,7 +77,7 @@ class Config implements ConfigInterface * @param string $wsdl * @param string $destination */ - public function __construct($wsdl = '', $destination = '') + public function __construct(string $wsdl = '', string $destination = '') { $this->setWsdl($wsdl); $this->setDestination($destination); @@ -92,7 +92,7 @@ public function __construct($wsdl = '', $destination = '') /** * @return Config */ - public static function create() + public static function create(): self { return new static(); } @@ -102,7 +102,7 @@ public static function create() * @throws InvalidArgumentException * @deprecated use getTypeNamespace or getClientNamespace instead */ - public function getNamespace() + public function getNamespace(): string { return $this->typesNamespace; } @@ -113,7 +113,7 @@ public function getNamespace() * @return Config * @deprecated use setTypeNamespace of setClientNamespace instead */ - public function setNamespace($namespace) + public function setNamespace(string $namespace): self { $this->typesNamespace = Normalizer::normalizeNamespace($namespace); @@ -144,7 +144,7 @@ public function setTypeNamespace($namespace) * @return string * @throws InvalidArgumentException */ - public function getWsdl() + public function getWsdl(): string { if (!$this->wsdl) { throw InvalidArgumentException::wsdlConfigurationIsMissing(); @@ -164,7 +164,7 @@ public function getWsdl() * * @return Config */ - public function setWsdl($wsdl) + public function setWsdl($wsdl): self { $this->wsdl = $wsdl; @@ -177,7 +177,7 @@ public function setWsdl($wsdl) * * @return $this */ - public function addSoapOption($key, $value) + public function addSoapOption(string $key, $value): self { $this->soapOptions[$key] = $value; @@ -187,7 +187,7 @@ public function addSoapOption($key, $value) /** * @return array */ - public function getSoapOptions() + public function getSoapOptions(): array { return $this->soapOptions; } @@ -209,7 +209,7 @@ public function setSoapOptions(array $soapOptions) * @throws InvalidArgumentException * @deprecated */ - public function getDestination() + public function getDestination(): string { if (!$this->typeDestination) { throw InvalidArgumentException::destinationConfigurationIsMissing(); @@ -224,7 +224,7 @@ public function getDestination() * @return Config * @deprecated */ - public function setDestination($destination) + public function setDestination(string $destination): self { $this->typeDestination = rtrim($destination, '/\\'); @@ -234,7 +234,7 @@ public function setDestination($destination) /** * @return RuleSetInterface */ - public function getRuleSet() + public function getRuleSet(): RuleSetInterface { return $this->ruleSet; } @@ -256,7 +256,7 @@ public function setRuleSet(RuleSetInterface $ruleSet) * * @return Config */ - public function addRule(RuleInterface $rule) + public function addRule(RuleInterface $rule): self { $this->ruleSet->addRule($rule); @@ -298,7 +298,7 @@ public function getClientNamespace() * @param string $clientNamespace * @return Config */ - public function setClientNamespace($clientNamespace) + public function setClientNamespace($clientNamespace): self { $this->clientNamespace = $clientNamespace; @@ -375,7 +375,7 @@ public function getWsdlProvider(): WsdlProviderInterface * @param WsdlProviderInterface $wsdlProvider * @return Config */ - public function setWsdlProvider(WsdlProviderInterface $wsdlProvider) + public function setWsdlProvider(WsdlProviderInterface $wsdlProvider): self { $this->wsdlProvider = $wsdlProvider; return $this; diff --git a/src/Phpro/SoapClient/CodeGenerator/Config/ConfigInterface.php b/src/Phpro/SoapClient/CodeGenerator/Config/ConfigInterface.php index befc05ee..ccf891f1 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Config/ConfigInterface.php +++ b/src/Phpro/SoapClient/CodeGenerator/Config/ConfigInterface.php @@ -16,23 +16,23 @@ interface ConfigInterface * @return string * @deprecated use getClientNamespace or getTypeNamespace instead */ - public function getNamespace(); + public function getNamespace(): string; /** * @return string */ - public function getWsdl(); + public function getWsdl(): string; /** * array */ - public function getSoapOptions(); + public function getSoapOptions(): array; /** * @return string * @deprecated Use getTypeDestination or getClientDestination instead */ - public function getDestination(); + public function getDestination(): string; /** * @return string @@ -47,7 +47,7 @@ public function getTypeDestination(); /** * @return RuleSetInterface */ - public function getRuleSet(); + public function getRuleSet(): RuleSetInterface; /** * @return string @@ -62,5 +62,5 @@ public function getTypeNamespace(); /** * @return WsdlProviderInterface */ - public function getWsdlProvider(); + public function getWsdlProvider(): WsdlProviderInterface; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Context/ClassMapContext.php b/src/Phpro/SoapClient/CodeGenerator/Context/ClassMapContext.php index ecfb7eee..d811f78e 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Context/ClassMapContext.php +++ b/src/Phpro/SoapClient/CodeGenerator/Context/ClassMapContext.php @@ -37,7 +37,7 @@ public function __construct(FileGenerator $file, TypeMap $typeMap) /** * @return FileGenerator */ - public function getFile() + public function getFile(): FileGenerator { return $this->file; } @@ -45,7 +45,7 @@ public function getFile() /** * @return TypeMap */ - public function getTypeMap() + public function getTypeMap(): TypeMap { return $this->typeMap; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Context/PropertyContext.php b/src/Phpro/SoapClient/CodeGenerator/Context/PropertyContext.php index f086133d..6b1f2922 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Context/PropertyContext.php +++ b/src/Phpro/SoapClient/CodeGenerator/Context/PropertyContext.php @@ -45,7 +45,7 @@ public function __construct(ClassGenerator $class, Type $type, Property $propert /** * @return ClassGenerator */ - public function getClass() + public function getClass(): ClassGenerator { return $this->class; } @@ -53,7 +53,7 @@ public function getClass() /** * @return Type */ - public function getType() + public function getType(): Type { return $this->type; } @@ -61,7 +61,7 @@ public function getType() /** * @return Property */ - public function getProperty() + public function getProperty(): Property { return $this->property; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Context/TypeContext.php b/src/Phpro/SoapClient/CodeGenerator/Context/TypeContext.php index 7187718d..2f38e8f3 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Context/TypeContext.php +++ b/src/Phpro/SoapClient/CodeGenerator/Context/TypeContext.php @@ -37,7 +37,7 @@ public function __construct(ClassGenerator $class, Type $type) /** * @return ClassGenerator */ - public function getClass() + public function getClass(): ClassGenerator { return $this->class; } @@ -45,7 +45,7 @@ public function getClass() /** * @return Type */ - public function getType() + public function getType(): Type { return $this->type; } diff --git a/src/Phpro/SoapClient/CodeGenerator/GeneratorInterface.php b/src/Phpro/SoapClient/CodeGenerator/GeneratorInterface.php index 54dc85e0..68a82f4e 100644 --- a/src/Phpro/SoapClient/CodeGenerator/GeneratorInterface.php +++ b/src/Phpro/SoapClient/CodeGenerator/GeneratorInterface.php @@ -17,5 +17,5 @@ interface GeneratorInterface * * @return string */ - public function generate(FileGenerator $file, $model); + public function generate(FileGenerator $file, $model): string; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/Property.php b/src/Phpro/SoapClient/CodeGenerator/Model/Property.php index d642f1dd..3d9f2c42 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/Property.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/Property.php @@ -27,7 +27,7 @@ class Property * @param string $name * @param string $type */ - public function __construct($name, $type) + public function __construct(string $name, string $type) { $this->name = Normalizer::normalizeProperty($name); $this->type = Normalizer::normalizeDataType($type); @@ -36,7 +36,7 @@ public function __construct($name, $type) /** * @return string */ - public function getName() + public function getName(): string { return $this->name; } @@ -44,7 +44,7 @@ public function getName() /** * @return string */ - public function getType() + public function getType(): string { return $this->type; } @@ -52,7 +52,7 @@ public function getType() /** * @return string */ - public function getterName() + public function getterName(): string { return Normalizer::generatePropertyMethod('get', $this->getName()); } @@ -60,7 +60,7 @@ public function getterName() /** * @return string */ - public function setterName() + public function setterName(): string { return Normalizer::generatePropertyMethod('set', $this->getName()); } diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/Type.php b/src/Phpro/SoapClient/CodeGenerator/Model/Type.php index 3885f8a7..fe10c2aa 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/Type.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/Type.php @@ -41,7 +41,7 @@ class Type * @param string $xsdName * @param Property[] $properties */ - public function __construct($namespace, $xsdName, array $properties) + public function __construct(string $namespace, string $xsdName, array $properties) { $this->namespace = Normalizer::normalizeNamespace($namespace); $this->xsdName = $xsdName; @@ -55,7 +55,7 @@ public function __construct($namespace, $xsdName, array $properties) /** * @return string */ - public function getNamespace() + public function getNamespace(): string { return $this->namespace; } @@ -63,7 +63,7 @@ public function getNamespace() /** * @return string */ - public function getName() + public function getName(): string { return $this->name; } @@ -71,11 +71,17 @@ public function getName() /** * @return string */ - public function getXsdName() + public function getXsdName(): string { return $this->xsdName; } + + /** + * @param string $destination + * + * @return SplFileInfo + */ public function getFileInfo(string $destination) : SplFileInfo { $name = str_replace('_', DIRECTORY_SEPARATOR, $this->getName()); @@ -89,7 +95,7 @@ public function getFileInfo(string $destination) : SplFileInfo * @deprecated please use getFileInfo instead * @return string */ - public function getPathname($destination) + public function getPathname(string $destination): string { return $this->getFileInfo($destination)->getPathname(); } @@ -97,7 +103,7 @@ public function getPathname($destination) /** * @return string */ - public function getFullName() + public function getFullName(): string { $fqnName = sprintf('%s\\%s', $this->getNamespace(), $this->getName()); @@ -107,7 +113,7 @@ public function getFullName() /** * @return Property[] */ - public function getProperties() + public function getProperties(): array { return $this->properties; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Model/TypeMap.php b/src/Phpro/SoapClient/CodeGenerator/Model/TypeMap.php index 8d672073..470a15e9 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Model/TypeMap.php +++ b/src/Phpro/SoapClient/CodeGenerator/Model/TypeMap.php @@ -29,7 +29,7 @@ class TypeMap * @param string $namespace * @param array $types */ - public function __construct($namespace, array $types) + public function __construct(string $namespace, array $types) { $this->namespace = Normalizer::normalizeNamespace($namespace); @@ -44,7 +44,7 @@ public function __construct($namespace, array $types) * * @return TypeMap */ - public static function fromSoapClient($namespace, SoapClient $client) + public static function fromSoapClient(string $namespace, SoapClient $client): self { return new self($namespace, $client->getSoapTypes()); } @@ -52,7 +52,7 @@ public static function fromSoapClient($namespace, SoapClient $client) /** * @return string */ - public function getNamespace() + public function getNamespace(): string { return $this->namespace; } @@ -60,7 +60,7 @@ public function getNamespace() /** * @return array|Type[] */ - public function getTypes() + public function getTypes(): array { return $this->types; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Rules/AssembleRule.php b/src/Phpro/SoapClient/CodeGenerator/Rules/AssembleRule.php index 5d0ca046..906aeb3e 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Rules/AssembleRule.php +++ b/src/Phpro/SoapClient/CodeGenerator/Rules/AssembleRule.php @@ -32,7 +32,7 @@ public function __construct(AssemblerInterface $assembler) * * @return bool */ - public function appliesToContext(ContextInterface $context) + public function appliesToContext(ContextInterface $context): bool { return $this->assembler->canAssemble($context); } diff --git a/src/Phpro/SoapClient/CodeGenerator/Rules/MultiRule.php b/src/Phpro/SoapClient/CodeGenerator/Rules/MultiRule.php index 3aaa2864..4ed460d0 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Rules/MultiRule.php +++ b/src/Phpro/SoapClient/CodeGenerator/Rules/MultiRule.php @@ -31,7 +31,7 @@ public function __construct(array $rules) * * @return bool */ - public function appliesToContext(ContextInterface $context) + public function appliesToContext(ContextInterface $context): bool { return true; } diff --git a/src/Phpro/SoapClient/CodeGenerator/Rules/PropertynameMatchesRule.php b/src/Phpro/SoapClient/CodeGenerator/Rules/PropertynameMatchesRule.php index ed28d296..a7aaf167 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Rules/PropertynameMatchesRule.php +++ b/src/Phpro/SoapClient/CodeGenerator/Rules/PropertynameMatchesRule.php @@ -6,7 +6,7 @@ use Phpro\SoapClient\CodeGenerator\Context\PropertyContext; /** - * Class TypenameMatchingAssembleRule + * Class PropertynameMatchesRule * * @package Phpro\SoapClient\CodeGenerator\Rules */ @@ -28,7 +28,7 @@ class PropertynameMatchesRule implements RuleInterface * @param RuleInterface $subRule * @param string $regex */ - public function __construct(RuleInterface $subRule, $regex) + public function __construct(RuleInterface $subRule, string $regex) { $this->subRule = $subRule; $this->regex = $regex; @@ -39,7 +39,7 @@ public function __construct(RuleInterface $subRule, $regex) * * @return bool */ - public function appliesToContext(ContextInterface $context) + public function appliesToContext(ContextInterface $context): bool { if (!$context instanceof PropertyContext) { return false; diff --git a/src/Phpro/SoapClient/CodeGenerator/Rules/RuleInterface.php b/src/Phpro/SoapClient/CodeGenerator/Rules/RuleInterface.php index 0fa0bf71..504471a6 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Rules/RuleInterface.php +++ b/src/Phpro/SoapClient/CodeGenerator/Rules/RuleInterface.php @@ -16,7 +16,7 @@ interface RuleInterface * * @return bool */ - public function appliesToContext(ContextInterface $context); + public function appliesToContext(ContextInterface $context): bool; /** * @param ContextInterface $context diff --git a/src/Phpro/SoapClient/CodeGenerator/Rules/TypeMapRule.php b/src/Phpro/SoapClient/CodeGenerator/Rules/TypeMapRule.php index 36f5fdb2..f1f1fd93 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Rules/TypeMapRule.php +++ b/src/Phpro/SoapClient/CodeGenerator/Rules/TypeMapRule.php @@ -29,7 +29,7 @@ class TypeMapRule implements RuleInterface * @param RuleInterface[] $typeMap * @param RuleInterface $defaultRule */ - public function __construct(array $typeMap, $defaultRule) + public function __construct(array $typeMap, RuleInterface $defaultRule) { $this->typeMap = $typeMap; $this->defaultRule = $defaultRule; @@ -40,7 +40,7 @@ public function __construct(array $typeMap, $defaultRule) * * @return bool */ - public function appliesToContext(ContextInterface $context) + public function appliesToContext(ContextInterface $context): bool { if (!$context instanceof TypeContext && !$context instanceof PropertyContext) { return false; diff --git a/src/Phpro/SoapClient/CodeGenerator/Rules/TypenameMatchesRule.php b/src/Phpro/SoapClient/CodeGenerator/Rules/TypenameMatchesRule.php index 746b9c42..ab0767ee 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Rules/TypenameMatchesRule.php +++ b/src/Phpro/SoapClient/CodeGenerator/Rules/TypenameMatchesRule.php @@ -29,7 +29,7 @@ class TypenameMatchesRule implements RuleInterface * @param RuleInterface $subRule * @param string $regex */ - public function __construct(RuleInterface $subRule, $regex) + public function __construct(RuleInterface $subRule, string $regex) { $this->subRule = $subRule; $this->regex = $regex; @@ -40,7 +40,7 @@ public function __construct(RuleInterface $subRule, $regex) * * @return bool */ - public function appliesToContext(ContextInterface $context) + public function appliesToContext(ContextInterface $context): bool { if (!$context instanceof TypeContext && !$context instanceof PropertyContext) { return false; diff --git a/src/Phpro/SoapClient/CodeGenerator/TypeGenerator.php b/src/Phpro/SoapClient/CodeGenerator/TypeGenerator.php index 514e3937..52b01630 100644 --- a/src/Phpro/SoapClient/CodeGenerator/TypeGenerator.php +++ b/src/Phpro/SoapClient/CodeGenerator/TypeGenerator.php @@ -37,7 +37,7 @@ public function __construct(RuleSetInterface $ruleSet) * * @return string */ - public function generate(FileGenerator $file, $type) + public function generate(FileGenerator $file, $type): string { $class = $file->getClass() ?: new ClassGenerator(); $class->setNamespaceName($type->getNamespace()); diff --git a/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php b/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php index df206cf3..afcdc2c1 100644 --- a/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php +++ b/src/Phpro/SoapClient/CodeGenerator/Util/Normalizer.php @@ -15,7 +15,7 @@ class Normalizer * * @return string */ - public static function normalizeNamespace($namespace) + public static function normalizeNamespace(string $namespace): string { return trim(str_replace('/', '\\', $namespace), '\\'); } @@ -25,7 +25,7 @@ public static function normalizeNamespace($namespace) * * @return string */ - public static function normalizeClassname($name) + public static function normalizeClassname($name): string { return ucfirst(preg_replace('{[^a-z0-9_]}i', '', $name)); } @@ -45,16 +45,16 @@ public static function normalizeProperty($property) * * @return string */ - public static function normalizeDataType($type) + public static function normalizeDataType(string $type): string { $normalizations = [ - 'long' => 'int', - 'short' => 'int', + 'long' => 'int', + 'short' => 'int', 'datetime' => '\\DateTime', - 'date' => '\\DateTime', - 'boolean' => 'bool', - 'decimal' => 'float', - 'double' => 'float', + 'date' => '\\DateTime', + 'boolean' => 'bool', + 'decimal' => 'float', + 'double' => 'float', ]; $searchType = strtolower($type); @@ -63,37 +63,41 @@ public static function normalizeDataType($type) } /** - * @param $prefix - * @param $property + * @param string $prefix + * @param string $property * * @return string */ - public static function generatePropertyMethod($prefix, $property) + public static function generatePropertyMethod(string $prefix, string $property): string { return strtolower($prefix) . ucfirst(self::normalizeProperty($property)); } /** * @param string $name + * * @return string */ - public static function getClassNameFromFQN($name) + public static function getClassNameFromFQN(string $name): string { $arr = explode('\\', $name); - return array_pop($arr); + + return (string)array_pop($arr); } /** - * @param string $useName - * @param string $useAlias + * @param string $useName + * @param string|null $useAlias + * * @return string */ - public static function getCompleteUseStatement($useName, $useAlias) + public static function getCompleteUseStatement(string $useName, $useAlias): string { $use = $useName; if (!empty($useAlias)) { $use .= ' as ' . $useAlias; } + return $use; } } diff --git a/src/Phpro/SoapClient/Console/Application.php b/src/Phpro/SoapClient/Console/Application.php index 38f4ba47..3d7f0056 100644 --- a/src/Phpro/SoapClient/Console/Application.php +++ b/src/Phpro/SoapClient/Console/Application.php @@ -28,7 +28,7 @@ public function __construct() /** * {@inheritdoc} */ - protected function getDefaultCommands() + protected function getDefaultCommands(): array { $filesystem = new Filesystem(); $commands = parent::getDefaultCommands(); diff --git a/src/Phpro/SoapClient/Console/Command/GenerateTypesCommand.php b/src/Phpro/SoapClient/Console/Command/GenerateTypesCommand.php index 19089510..aea407a0 100644 --- a/src/Phpro/SoapClient/Console/Command/GenerateTypesCommand.php +++ b/src/Phpro/SoapClient/Console/Command/GenerateTypesCommand.php @@ -114,7 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output) * @param SplFileInfo $fileInfo * @return bool */ - protected function handleType(TypeGenerator $generator, Type $type, SplFileInfo $fileInfo) + protected function handleType(TypeGenerator $generator, Type $type, SplFileInfo $fileInfo): bool { // Generate type sub folders if needed $this->filesystem->ensureDirectoryExists($fileInfo->getPath()); @@ -153,7 +153,7 @@ protected function handleType(TypeGenerator $generator, Type $type, SplFileInfo * @return bool * */ - protected function handleExistingFile(TypeGenerator $generator, Type $type, SplFileInfo $fileInfo) + protected function handleExistingFile(TypeGenerator $generator, Type $type, SplFileInfo $fileInfo): bool { $this->output->write(sprintf('Type %s exists. Trying to patch ...', $type->getName())); $patched = $this->patchExistingFile($generator, $type, $fileInfo); @@ -176,7 +176,7 @@ protected function handleExistingFile(TypeGenerator $generator, Type $type, SplF * @param SplFileInfo $fileInfo * @return bool */ - protected function patchExistingFile(TypeGenerator $generator, Type $type, SplFileInfo $fileInfo) + protected function patchExistingFile(TypeGenerator $generator, Type $type, SplFileInfo $fileInfo): bool { try { $this->filesystem->createBackup($fileInfo->getPathname()); @@ -208,11 +208,11 @@ protected function generateType(FileGenerator $file, TypeGenerator $generator, T /** * @return bool */ - protected function askForOverwrite() + protected function askForOverwrite(): bool { $overwriteByDefault = $this->input->getOption('overwrite'); $question = new ConfirmationQuestion('Do you want to overwrite it?', $overwriteByDefault); - return $this->getHelper('question')->ask($this->input, $this->output, $question); + return (bool)$this->getHelper('question')->ask($this->input, $this->output, $question); } } diff --git a/src/Phpro/SoapClient/Event/FaultEvent.php b/src/Phpro/SoapClient/Event/FaultEvent.php index 9622c84a..1dedc202 100644 --- a/src/Phpro/SoapClient/Event/FaultEvent.php +++ b/src/Phpro/SoapClient/Event/FaultEvent.php @@ -44,7 +44,7 @@ public function __construct(Client $client, SoapException $soapException, Reques /** * @return SoapException */ - public function getSoapException() + public function getSoapException(): SoapException { return $this->soapException; } @@ -52,7 +52,7 @@ public function getSoapException() /** * @return RequestEvent */ - public function getRequestEvent() + public function getRequestEvent(): RequestEvent { return $this->requestEvent; } @@ -60,7 +60,7 @@ public function getRequestEvent() /** * @return Client */ - public function getClient() + public function getClient(): Client { return $this->client; } diff --git a/src/Phpro/SoapClient/Event/RequestEvent.php b/src/Phpro/SoapClient/Event/RequestEvent.php index 124707cf..409be281 100644 --- a/src/Phpro/SoapClient/Event/RequestEvent.php +++ b/src/Phpro/SoapClient/Event/RequestEvent.php @@ -33,7 +33,7 @@ class RequestEvent extends Event * @param string $method * @param RequestInterface $request */ - public function __construct(Client $client, $method, RequestInterface $request) + public function __construct(Client $client, string $method, RequestInterface $request) { $this->client = $client; $this->method = $method; @@ -43,7 +43,7 @@ public function __construct(Client $client, $method, RequestInterface $request) /** * @return string */ - public function getMethod() + public function getMethod(): string { return $this->method; } @@ -51,7 +51,7 @@ public function getMethod() /** * @return RequestInterface */ - public function getRequest() + public function getRequest(): RequestInterface { return $this->request; } @@ -59,7 +59,7 @@ public function getRequest() /** * @return Client */ - public function getClient() + public function getClient(): Client { return $this->client; } diff --git a/src/Phpro/SoapClient/Event/ResponseEvent.php b/src/Phpro/SoapClient/Event/ResponseEvent.php index bde1e7ad..547a2d9b 100644 --- a/src/Phpro/SoapClient/Event/ResponseEvent.php +++ b/src/Phpro/SoapClient/Event/ResponseEvent.php @@ -42,7 +42,7 @@ public function __construct(Client $client, RequestEvent $requestEvent, ResultIn /** * @return RequestEvent */ - public function getRequestEvent() + public function getRequestEvent(): RequestEvent { return $this->requestEvent; } @@ -50,7 +50,7 @@ public function getRequestEvent() /** * @return ResultInterface */ - public function getResponse() + public function getResponse(): ResultInterface { return $this->response; } @@ -58,7 +58,7 @@ public function getResponse() /** * @return Client */ - public function getClient() + public function getClient(): Client { return $this->client; } diff --git a/src/Phpro/SoapClient/Exception/AssemblerException.php b/src/Phpro/SoapClient/Exception/AssemblerException.php index f4410168..df615a41 100644 --- a/src/Phpro/SoapClient/Exception/AssemblerException.php +++ b/src/Phpro/SoapClient/Exception/AssemblerException.php @@ -15,7 +15,7 @@ class AssemblerException extends RuntimeException * * @return AssemblerException */ - public static function fromException(\Exception $e) + public static function fromException(\Exception $e): self { return new self($e->getMessage(), $e->getCode(), $e); } diff --git a/src/Phpro/SoapClient/Exception/InvalidArgumentException.php b/src/Phpro/SoapClient/Exception/InvalidArgumentException.php index 3b6790c4..9ef38b83 100644 --- a/src/Phpro/SoapClient/Exception/InvalidArgumentException.php +++ b/src/Phpro/SoapClient/Exception/InvalidArgumentException.php @@ -14,7 +14,7 @@ class InvalidArgumentException extends \InvalidArgumentException /** * @return InvalidArgumentException */ - public static function wsdlConfigurationIsMissing() + public static function wsdlConfigurationIsMissing(): self { return new static('You did not configure a WSDL file.'); } @@ -31,7 +31,7 @@ public static function wsdlCouldNotBeProvided(Throwable $e): self /** * @return InvalidArgumentException */ - public static function destinationConfigurationIsMissing() + public static function destinationConfigurationIsMissing(): self { return new static('You did not configure a destination.'); } @@ -39,7 +39,7 @@ public static function destinationConfigurationIsMissing() /** * @return InvalidArgumentException */ - public static function invalidConfigFile() + public static function invalidConfigFile(): self { return new static('You have to provide a code-generator config file which returns a ConfigInterface.'); } diff --git a/src/Phpro/SoapClient/Exception/RuntimeException.php b/src/Phpro/SoapClient/Exception/RuntimeException.php index 13e533b7..b3313e85 100644 --- a/src/Phpro/SoapClient/Exception/RuntimeException.php +++ b/src/Phpro/SoapClient/Exception/RuntimeException.php @@ -2,6 +2,10 @@ namespace Phpro\SoapClient\Exception; +/** + * Class RuntimeException + * @package Phpro\SoapClient\Exception + */ class RuntimeException extends \RuntimeException { } diff --git a/src/Phpro/SoapClient/Exception/SoapException.php b/src/Phpro/SoapClient/Exception/SoapException.php index 18282374..a962ba5a 100644 --- a/src/Phpro/SoapClient/Exception/SoapException.php +++ b/src/Phpro/SoapClient/Exception/SoapException.php @@ -14,7 +14,7 @@ class SoapException extends RuntimeException * * @return SoapException */ - public static function fromThrowable(\Throwable $throwable) + public static function fromThrowable(\Throwable $throwable): self { return new self($throwable->getMessage(), $throwable->getCode(), $throwable); } diff --git a/src/Phpro/SoapClient/Exception/WsdlException.php b/src/Phpro/SoapClient/Exception/WsdlException.php index c2ee7e6b..94faccbb 100644 --- a/src/Phpro/SoapClient/Exception/WsdlException.php +++ b/src/Phpro/SoapClient/Exception/WsdlException.php @@ -10,11 +10,11 @@ class WsdlException extends RuntimeException { /** - * @param $path + * @param string $path * * @return WsdlException */ - public static function notFound($path) + public static function notFound(string $path): self { return new self( sprintf('The WSDL could not be loaded from location: %s', $path) @@ -26,7 +26,7 @@ public static function notFound($path) * * @return WsdlException */ - public static function fromException(\Throwable $exception) + public static function fromException(\Throwable $exception): self { return new self( $exception->getMessage(), diff --git a/src/Phpro/SoapClient/Middleware/Middleware.php b/src/Phpro/SoapClient/Middleware/Middleware.php index dcfec4d1..fa81e776 100644 --- a/src/Phpro/SoapClient/Middleware/Middleware.php +++ b/src/Phpro/SoapClient/Middleware/Middleware.php @@ -19,7 +19,7 @@ public function getName(): string return 'empty_middleware'; } - public function handleRequest(RequestInterface $request, callable $next, callable $first) + public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise { return $this->beforeRequest($next, $request) ->then( diff --git a/src/Phpro/SoapClient/Middleware/RemoveEmptyNodesMiddleware.php b/src/Phpro/SoapClient/Middleware/RemoveEmptyNodesMiddleware.php index 683c3355..05ce3212 100644 --- a/src/Phpro/SoapClient/Middleware/RemoveEmptyNodesMiddleware.php +++ b/src/Phpro/SoapClient/Middleware/RemoveEmptyNodesMiddleware.php @@ -6,7 +6,7 @@ use Phpro\SoapClient\Xml\SoapXml; use Psr\Http\Message\RequestInterface; -class RemoveEmptyNodesMiddleware extends MiddleWare +class RemoveEmptyNodesMiddleware extends Middleware { public function getName(): string { diff --git a/src/Phpro/SoapClient/Middleware/WsseMiddleware.php b/src/Phpro/SoapClient/Middleware/WsseMiddleware.php index f3ef6c45..086cd462 100644 --- a/src/Phpro/SoapClient/Middleware/WsseMiddleware.php +++ b/src/Phpro/SoapClient/Middleware/WsseMiddleware.php @@ -122,7 +122,7 @@ public function withEncryption(string $serverCertificateFile): self return $this; } - public function withServerCertificateHasSubjectKeyIdentifier(bool $hasSubjectKeyIdentifier) + public function withServerCertificateHasSubjectKeyIdentifier(bool $hasSubjectKeyIdentifier): self { $this->serverCertificateHasSubjectKeyIdentifier = $hasSubjectKeyIdentifier; diff --git a/src/Phpro/SoapClient/Plugin/LogPlugin.php b/src/Phpro/SoapClient/Plugin/LogPlugin.php index d314e545..d7d2ccda 100644 --- a/src/Phpro/SoapClient/Plugin/LogPlugin.php +++ b/src/Phpro/SoapClient/Plugin/LogPlugin.php @@ -70,7 +70,7 @@ public function onClientFault(FaultEvent $event) /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return array( Events::REQUEST => 'onClientRequest', diff --git a/src/Phpro/SoapClient/Plugin/ValidatorPlugin.php b/src/Phpro/SoapClient/Plugin/ValidatorPlugin.php index 380b98e6..ede07790 100644 --- a/src/Phpro/SoapClient/Plugin/ValidatorPlugin.php +++ b/src/Phpro/SoapClient/Plugin/ValidatorPlugin.php @@ -47,7 +47,7 @@ public function onClientRequest(RequestEvent $event) /** * {@inheritdoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ Events::REQUEST => 'onClientRequest', diff --git a/src/Phpro/SoapClient/Soap/ClassMap/ClassMap.php b/src/Phpro/SoapClient/Soap/ClassMap/ClassMap.php index f489f9c8..ba908fc7 100644 --- a/src/Phpro/SoapClient/Soap/ClassMap/ClassMap.php +++ b/src/Phpro/SoapClient/Soap/ClassMap/ClassMap.php @@ -21,10 +21,10 @@ class ClassMap implements ClassMapInterface private $phpClassName; /** - * @param $wsdlType - * @param $phpClassName + * @param string $wsdlType + * @param string $phpClassName */ - public function __construct($wsdlType, $phpClassName) + public function __construct(string $wsdlType, string $phpClassName) { $this->wsdlType = $wsdlType; $this->phpClassName = $phpClassName; @@ -33,13 +33,13 @@ public function __construct($wsdlType, $phpClassName) /** * @return string */ - public function getPhpClassName() + public function getPhpClassName(): string { return $this->phpClassName; } /** - * @return string + * @return string|null */ public function getWsdlType() { diff --git a/src/Phpro/SoapClient/Soap/ClassMap/ClassMapCollection.php b/src/Phpro/SoapClient/Soap/ClassMap/ClassMapCollection.php index d9cd6709..19c42a12 100644 --- a/src/Phpro/SoapClient/Soap/ClassMap/ClassMapCollection.php +++ b/src/Phpro/SoapClient/Soap/ClassMap/ClassMapCollection.php @@ -28,11 +28,11 @@ public function __construct(array $classMaps = []) } /** - * @param ClassMap $classMap + * @param ClassMapInterface $classMap * * @return ClassMapCollection */ - public function add(ClassMapInterface $classMap) + public function add(ClassMapInterface $classMap): self { if ($this->has($classMap)) { throw new InvalidArgumentException('The classmap already exists!'); @@ -42,22 +42,23 @@ public function add(ClassMapInterface $classMap) } /** - * @param ClassMap $classMap + * @param ClassMapInterface $classMap * * @return $this */ - public function set(ClassMapInterface $classMap) + public function set(ClassMapInterface $classMap): self { $this->classMaps[$classMap->getWsdlType()] = $classMap; + return $this; } /** - * @param ClassMap $classMap + * @param ClassMapInterface $classMap * * @return bool */ - public function has(ClassMapInterface $classMap) + public function has(ClassMapInterface $classMap): bool { return array_key_exists($classMap->getWsdlType(), $this->classMaps); } @@ -65,12 +66,13 @@ public function has(ClassMapInterface $classMap) /** * @return array */ - public function toSoapClassMap() + public function toSoapClassMap(): array { $map = []; foreach ($this->classMaps as $classMap) { $map[$classMap->getWsdlType()] = $classMap->getPhpClassName(); } + return $map; } } diff --git a/src/Phpro/SoapClient/Soap/ClassMap/ClassMapInterface.php b/src/Phpro/SoapClient/Soap/ClassMap/ClassMapInterface.php index a0248871..70409c35 100644 --- a/src/Phpro/SoapClient/Soap/ClassMap/ClassMapInterface.php +++ b/src/Phpro/SoapClient/Soap/ClassMap/ClassMapInterface.php @@ -11,12 +11,12 @@ interface ClassMapInterface { /** - * @return string + * @return string|null */ public function getWsdlType(); /** * @return string */ - public function getPhpClassName(); + public function getPhpClassName(): string; } diff --git a/src/Phpro/SoapClient/Soap/HttpBinding/Builder/Psr7RequestBuilder.php b/src/Phpro/SoapClient/Soap/HttpBinding/Builder/Psr7RequestBuilder.php index 8ecc4560..697a6a0e 100644 --- a/src/Phpro/SoapClient/Soap/HttpBinding/Builder/Psr7RequestBuilder.php +++ b/src/Phpro/SoapClient/Soap/HttpBinding/Builder/Psr7RequestBuilder.php @@ -70,7 +70,7 @@ public function __construct(MessageFactory $messageFactory, StreamFactory $strea * @return RequestInterface * @throws RequestException */ - public function getHttpRequest() + public function getHttpRequest(): RequestInterface { $this->validate(); @@ -92,7 +92,7 @@ public function getHttpRequest() /** * @param string $endpoint */ - public function setEndpoint($endpoint) + public function setEndpoint(string $endpoint) { $this->endpoint = $endpoint; } @@ -117,7 +117,7 @@ public function isSOAP12() /** * @param string $soapAction */ - public function setSoapAction($soapAction) + public function setSoapAction(string $soapAction) { $this->soapAction = $soapAction; } @@ -125,7 +125,7 @@ public function setSoapAction($soapAction) /** * @param string $content */ - public function setSoapMessage($content) + public function setSoapMessage(string $content) { $this->soapMessage = $this->streamFactory->createStream($content); $this->hasSoapMessage = true; @@ -134,7 +134,7 @@ public function setSoapMessage($content) /** * @param string $method */ - public function setHttpMethod($method) + public function setHttpMethod(string $method) { $this->httpMethod = $method; } @@ -173,7 +173,7 @@ private function validate() /** * @return array */ - private function prepareHeaders() + private function prepareHeaders(): array { if ($this->soapVersion === self::SOAP11) { return $this->prepareSoap11Headers(); @@ -186,7 +186,7 @@ private function prepareHeaders() * @link https://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383526 * @return array */ - private function prepareSoap11Headers() + private function prepareSoap11Headers(): array { $headers = []; $headers['Content-Length'] = (string) $this->soapMessage->getSize(); @@ -202,7 +202,7 @@ private function prepareSoap11Headers() * @link https://www.w3.org/TR/soap12-part0/#L4697 * @return array */ - private function prepareSoap12Headers() + private function prepareSoap12Headers(): array { $headers = []; if ($this->httpMethod !== 'POST') { @@ -219,7 +219,7 @@ private function prepareSoap12Headers() /** * @return StreamInterface */ - private function prepareMessage() + private function prepareMessage(): StreamInterface { if ($this->httpMethod === 'POST') { return $this->soapMessage; diff --git a/src/Phpro/SoapClient/Soap/HttpBinding/LastRequestInfo.php b/src/Phpro/SoapClient/Soap/HttpBinding/LastRequestInfo.php index 42c0d3ba..823f2d12 100644 --- a/src/Phpro/SoapClient/Soap/HttpBinding/LastRequestInfo.php +++ b/src/Phpro/SoapClient/Soap/HttpBinding/LastRequestInfo.php @@ -58,7 +58,7 @@ public function __construct( * * @return LastRequestInfo */ - public static function createFromSoapClient(\SoapClient $soapClient) + public static function createFromSoapClient(\SoapClient $soapClient): self { return new self( (string) $soapClient->__getLastRequestHeaders(), @@ -74,8 +74,10 @@ public static function createFromSoapClient(\SoapClient $soapClient) * * @return LastRequestInfo */ - public static function createFromPsr7RequestAndResponse(RequestInterface $request, ResponseInterface $response) - { + public static function createFromPsr7RequestAndResponse( + RequestInterface $request, + ResponseInterface $response + ): self { // Reset the bodies: $request->getBody()->rewind(); $response->getBody()->rewind(); @@ -126,7 +128,7 @@ public static function createFromPsr7RequestAndResponse(RequestInterface $reques /** * @return LastRequestInfo */ - public static function createEmpty() + public static function createEmpty(): self { return new self('', '', '', ''); } diff --git a/src/Phpro/SoapClient/Soap/SoapClient.php b/src/Phpro/SoapClient/Soap/SoapClient.php index acaa6a5f..d2a37303 100644 --- a/src/Phpro/SoapClient/Soap/SoapClient.php +++ b/src/Phpro/SoapClient/Soap/SoapClient.php @@ -84,7 +84,7 @@ public function setHandler(HandlerInterface $handler) * * @return array Array of types and their properties */ - public function getSoapTypes() + public function getSoapTypes(): array { if ($this->types) { return $this->types; @@ -92,7 +92,7 @@ public function getSoapTypes() $soapTypes = $this->__getTypes(); foreach ($soapTypes as $soapType) { - $properties = array(); + $properties = []; $lines = explode("\n", $soapType); if (!preg_match('/struct (.*) {/', $lines[0], $matches)) { continue; @@ -113,13 +113,6 @@ public function getSoapTypes() return $this->types; } - /** - * Get a SOAP type’s elements - * - * @param string $type Object name - * @return array Elements for the type - */ - /** * Get SOAP elements for a complexType * @@ -127,7 +120,7 @@ public function getSoapTypes() * * @return array Names of elements and their types */ - public function getSoapElements($complexType) + public function getSoapElements(string $complexType): array { $types = $this->getSoapTypes(); if (isset($types[$complexType])) { @@ -143,7 +136,7 @@ public function getSoapElements($complexType) * * @return string */ - public function getSoapElementType($complexType, $element) + public function getSoapElementType(string $complexType, string $element): string { $elements = $this->getSoapElements($complexType); if ($elements && isset($elements[$element])) { @@ -160,9 +153,14 @@ public function getSoapElementType($complexType, $element) * * @return string */ - public function doInternalRequest($request, $location, $action, $version, $oneWay = 0) - { - return (string) parent::__doRequest($request, $location, $action, $version, $oneWay); + public function doInternalRequest( + string $request, + string $location, + string $action, + int $version, + int $oneWay = 0 + ): string { + return (string)parent::__doRequest($request, $location, $action, $version, $oneWay); } /** @@ -187,10 +185,10 @@ public function __doRequest($request, $location, $action, $version, $oneWay = 0) // Copy the request info in the correct internal __last_* parameters: // We don't need the trace option: always remember the last response @ request - $this->__last_request = (string) $lastRequestInfo->getLastRequest() ?? $request; - $this->__last_response = (string) $lastRequestInfo->getLastResponse() ?? $response->getResponse(); - $this->__last_request_headers = (string) $lastRequestInfo->getLastRequestHeaders(); - $this->__last_response_headers = (string) $lastRequestInfo->getLastResponseHeaders(); + $this->__last_request = (string)$lastRequestInfo->getLastRequest() ?? $request; + $this->__last_response = (string)$lastRequestInfo->getLastResponse() ?? $response->getResponse(); + $this->__last_request_headers = (string)$lastRequestInfo->getLastRequestHeaders(); + $this->__last_response_headers = (string)$lastRequestInfo->getLastResponseHeaders(); // Return the response or an empty response when oneWay is enabled. return $oneWay ? null : $response->getResponse(); @@ -201,7 +199,7 @@ public function __doRequest($request, $location, $action, $version, $oneWay = 0) */ public function __getLastRequest(): string { - return $this->__last_request ?: (string) parent::__getLastRequest(); + return $this->__last_request ?: (string)parent::__getLastRequest(); } /** @@ -209,7 +207,7 @@ public function __getLastRequest(): string */ public function __getLastResponse(): string { - return $this->__last_response ?: (string) parent::__getLastResponse(); + return $this->__last_response ?: (string)parent::__getLastResponse(); } /** @@ -217,7 +215,7 @@ public function __getLastResponse(): string */ public function __getLastRequestHeaders(): string { - return $this->__last_request_headers ?: (string) parent::__getLastRequestHeaders(); + return $this->__last_request_headers ?: (string)parent::__getLastRequestHeaders(); } /** @@ -225,6 +223,6 @@ public function __getLastRequestHeaders(): string */ public function __getLastResponseHeaders(): string { - return $this->__last_response_headers ?: (string) parent::__getLastResponseHeaders(); + return $this->__last_response_headers ?: (string)parent::__getLastResponseHeaders(); } } diff --git a/src/Phpro/SoapClient/Soap/SoapClientFactory.php b/src/Phpro/SoapClient/Soap/SoapClientFactory.php index 538609d9..e31e0de0 100644 --- a/src/Phpro/SoapClient/Soap/SoapClientFactory.php +++ b/src/Phpro/SoapClient/Soap/SoapClientFactory.php @@ -39,7 +39,7 @@ public function __construct(ClassMapCollection $classMap, TypeConverterCollectio * * @return SoapClient */ - public function factory($wsdl, array $soapOptions = []) + public function factory(string $wsdl, array $soapOptions = []): SoapClient { $defaults = [ 'trace' => true, diff --git a/src/Phpro/SoapClient/Soap/TypeConverter/DateTimeTypeConverter.php b/src/Phpro/SoapClient/Soap/TypeConverter/DateTimeTypeConverter.php index c9976347..8f03240a 100644 --- a/src/Phpro/SoapClient/Soap/TypeConverter/DateTimeTypeConverter.php +++ b/src/Phpro/SoapClient/Soap/TypeConverter/DateTimeTypeConverter.php @@ -18,7 +18,7 @@ class DateTimeTypeConverter implements TypeConverterInterface /** * {@inheritdoc} */ - public function getTypeNamespace() + public function getTypeNamespace(): string { return 'http://www.w3.org/2001/XMLSchema'; } @@ -26,7 +26,7 @@ public function getTypeNamespace() /** * {@inheritdoc} */ - public function getTypeName() + public function getTypeName(): string { return 'dateTime'; } @@ -34,7 +34,7 @@ public function getTypeName() /** * {@inheritdoc} */ - public function convertXmlToPhp($data) + public function convertXmlToPhp(string $data) { $doc = new DOMDocument(); $doc->loadXML($data); @@ -52,7 +52,7 @@ public function convertXmlToPhp($data) /** * {@inheritdoc} */ - public function convertPhpToXml($php) + public function convertPhpToXml($php): string { return sprintf('<%1$s>%2$s', $this->getTypeName(), $php->format('Y-m-d\TH:i:sP')); } diff --git a/src/Phpro/SoapClient/Soap/TypeConverter/DateTypeConverter.php b/src/Phpro/SoapClient/Soap/TypeConverter/DateTypeConverter.php index c6e2b124..739ccb4a 100644 --- a/src/Phpro/SoapClient/Soap/TypeConverter/DateTypeConverter.php +++ b/src/Phpro/SoapClient/Soap/TypeConverter/DateTypeConverter.php @@ -17,7 +17,7 @@ class DateTypeConverter implements TypeConverterInterface /** * {@inheritdoc} */ - public function getTypeNamespace() + public function getTypeNamespace(): string { return 'http://www.w3.org/2001/XMLSchema'; } @@ -25,7 +25,7 @@ public function getTypeNamespace() /** * {@inheritdoc} */ - public function getTypeName() + public function getTypeName(): string { return 'date'; } @@ -33,7 +33,7 @@ public function getTypeName() /** * {@inheritdoc} */ - public function convertXmlToPhp($data) + public function convertXmlToPhp(string $data) { $doc = new DOMDocument(); $doc->loadXML($data); @@ -50,7 +50,7 @@ public function convertXmlToPhp($data) /** * {@inheritdoc} */ - public function convertPhpToXml($php) + public function convertPhpToXml($php): string { return sprintf('<%1$s>%2$s', $this->getTypeName(), $php->format('Y-m-d')); } diff --git a/src/Phpro/SoapClient/Soap/TypeConverter/DecimalTypeConverter.php b/src/Phpro/SoapClient/Soap/TypeConverter/DecimalTypeConverter.php index 98b9f20c..857e59e0 100644 --- a/src/Phpro/SoapClient/Soap/TypeConverter/DecimalTypeConverter.php +++ b/src/Phpro/SoapClient/Soap/TypeConverter/DecimalTypeConverter.php @@ -16,7 +16,7 @@ class DecimalTypeConverter implements TypeConverterInterface /** * {@inheritdoc} */ - public function getTypeNamespace() + public function getTypeNamespace(): string { return 'http://www.w3.org/2001/XMLSchema'; } @@ -24,7 +24,7 @@ public function getTypeNamespace() /** * {@inheritdoc} */ - public function getTypeName() + public function getTypeName(): string { return 'decimal'; } @@ -32,7 +32,7 @@ public function getTypeName() /** * {@inheritdoc} */ - public function convertXmlToPhp($data) + public function convertXmlToPhp(string $data) { $doc = new DOMDocument(); $doc->loadXML($data); @@ -47,7 +47,7 @@ public function convertXmlToPhp($data) /** * {@inheritdoc} */ - public function convertPhpToXml($php) + public function convertPhpToXml($php): string { return sprintf('<%1$s>%2$s', $this->getTypeName(), $php); } diff --git a/src/Phpro/SoapClient/Soap/TypeConverter/DoubleTypeConverter.php b/src/Phpro/SoapClient/Soap/TypeConverter/DoubleTypeConverter.php index aa93d212..8eaa88a0 100644 --- a/src/Phpro/SoapClient/Soap/TypeConverter/DoubleTypeConverter.php +++ b/src/Phpro/SoapClient/Soap/TypeConverter/DoubleTypeConverter.php @@ -16,7 +16,7 @@ class DoubleTypeConverter implements TypeConverterInterface /** * {@inheritdoc} */ - public function getTypeNamespace() + public function getTypeNamespace(): string { return 'http://www.w3.org/2001/XMLSchema'; } @@ -24,7 +24,7 @@ public function getTypeNamespace() /** * {@inheritdoc} */ - public function getTypeName() + public function getTypeName(): string { return 'double'; } @@ -32,7 +32,7 @@ public function getTypeName() /** * {@inheritdoc} */ - public function convertXmlToPhp($data) + public function convertXmlToPhp(string $data) { $doc = new DOMDocument(); $doc->loadXML($data); @@ -47,7 +47,7 @@ public function convertXmlToPhp($data) /** * {@inheritdoc} */ - public function convertPhpToXml($php) + public function convertPhpToXml($php): string { return sprintf('<%1$s>%2$s', $this->getTypeName(), $php); } diff --git a/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterCollection.php b/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterCollection.php index 8ede3d21..c8ac9132 100644 --- a/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterCollection.php +++ b/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterCollection.php @@ -35,7 +35,7 @@ public function __construct(array $converters = []) * * @return string */ - private function serialize(TypeConverterInterface $converter) + private function serialize(TypeConverterInterface $converter): string { return $converter->getTypeNamespace() . ':' . $converter->getTypeName(); } @@ -48,7 +48,7 @@ private function serialize(TypeConverterInterface $converter) * @return TypeConverterCollection * @throws InvalidArgumentException */ - public function add(TypeConverterInterface $converter) + public function add(TypeConverterInterface $converter): self { if ($this->has($converter)) { throw new InvalidArgumentException( @@ -66,7 +66,7 @@ public function add(TypeConverterInterface $converter) * * @return TypeConverterCollection */ - public function set(TypeConverterInterface $converter) + public function set(TypeConverterInterface $converter): self { $serialized = $this->serialize($converter); $this->converters[$serialized] = $converter; @@ -82,7 +82,7 @@ public function set(TypeConverterInterface $converter) * * @return bool */ - public function has(TypeConverterInterface $converter) + public function has(TypeConverterInterface $converter): bool { $serialized = $this->serialize($converter); if (isset($this->converters[$serialized])) { @@ -97,7 +97,7 @@ public function has(TypeConverterInterface $converter) * * @return array */ - public function toSoapTypeMap() + public function toSoapTypeMap(): array { $typemap = []; diff --git a/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterInterface.php b/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterInterface.php index ae3869ec..793deb7a 100644 --- a/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterInterface.php +++ b/src/Phpro/SoapClient/Soap/TypeConverter/TypeConverterInterface.php @@ -16,14 +16,14 @@ interface TypeConverterInterface * * @return string */ - public function getTypeNamespace(); + public function getTypeNamespace(): string; /** * Get type name. * * @return string */ - public function getTypeName(); + public function getTypeName(): string; /** * Convert given XML string to PHP type. @@ -32,7 +32,7 @@ public function getTypeName(); * * @return mixed */ - public function convertXmlToPhp($xml); + public function convertXmlToPhp(string $xml); /** * Convert PHP type to XML string. @@ -41,5 +41,5 @@ public function convertXmlToPhp($xml); * * @return string */ - public function convertPhpToXml($php); + public function convertPhpToXml($php): string; } diff --git a/src/Phpro/SoapClient/Type/MultiArgumentRequest.php b/src/Phpro/SoapClient/Type/MultiArgumentRequest.php index ca555274..fa46c6ce 100644 --- a/src/Phpro/SoapClient/Type/MultiArgumentRequest.php +++ b/src/Phpro/SoapClient/Type/MultiArgumentRequest.php @@ -27,7 +27,7 @@ public function __construct(array $arguments) /** * @return array */ - public function getArguments() + public function getArguments(): array { return $this->arguments; } diff --git a/src/Phpro/SoapClient/Type/MultiArgumentRequestInterface.php b/src/Phpro/SoapClient/Type/MultiArgumentRequestInterface.php index 1aea6034..9ca0001b 100644 --- a/src/Phpro/SoapClient/Type/MultiArgumentRequestInterface.php +++ b/src/Phpro/SoapClient/Type/MultiArgumentRequestInterface.php @@ -12,5 +12,5 @@ interface MultiArgumentRequestInterface extends RequestInterface /** * @return array */ - public function getArguments(); + public function getArguments(): array; } diff --git a/src/Phpro/SoapClient/Type/ResultProviderInterface.php b/src/Phpro/SoapClient/Type/ResultProviderInterface.php index 1c8a1d18..c8dfe8c2 100644 --- a/src/Phpro/SoapClient/Type/ResultProviderInterface.php +++ b/src/Phpro/SoapClient/Type/ResultProviderInterface.php @@ -15,5 +15,5 @@ interface ResultProviderInterface /** * @return ResultInterface */ - public function getResult(); + public function getResult(): ResultInterface; } diff --git a/src/Phpro/SoapClient/Util/Filesystem.php b/src/Phpro/SoapClient/Util/Filesystem.php index 772fc73d..24a4ec9f 100644 --- a/src/Phpro/SoapClient/Util/Filesystem.php +++ b/src/Phpro/SoapClient/Util/Filesystem.php @@ -17,7 +17,7 @@ class Filesystem /** * @param string $directory */ - public function ensureDirectoryExists($directory) + public function ensureDirectoryExists(string $directory) { if (is_dir($directory)) { return; @@ -31,20 +31,20 @@ public function ensureDirectoryExists($directory) } /** - * @param $file + * @param string $file * * @return bool */ - public function fileExists($file) + public function fileExists(string $file): bool { return is_file($file) && is_readable($file); } /** - * @param $path + * @param string $path * @return string */ - public function getFileContents($path) + public function getFileContents(string $path): string { if (!$this->fileExists($path)) { throw new InvalidArgumentException(sprintf('File %s does not exist.', $path)); @@ -54,10 +54,10 @@ public function getFileContents($path) } /** - * @param $path - * @param $content + * @param string $path + * @param mixed $content */ - public function putFileContents($path, $content) + public function putFileContents(string $path, $content) { file_put_contents($path, $content); } @@ -65,7 +65,7 @@ public function putFileContents($path, $content) /** * @param string $file */ - public function createBackup($file) + public function createBackup(string $file) { if (!$this->fileExists($file)) { throw new RuntimeException('Could not create a backup from a non existing file: ' . $file); @@ -78,7 +78,7 @@ public function createBackup($file) /** * @param string $file */ - public function removeBackup($file) + public function removeBackup(string $file) { $backupFile = preg_replace('{\.backup$}', '', $file) . '.backup'; if (!$this->fileExists($backupFile)) { diff --git a/src/Phpro/SoapClient/Wsdl/Provider/LocalWsdlProvider.php b/src/Phpro/SoapClient/Wsdl/Provider/LocalWsdlProvider.php index 2e5918d2..1ce811b2 100644 --- a/src/Phpro/SoapClient/Wsdl/Provider/LocalWsdlProvider.php +++ b/src/Phpro/SoapClient/Wsdl/Provider/LocalWsdlProvider.php @@ -30,7 +30,7 @@ public function __construct(Filesystem $filesystem) /** * @return LocalWsdlProvider */ - public static function create() + public static function create(): self { return new self(new Filesystem()); } diff --git a/src/Phpro/SoapClient/Wsdl/Provider/MixedWsdlProvider.php b/src/Phpro/SoapClient/Wsdl/Provider/MixedWsdlProvider.php index e98320b7..d9ee10a4 100644 --- a/src/Phpro/SoapClient/Wsdl/Provider/MixedWsdlProvider.php +++ b/src/Phpro/SoapClient/Wsdl/Provider/MixedWsdlProvider.php @@ -15,7 +15,7 @@ class MixedWsdlProvider implements WsdlProviderInterface * * {@inheritdoc} */ - public function provide(string $source) + public function provide(string $source): string { return $source; } diff --git a/src/Phpro/SoapClient/Wsdl/Provider/WsdlProviderInterface.php b/src/Phpro/SoapClient/Wsdl/Provider/WsdlProviderInterface.php index a39bbd93..804ade05 100644 --- a/src/Phpro/SoapClient/Wsdl/Provider/WsdlProviderInterface.php +++ b/src/Phpro/SoapClient/Wsdl/Provider/WsdlProviderInterface.php @@ -19,5 +19,5 @@ interface WsdlProviderInterface * @return string * @throws WsdlException */ - public function provide(string $source); + public function provide(string $source): string; } diff --git a/src/Phpro/SoapClient/Xml/SoapXml.php b/src/Phpro/SoapClient/Xml/SoapXml.php index d8bc4ebe..db9a684d 100644 --- a/src/Phpro/SoapClient/Xml/SoapXml.php +++ b/src/Phpro/SoapClient/Xml/SoapXml.php @@ -30,7 +30,7 @@ public function __construct(DOMDocument $xml) /** * @return string */ - public function getSoapNamespaceUri() + public function getSoapNamespaceUri(): string { return $this->getEnvelope()->namespaceURI; } @@ -48,7 +48,7 @@ public function addEnvelopeNamespace(string $prefix, string $namespaceUri) /** * @return DOMElement */ - public function getEnvelope() + public function getEnvelope(): DOMElement { return $this->getRootElement(); } @@ -56,7 +56,7 @@ public function getEnvelope() /** * @return \DOMNodeList */ - public function getHeaders() + public function getHeaders(): \DOMNodeList { return $this->xpath('//soap:Envelope/soap:Header'); } @@ -81,7 +81,7 @@ public function prependSoapHeader(DOMElement $header) /** * @return DOMElement|null */ - public function getBody() + public function getBody(): DOMElement { $list = $this->xpath('//soap:Envelope/soap:Body'); diff --git a/src/Phpro/SoapClient/Xml/WsdlXml.php b/src/Phpro/SoapClient/Xml/WsdlXml.php index 619e3c20..e887ad1d 100644 --- a/src/Phpro/SoapClient/Xml/WsdlXml.php +++ b/src/Phpro/SoapClient/Xml/WsdlXml.php @@ -27,7 +27,7 @@ public function __construct(DOMDocument $xml) /** * @return string */ - public function getWsdlNamespaceUri() + public function getWsdlNamespaceUri(): string { return $this->getRootNamespace(); } diff --git a/src/Phpro/SoapClient/Xml/Xml.php b/src/Phpro/SoapClient/Xml/Xml.php index bb535373..e3f2f582 100644 --- a/src/Phpro/SoapClient/Xml/Xml.php +++ b/src/Phpro/SoapClient/Xml/Xml.php @@ -39,7 +39,7 @@ public function __construct(DOMDocument $xml) /** * @return string */ - public function getRootNamespace() + public function getRootNamespace(): string { return $this->getRootElement()->namespaceURI; } @@ -56,7 +56,7 @@ public function registerNamespace(string $prefix, string $namespaceUri) /** * @return DOMDocument */ - public function getXmlDocument() + public function getXmlDocument(): DOMDocument { return $this->xml; } @@ -64,17 +64,17 @@ public function getXmlDocument() /** * @return DOMElement */ - public function getRootElement() + public function getRootElement(): DOMElement { return $this->xml->documentElement; } /** - * @param $expression + * @param string $expression * * @return \DOMNodeList */ - public function xpath($expression) + public function xpath(string $expression): \DOMNodeList { return $this->xpath->query($expression); }