Skip to content

Commit 00b6c29

Browse files
authored
Merge pull request #89 from LibreSign/chore/bump-psalm
chore: bump psalm
2 parents c6d5236 + c293d28 commit 00b6c29

File tree

6 files changed

+1468
-493
lines changed

6 files changed

+1468
-493
lines changed

composer.json

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,23 @@
99
"type": "library",
1010
"license": "AGPL-3.0-or-later",
1111
"prefer-stable": true,
12-
"authors": [
13-
{
14-
"name": "Vitor Mattos",
15-
"email": "vitor@php.rio"
16-
}
17-
],
12+
"authors": [{
13+
"name": "Vitor Mattos",
14+
"email": "vitor@php.rio"
15+
}],
1816
"scripts": {
1917
"bin": "echo 'bin not installed'",
2018
"cs:check": "php-cs-fixer fix --dry-run --diff",
2119
"cs:fix": "php-cs-fixer fix",
2220
"psalm": "psalm --threads=1",
23-
"psalm:update-baseline": "psalm --threads=1 --update-baseline --set-baseline=psalm-baseline.xml",
24-
"psalm:clear": "psalm --clear-cache && psalm --clear-global-cache",
21+
"psalm:update-baseline": "psalm --no-cache --threads=$(nproc) --update-baseline --set-baseline=psalm-baseline.xml",
2522
"post-install-cmd": [
26-
"@composer bin all install --ansi",
27-
"composer dump-autoload"
23+
"@composer bin all install --ansi",
24+
"composer dump-autoload"
2825
],
2926
"post-update-cmd": [
30-
"@composer bin all update --ansi",
31-
"composer dump-autoload"
27+
"@composer bin all update --ansi",
28+
"composer dump-autoload"
3229
]
3330
},
3431
"require": {
@@ -53,14 +50,14 @@
5350
}
5451
},
5552
"extra": {
56-
"bamarni-bin": {
57-
"bin-links": true,
58-
"forward-command": true
59-
}
53+
"bamarni-bin": {
54+
"bin-links": true,
55+
"forward-command": true
56+
}
6057
},
6158
"autoload": {
6259
"psr-4": {
6360
"Libresign\\NextcloudBehat\\": "src/"
6461
}
6562
}
66-
}
63+
}

features/bootstrap/FeatureContext.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ public function setTheResponseTo(PyStringNode $response): void {
9393
*/
9494
public function theResponseShouldBeAJsonArrayWithTheFollowingMandatoryValues(TableNode $table): void {
9595
$lastRequest = $this->getLastRequest();
96+
$body = json_encode($lastRequest->getParsedInput());
97+
Assert::assertIsString($body);
9698
// Mock response to be equal to body of request
9799
$this->mockServer->setDefaultResponse(new MockWebServerResponse(
98-
json_encode($lastRequest->getParsedInput())
100+
$body
99101
));
100102
parent::theResponseShouldBeAJsonArrayWithTheFollowingMandatoryValues($table);
101103
}

psalm-baseline.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.23.1@8471a896ccea3526b26d082f4461eeea467f10a4">
2+
<files psalm-version="6.5.0@38fc8444edf0cebc9205296ee6e30e906ade783b">
33
<file src="src/NextcloudApiContext.php">
44
<ForbiddenCode>
55
<code><![CDATA[`which jq`]]></code>

src/NextcloudApiContext.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,21 @@ private function testAndGetActualValue(array $value, string $json): string {
283283
);
284284
if (!is_string($actual)) {
285285
$actual = json_encode($actual);
286+
Assert::assertIsString($actual);
286287
}
287288
return $actual;
288289
}
290+
$responseAsJsonString = json_encode($realResponseArray);
291+
Assert::assertIsString($responseAsJsonString);
289292
Assert::assertArrayHasKey(
290293
$value['key'],
291294
$realResponseArray,
292-
'Not found: "' . $value['key'] . '" at array: ' . json_encode($realResponseArray)
295+
'Not found: "' . $value['key'] . '" at array: ' . $responseAsJsonString
293296
);
294297
$actual = $realResponseArray[$value['key']];
295298
if (!is_string($actual)) {
296299
$actual = json_encode($actual);
300+
Assert::assertIsString($actual);
297301
}
298302
return $actual;
299303
}
@@ -327,7 +331,9 @@ public function fetchFieldFromPreviousJsonResponse(string $path): void {
327331
$keys = explode('.', $path);
328332
$value = $responseArray;
329333
foreach ($keys as $key) {
330-
Assert::assertArrayHasKey($key, $value, 'Key [' . $key . '] of path [' . $path . '] not found at body: ' . json_encode($responseArray));
334+
$body = json_encode($responseArray);
335+
Assert::assertIsString($body);
336+
Assert::assertArrayHasKey($key, $value, 'Key [' . $key . '] of path [' . $path . '] not found at body: ' . $body);
331337
$value = $value[$key];
332338
}
333339
if (isset($alias)) {
@@ -419,7 +425,9 @@ private function parseTextRcursive(array &$array): array {
419425
$value = $this->parseText($value);
420426
} elseif ($value instanceof \stdClass) {
421427
$value = (array) $value;
422-
$value = json_decode(json_encode($this->parseTextRcursive($value)));
428+
$buffer = json_encode($this->parseTextRcursive($value));
429+
Assert::assertIsString($buffer);
430+
$value = json_decode($buffer);
423431
}
424432
});
425433
return $array;
@@ -433,6 +441,7 @@ protected function parseText(string $text): string {
433441
$replacements[] = $value;
434442
}
435443
$text = preg_replace($patterns, $replacements, $text);
444+
Assert::assertIsString($text);
436445
return $text;
437446
}
438447

vendor-bin/psalm/composer.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
2-
"require": {
3-
"vimeo/psalm": "^5.12"
2+
"config": {
3+
"platform": {
4+
"php": "8.1.17"
5+
},
6+
"sort-packages": true
7+
},
8+
"require-dev": {
9+
"vimeo/psalm": "^6.5.0"
410
}
5-
}
11+
}

0 commit comments

Comments
 (0)