Skip to content

Commit 8043178

Browse files
#8 Remove all phpstan ignoreErrors. Fix code.
1 parent 7e98456 commit 8043178

File tree

5 files changed

+34
-18
lines changed

5 files changed

+34
-18
lines changed

phpstan.neon

-13
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,3 @@ parameters:
33
paths:
44
- src
55
- tests
6-
ignoreErrors:
7-
- '#type has no value type specified in iterable type#'
8-
- '#has parameter .* with no value type specified in iterable type#'
9-
- '#has no value type specified in iterable type array#'
10-
- '#configureOptions\(\) has no return type specified.#'
11-
- '#configure\(\) has no return type specified#'
12-
- '#process\(\) has no return type specified#'
13-
- '#should return Iterator but returns Traversable#'
14-
- '#Negated boolean expression is always false#'
15-
checkGenericClassInNonGenericObjectType: false
16-
reportUnmatchedIgnoredErrors: false
17-
inferPrivatePropertyTypeFromConstructor: true
18-
treatPhpDocTypesAsCertain: false

src/Client/Client.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class Client implements ClientInterface
2424
{
25-
/** @var array */
25+
/** @var array<mixed>|null */
2626
private $soapOptions;
2727

2828
/** @var \SoapHeader[]|null */
@@ -50,6 +50,7 @@ public function __construct(
5050
private readonly LoggerInterface $logger,
5151
private readonly string $code,
5252
private ?string $wsdl,
53+
/** @var array<mixed> */
5354
private array $options = [],
5455
) {
5556
}
@@ -167,9 +168,6 @@ public function setLastResponseHeaders(?string $lastResponseHeaders): void
167168
$this->lastResponseHeaders = $lastResponseHeaders;
168169
}
169170

170-
/**
171-
* @return bool|mixed
172-
*/
173171
public function call(string $method, array $input = []): mixed
174172
{
175173
$this->initializeSoapClient();
@@ -187,6 +185,8 @@ public function call(string $method, array $input = []): mixed
187185
}
188186

189187
/**
188+
* @param array<mixed> $input
189+
*
190190
* @return bool|mixed
191191
*/
192192
protected function doSoapCall(string $method, array $input = []): mixed
@@ -196,7 +196,7 @@ protected function doSoapCall(string $method, array $input = []): mixed
196196
}
197197
try {
198198
$result = $this->getSoapClient()->__soapCall($method, $input, $this->getSoapOptions(), $this->getSoapHeaders());
199-
} /* @noinspection PhpRedundantCatchClauseInspection */ catch (\SoapFault $e) {
199+
} catch (\SoapFault $e) {
200200
$this->getLastRequestTrace();
201201
$this->getLogger()->alert(
202202
\sprintf("Soap call '%s' on '%s' failed : %s", $method, $this->getWsdl(), $e->getMessage()),
@@ -239,6 +239,14 @@ protected function getLastRequestTrace(): void
239239
}
240240
}
241241

242+
/**
243+
* @return array{
244+
* 'LastRequest': ?string,
245+
* 'LastRequestHeaders': ?string,
246+
* 'LastResponse': ?string,
247+
* 'LastResponseHeaders': ?string
248+
* }
249+
*/
242250
protected function getLastRequestTraceArray(): array
243251
{
244252
return [

src/Client/ClientInterface.php

+10
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,35 @@ public function setWsdl(?string $wsdl): void;
3434
* Return the Soap client options.
3535
*
3636
* @see http://php.net/manual/en/soapclient.soapclient.php
37+
*
38+
* @return array<mixed>
3739
*/
3840
public function getOptions(): array;
3941

4042
/**
4143
* Set the Soap client options.
4244
*
4345
* @see http://php.net/manual/en/soapclient.soapclient.php
46+
*
47+
* @param array<mixed> $options
4448
*/
4549
public function setOptions(array $options): void;
4650

4751
/**
4852
* Return the Soap call options.
4953
*
5054
* @see https://www.php.net/manual/en/soapclient.soapcall.php
55+
*
56+
* @return array<mixed>|null
5157
*/
5258
public function getSoapOptions(): ?array;
5359

5460
/**
5561
* Set the Soap call options.
5662
*
5763
* @see https://www.php.net/manual/en/soapclient.soapcall.php
64+
*
65+
* @param array<mixed>|null $options
5866
*/
5967
public function setSoapOptions(?array $options = null): void;
6068

@@ -87,6 +95,8 @@ public function getLastResponseHeaders(): ?string;
8795
/**
8896
* Call Soap method.
8997
*
98+
* @param array<mixed> $input
99+
*
90100
* @return bool|mixed
91101
*/
92102
public function call(string $method, array $input = []): mixed;

src/Task/RequestTask.php

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function execute(ProcessState $state): void
3333

3434
$client = $this->registry->getClient($options['client']);
3535

36+
/** @var array<mixed> $input */
3637
$input = $state->getInput() ?: [];
3738

3839
$client->setSoapOptions($this->getOption($state, 'soap_call_options'));

src/Transformer/RequestTransformer.php

+10
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,26 @@
1717
use CleverAge\SoapProcessBundle\Registry\ClientRegistry;
1818
use Symfony\Component\OptionsResolver\OptionsResolver;
1919

20+
/**
21+
* @phpstan-type Options array{
22+
* 'client': string,
23+
* 'method': string,
24+
* }
25+
*/
2026
class RequestTransformer implements ConfigurableTransformerInterface
2127
{
2228
public function __construct(protected ClientRegistry $registry)
2329
{
2430
}
2531

32+
/**
33+
* @param array<mixed> $options
34+
*/
2635
public function transform(mixed $value, array $options = []): mixed
2736
{
2837
$resolver = new OptionsResolver();
2938
$this->configureOptions($resolver);
39+
/** @var Options $options */
3040
$options = $resolver->resolve($options);
3141

3242
$client = $this->registry->getClient($options['client']);

0 commit comments

Comments
 (0)