From 2bcd30e5f2396592e757f5cd3196922b54cd4bcc Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Fri, 26 Jul 2024 08:30:24 -0400 Subject: [PATCH] chore: lint all files via pint + strict typing --- phpcs.xml | 9 --- phpunit.xml | 17 ++--- .../ClientClassNotFoundException.php | 3 +- src/Exceptions/CurtainNotSetupException.php | 3 +- .../CurtainRequiresWsdlException.php | 3 +- src/SoapyBaseClient.php | 3 +- src/SoapyClient.php | 3 +- src/SoapyCurtain.php | 66 ++++++++++--------- src/SoapyFacade.php | 6 +- src/SoapyServiceProvider.php | 9 +-- src/SoapyTub.php | 13 ++-- tests/BaseTestCase.php | 5 +- tests/TestSoapyClient.php | 3 +- tests/Unit/CustomClassTest.php | 3 +- 14 files changed, 72 insertions(+), 74 deletions(-) delete mode 100644 phpcs.xml diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index da20ccc..0000000 --- a/phpcs.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - ./src - ./tests - - */vendor/* - - - diff --git a/phpunit.xml b/phpunit.xml index 3e35454..191b1c5 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,23 +1,16 @@ + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd" bootstrap="vendor/autoload.php" + executionOrder="depends,defects" failOnRisky="true" failOnWarning="true" cacheDirectory=".phpunit.cache" + requireCoverageMetadata="false"> ./tests/Unit - - + src - + diff --git a/src/Exceptions/ClientClassNotFoundException.php b/src/Exceptions/ClientClassNotFoundException.php index 3d4e7cb..99d8688 100644 --- a/src/Exceptions/ClientClassNotFoundException.php +++ b/src/Exceptions/ClientClassNotFoundException.php @@ -1,5 +1,6 @@ $this->getTrace(), + 'trace' => $this->getTrace(), 'cache_wsdl' => $this->getCache(), ]; @@ -104,19 +96,21 @@ public function getTypemap(): ?array return $this->typeMap; } - #endregion + //endregion - #region setters + //region setters public function setWsdl(string $wsdl): self { $this->wsdl = $wsdl; + return $this; } public function setTrace(bool $flag): self { $this->trace = $flag; + return $this; } @@ -125,10 +119,11 @@ public function setCache(int $cache): self $allowed = [WSDL_CACHE_NONE, WSDL_CACHE_DISK, WSDL_CACHE_MEMORY, WSDL_CACHE_BOTH]; if (! in_array($cache, $allowed)) { - throw new \InvalidArgumentException('Cache value passed (' . $allowed . ') is not valid.'); + throw new \InvalidArgumentException('Cache value passed ('.$cache.') is not valid.'); } $this->cache = $cache; + return $this; } @@ -143,58 +138,65 @@ public function setClassMap(array $classmap): self } $this->classMap = $classes; + return $this; } public function setOptions(array $options): self { $this->options = $options; + return $this; } public function setCertificate(string $certificate): self { $this->certificate = $certificate; + return $this; } public function setLocation(string $location): self { $this->location = $location; + return $this; } public function setUri(string $uri): self { $this->uri = $uri; + return $this; } - public function addTypeMapViaClassName(string $namespace, string $item, string $itemClass) + public function addTypeMapViaClassName(string $namespace, string $item, string $itemClass): self { $function = function (string $xml) use ($itemClass) { $object = simplexml_load_string($xml); + return new $itemClass($object); }; return $this->addTypeMap($namespace, $item, $function); } - public function addTypeMap(string $namespace, string $item, \Closure $fromXml) + public function addTypeMap(string $namespace, string $item, \Closure $fromXml): self { $typeMap = [ - 'type_ns' => $namespace, + 'type_ns' => $namespace, 'type_name' => $item, - 'from_xml' => $fromXml, + 'from_xml' => $fromXml, ]; $this->typeMap[] = $typeMap; + return $this; } - #endregion + //endregion - #region functions + //region functions public function isReady(): bool { @@ -202,8 +204,8 @@ public function isReady(): bool return true; } - return !empty($this->getWsdl()); + return ! empty($this->getWsdl()); } - #endregion + //endregion } diff --git a/src/SoapyFacade.php b/src/SoapyFacade.php index e48f978..bac2a9f 100644 --- a/src/SoapyFacade.php +++ b/src/SoapyFacade.php @@ -1,5 +1,6 @@ app->singleton(SoapyTub::class, function () { - return new SoapyTub(); + return new SoapyTub; }); } } diff --git a/src/SoapyTub.php b/src/SoapyTub.php index ace13fd..8390d52 100644 --- a/src/SoapyTub.php +++ b/src/SoapyTub.php @@ -1,5 +1,6 @@ isReady()) { - throw new CurtainRequiresWsdlException(); + throw new CurtainRequiresWsdlException; } $client = new $soapyClient( diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 89d789d..2895231 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -1,5 +1,6 @@ baseWsdl = __DIR__ . '/example.wsdl'; + $this->baseWsdl = __DIR__.'/example.wsdl'; } } diff --git a/tests/TestSoapyClient.php b/tests/TestSoapyClient.php index 069f7b3..371a051 100644 --- a/tests/TestSoapyClient.php +++ b/tests/TestSoapyClient.php @@ -1,5 +1,6 @@