Skip to content

Commit ec9435e

Browse files
committed
psalm formatter
1 parent d0278a6 commit ec9435e

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

src/Contracts/FormatterInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
* constraints-removed?: int,
5959
* contains-updates?: bool,
6060
* contains-system-updates?: bool,
61-
* system-updates?: int
61+
* system-updates?: int,
62+
* db?: string
6263
* }
6364
* @psalm-type CypherError = array{code: string, message: string}
6465
* @psalm-type CypherRowResponse = array{row: list<scalar|null|array<array-key,scalar|null|array>>}

src/Formatter/BasicFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static function create(): self
5858
}
5959

6060
/**
61-
* @param array{fields: array<int, string>} $meta
61+
* @param array{fields: array<int, string>, qid?: int, t_first: int} $meta
6262
*
6363
* @return CypherList<CypherMap<array|scalar|null>>
6464
*/
@@ -127,7 +127,7 @@ private function buildResult(stdClass $result): CypherList
127127
}
128128

129129
/**
130-
* @param array{fields: array<int, string>} $meta
130+
* @param array{fields: array<int, string>, qid?: int, t_first: int} $meta
131131
*
132132
* @return CypherMap<scalar|array|null>
133133
*/

src/Formatter/Specialised/BoltOGMTranslator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
* @psalm-import-type OGMTypes from OGMFormatter
5555
*
5656
* @psalm-immutable
57+
* @psalm-pure
5758
*/
5859
final class BoltOGMTranslator
5960
{
@@ -64,6 +65,7 @@ final class BoltOGMTranslator
6465

6566
public function __construct()
6667
{
68+
/** @psalm-suppress InvalidPropertyAssignmentValue */
6769
$this->rawToTypes = [
6870
BoltNode::class => $this->makeFromBoltNode(...),
6971
BoltDate::class => $this->makeFromBoltDate(...),

src/Formatter/Specialised/JoltHttpOGMTranslator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
* @psalm-immutable
6565
*
6666
* @psalm-import-type OGMTypes from OGMFormatter
67+
*
68+
* @psalm-suppress PossiblyUndefinedArrayOffset
6769
*/
6870
final class JoltHttpOGMTranslator
6971
{

src/Formatter/Specialised/LegacyHttpOGMTranslator.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,18 @@ public function translateCypherMap(array $row, HttpMetaInfo $meta): array
154154
}
155155

156156
/**
157-
* @param stdClass|array|scalar|null $value
157+
* @param array|scalar|stdClass|null $value
158158
*
159159
* @return array{0: OGMTypes, 1: HttpMetaInfo}
160160
*
161161
* @psalm-suppress MixedArgumentTypeCoercion
162162
* @psalm-suppress MixedArgument
163163
* @psalm-suppress MixedAssignment
164+
* @psalm-suppress InvalidReturnStatement
165+
* @psalm-suppress ArgumentTypeCoercion
166+
* @psalm-suppress InvalidReturnType
164167
*/
165-
private function translateValue($value, HttpMetaInfo $meta): array
168+
private function translateValue(float|array|bool|int|string|stdClass|null $value, HttpMetaInfo $meta): array
166169
{
167170
if (is_object($value)) {
168171
return $this->translateObject($value, $meta);
@@ -416,6 +419,7 @@ private function translateDuration(string $value): Duration
416419
{
417420
/** @psalm-suppress ImpureFunctionCall false positive in version php 7.4 */
418421
if (str_contains($value, '.')) {
422+
/** @psalm-suppress PossiblyUndefinedIntArrayOffset */
419423
[$format, $secondsFraction] = explode('.', $value);
420424
$nanoseconds = (int) substr($secondsFraction, 6);
421425
$microseconds = (int) str_pad((string) ((int) substr($secondsFraction, 0, 6)), 6, '0');
@@ -464,14 +468,19 @@ private function translateTime(string $value): Time
464468
*/
465469
private function translateDateTime(string $value): DateTime
466470
{
471+
/** @psalm-suppress PossiblyUndefinedIntArrayOffset */
467472
[$date, $time] = explode('T', $value);
468473
$tz = null;
469-
/** @psalm-suppress ImpureFunctionCall false positive in version php 7.4 */
470474
if (str_contains($time, '+')) {
475+
/** @psalm-suppress PossiblyUndefinedIntArrayOffset */
471476
[$time, $timezone] = explode('+', $time);
477+
478+
/** @psalm-suppress PossiblyUndefinedIntArrayOffset */
472479
[$tzHours, $tzMinutes] = explode(':', $timezone);
473480
$tz = (int) $tzHours * 60 * 60 + (int) $tzMinutes * 60;
474481
}
482+
483+
/** @psalm-suppress PossiblyUndefinedIntArrayOffset */
475484
[$time, $milliseconds] = explode('.', $time);
476485

477486
$dateTime = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date.' '.$time);
@@ -488,7 +497,9 @@ private function translateDateTime(string $value): DateTime
488497

489498
private function translateLocalDateTime(string $value): LocalDateTime
490499
{
500+
/** @psalm-suppress PossiblyUndefinedIntArrayOffset */
491501
[$date, $time] = explode('T', $value);
502+
/** @psalm-suppress PossiblyUndefinedIntArrayOffset */
492503
[$time, $milliseconds] = explode('.', $time);
493504

494505
$dateTime = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date.' '.$time);

src/Formatter/SummarizedResultFormatter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function formatHttpStats(stdClass $response, HttpConnection $connection,
129129
}
130130

131131
/**
132-
* @param array{stats?: BoltCypherStats} $response
132+
* @param array{stats?: BoltCypherStats}&array $response
133133
*
134134
* @psalm-mutation-free
135135
*/
@@ -173,7 +173,6 @@ public function formatBoltResult(array $meta, BoltResult $result, BoltConnection
173173
/** @var BoltCypherStats $response */
174174
$stats = $this->formatBoltStats($response);
175175
$resultConsumedAfter = microtime(true) - $runStart;
176-
/** @var string */
177176
$db = $response['db'] ?? '';
178177
$summary = new ResultSummary(
179178
$stats,

0 commit comments

Comments
 (0)