Skip to content

Commit 89d366b

Browse files
committed
fix code for phpstan
1 parent 09431b5 commit 89d366b

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

src/Traits/ConfigTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ private function getCommonConfig(IConfiguration $config): array
7070
if ($config->getLang() !== null) {
7171
$common['lang'] = $config->getLang();
7272
}
73+
//mandatory configuration parameters
7374
$common['client'] = $config->getClient();
7475
$common['user'] = $config->getUser();
7576
$common['passwd'] = $config->getPasswd();
@@ -95,6 +96,7 @@ private function getTypeAConfig(IConfigTypeA $config): array
9596
if ($config->getGwserv() !== null) {
9697
$typeA['gwserv'] = $config->getGwserv();
9798
}
99+
//mandatory configuration parameters
98100
$typeA['ashost'] = $config->getAshost();
99101
$typeA['sysnr'] = $config->getSysnr();
100102
return $typeA;
@@ -119,6 +121,7 @@ private function getTypeBConfig(IConfigTypeB $config): array
119121
if ($config->getGroup() !== null) {
120122
$typeB['group'] = $config->getGroup();
121123
}
124+
//mandatory configuration parameter
122125
$typeB['mshost'] = $config->getMshost();
123126
return $typeB;
124127
}

src/Traits/ParamTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace phpsap\saprfc\Traits;
66

7+
use phpsap\classes\Api\Struct;
8+
use phpsap\classes\Api\Table;
9+
use phpsap\classes\Api\Value;
710
use phpsap\exceptions\FunctionCallException;
811
use phpsap\interfaces\Api\IApiElement;
912
use phpsap\interfaces\exceptions\IInvalidArgumentException;
@@ -79,6 +82,7 @@ private function getTableParams(array $tables, array $params): array
7982
private function castOutput(array $outputs, array $result): array
8083
{
8184
$return = [];
85+
/** @var Value|Table|Struct $output */
8286
foreach ($outputs as $output) {
8387
$key = $output->getName();
8488
if (array_key_exists($key, $result)) {

tests/OutputTableTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class OutputTableTest extends AbstractTestCase
2828
{
2929
use TestCaseTrait;
3030

31+
/**
32+
* @var array
33+
*/
3134
public static array $apiRaw = [
3235
'ET_API_ANGEBOT_ADRESSE' => [
3336
'name' => 'ET_API_ANGEBOT_ADRESSE',
@@ -206,9 +209,9 @@ class OutputTableTest extends AbstractTestCase
206209
]
207210
];
208211
/**
209-
* @var string
212+
* @var array
210213
*/
211-
public static $apiJson = [
214+
public static array $apiJson = [
212215
0 => [
213216
'type' => 'table',
214217
'name' => 'ET_API_ANGEBOT_ADRESSE',
@@ -343,7 +346,7 @@ class OutputTableTest extends AbstractTestCase
343346
/**
344347
* Mock the RFC_OUTPUT_TABLE function.
345348
*/
346-
public function mockRfcOutputTable()
349+
public function mockRfcOutputTable(): void
347350
{
348351
//Use an object for connection flag and function name.
349352
$flags = new stdClass();
@@ -354,9 +357,9 @@ public function mockRfcOutputTable()
354357
$flags->response = self::$responseRaw;
355358
$expectedConfig = static::getSampleSapConfig();
356359
static::mock('\SAPNWRFC\Connection::__construct', static function (array $config, array $options) use ($flags, $expectedConfig) {
360+
unset($options);
357361
if (
358-
!is_array($config)
359-
|| !array_key_exists('ashost', $config)
362+
!array_key_exists('ashost', $config)
360363
|| !array_key_exists('sysnr', $config)
361364
|| !array_key_exists('client', $config)
362365
|| !array_key_exists('user', $config)
@@ -373,7 +376,7 @@ public function mockRfcOutputTable()
373376
$flags->conn = true;
374377
});
375378
static::mock('\SAPNWRFC\Connection::close', static function () use ($flags) {
376-
//calling \SAPNWRFC\Connection::close twice has to fail
379+
//calling \SAPNWRFC\Connection::close() twice has to fail
377380
if ($flags->conn !== true) {
378381
throw new ConnectionException('mock connection already closed!');
379382
}

tests/SapRfcIntegrationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ protected function mockFailedRemoteFunctionCallWithParameters()
786786
}
787787
return new RemoteFunction($name);
788788
});
789-
static::mock('\SAPNWRFC\RemoteFunction::invoke', static function (array $params, array $options) use ($flags) {
789+
static::mock('\SAPNWRFC\RemoteFunction::invoke', static function (array $params, array $options) {
790+
unset($params, $options);
790791
throw new FunctionCallException('mock function call exception!');
791792
});
792793
}

tests/helper/SAPNWRFC.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function ping(): bool
178178
/**
179179
* Lookup a RFC function and return a RemoteFunction object.
180180
*
181-
* @param string $functionnName Name of the function.
181+
* @param string $functionName Name of the function.
182182
* @param bool $invalidateCache If true, invalidates the function desc cache.
183183
*
184184
* @return RemoteFunction A RemoteFunction class for the RFC function.

0 commit comments

Comments
 (0)