Skip to content

Commit e92cb0c

Browse files
committed
Fix psalm l3
1 parent cfee3ee commit e92cb0c

17 files changed

+125
-33
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/vendor/
22
composer.lock
3-
.phpunit.result.cache
3+
.phpunit.result.cache
4+
.php_cs.cache
5+

.phive/phars.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phive xmlns="https://phar.io/phive">
3+
<phar name="psalm" version="^4.3.1" installed="4.8.1" location="./tools/psalm.phar" copy="true"/>
4+
<phar name="php-cs-fixer" version="^2.18.2" installed="2.19.0" location="./tools/php-cs-fixer.phar" copy="true"/>
5+
</phive>

.php_cs.dist

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
return PhpCsFixer\Config::create()
4+
->setFinder(
5+
\Symfony\Component\Finder\Finder::create()
6+
->in([
7+
__DIR__ . '/src',
8+
__DIR__ . '/tests',
9+
])
10+
->name('*.php')
11+
)
12+
->setRiskyAllowed(true)
13+
->setRules([
14+
'@PSR2' => true,
15+
'align_multiline_comment' => true,
16+
'array_indentation' => true,
17+
'declare_strict_types' => true,
18+
'final_class' => true,
19+
'global_namespace_import' => [
20+
'import_classes' => true,
21+
'import_constants' => true,
22+
'import_functions' => true,
23+
],
24+
'list_syntax' => [
25+
'syntax' => 'short',
26+
],
27+
'lowercase_constants' => true,
28+
'multiline_comment_opening_closing' => true,
29+
'native_function_casing' => true,
30+
'no_empty_phpdoc' => true,
31+
'no_leading_import_slash' => true,
32+
'no_superfluous_phpdoc_tags' => [
33+
'allow_mixed' => true,
34+
],
35+
'no_unused_imports' => true,
36+
'no_useless_else' => true,
37+
'no_useless_return' => true,
38+
'ordered_imports' => [
39+
'imports_order' => ['class', 'function', 'const'],
40+
],
41+
'ordered_interfaces' => true,
42+
'php_unit_test_annotation' => true,
43+
'php_unit_test_case_static_method_calls' => [
44+
'call_type' => 'static',
45+
],
46+
'php_unit_method_casing' => [
47+
'case' => 'snake_case',
48+
],
49+
'single_import_per_statement' => true,
50+
'single_trait_insert_per_statement' => true,
51+
'static_lambda' => true,
52+
'strict_comparison' => true,
53+
'strict_param' => true,
54+
])
55+
;

psalm.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
errorLevel="2"
4+
resolveFromConfigFile="true"
5+
forbidEcho="true"
6+
strictBinaryOperands="true"
7+
phpVersion="8.0"
8+
allowPhpStormGenerics="true"
9+
allowStringToStandInForClass="true"
10+
rememberPropertyAssignmentsAfterCall="false"
11+
skipChecksOnUnresolvableIncludes="false"
12+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
13+
xmlns="https://getpsalm.org/schema/config"
14+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
15+
>
16+
<projectFiles>
17+
<directory name="src" />
18+
<ignoreFiles>
19+
<directory name="vendor" />
20+
<directory name="tests" />
21+
</ignoreFiles>
22+
</projectFiles>
23+
</psalm>

src/AbusedClient.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class AbusedClient extends \SoapClient
3131
protected $__last_response = '';
3232
// @codingStandardsIgnoreEnd
3333

34-
public function __construct($wsdl, array $options = [])
34+
public function __construct(?string $wsdl, array $options = [])
3535
{
3636
$options = ExtSoapOptionsResolverFactory::createForWsdl($wsdl)->resolve($options);
3737
parent::__construct($wsdl, $options);
@@ -42,6 +42,9 @@ public static function createFromOptions(ExtSoapOptions $options): self
4242
return new self($options->getWsdl(), $options->getOptions());
4343
}
4444

45+
/**
46+
* @psalm-suppress RedundantCastGivenDocblockType - Whatever psalm says ... $oneWay can be bool :-(
47+
*/
4548
public function __doRequest($request, $location, $action, $version, $oneWay = 0)
4649
{
4750
$this->storedRequest = new SoapRequest($request, $location, $action, $version, (int) $oneWay);
@@ -56,9 +59,8 @@ public function doActualRequest(
5659
int $version,
5760
int $oneWay = 0
5861
): string {
59-
$typedOneWay = PHP_VERSION_ID >= 80000 ? (bool) $oneWay : $oneWay;
6062
$this->__last_request = $request;
61-
$this->__last_response = (string) parent::__doRequest($request, $location, $action, $version, $typedOneWay);
63+
$this->__last_response = parent::__doRequest($request, $location, $action, $version, $oneWay);
6264

6365
return $this->__last_response;
6466
}
@@ -72,12 +74,12 @@ public function collectRequest(): SoapRequest
7274
return $this->storedRequest;
7375
}
7476

75-
public function registerResponse(SoapResponse $response)
77+
public function registerResponse(SoapResponse $response): void
7678
{
7779
$this->storedResponse = $response;
7880
}
7981

80-
public function cleanUpTemporaryState()
82+
public function cleanUpTemporaryState(): void
8183
{
8284
$this->storedRequest = null;
8385
$this->storedResponse = null;

src/Configuration/TypeConverter/DateTimeTypeConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ public function getTypeName(): string
2424
return 'dateTime';
2525
}
2626

27-
public function convertXmlToPhp(string $data)
27+
public function convertXmlToPhp(string $xml)
2828
{
2929
$doc = new DOMDocument();
30-
$doc->loadXML($data);
30+
$doc->loadXML($xml);
3131

3232
if ('' === $doc->textContent) {
3333
return null;

src/Configuration/TypeConverter/DateTypeConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public function getTypeName(): string
2323
return 'date';
2424
}
2525

26-
public function convertXmlToPhp(string $data)
26+
public function convertXmlToPhp(string $xml)
2727
{
2828
$doc = new DOMDocument();
29-
$doc->loadXML($data);
29+
$doc->loadXML($xml);
3030

3131
if ('' === $doc->textContent) {
3232
return null;

src/Configuration/TypeConverter/DecimalTypeConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public function getTypeName(): string
2121
return 'decimal';
2222
}
2323

24-
public function convertXmlToPhp(string $data)
24+
public function convertXmlToPhp(string $xml)
2525
{
2626
$doc = new DOMDocument();
27-
$doc->loadXML($data);
27+
$doc->loadXML($xml);
2828

2929
if ('' === $doc->textContent) {
3030
return null;

src/Configuration/TypeConverter/DoubleTypeConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public function getTypeName(): string
2121
return 'double';
2222
}
2323

24-
public function convertXmlToPhp(string $data)
24+
public function convertXmlToPhp(string $xml)
2525
{
2626
$doc = new DOMDocument();
27-
$doc->loadXML($data);
27+
$doc->loadXML($xml);
2828

2929
if ('' === $doc->textContent) {
3030
return null;

src/Configuration/TypeConverter/TypeConverterCollection.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Soap\ExtSoapEngine\Configuration\TypeConverter;
44

55
use IteratorAggregate;
6-
use Phpro\SoapClient\Exception\InvalidArgumentException;
76
use Traversable;
87

98
final class TypeConverterCollection implements IteratorAggregate
@@ -41,12 +40,11 @@ private function serialize(TypeConverterInterface $converter): string
4140
* @param TypeConverterInterface $converter Type converter
4241
*
4342
* @return TypeConverterCollection
44-
* @throws InvalidArgumentException
4543
*/
4644
public function add(TypeConverterInterface $converter): self
4745
{
4846
if ($this->has($converter)) {
49-
throw new InvalidArgumentException(
47+
throw new \InvalidArgumentException(
5048
'Converter for this type already exists'
5149
);
5250
}

0 commit comments

Comments
 (0)