From 5edb910fdcff6a2d289ca258d8e4342d78385fb3 Mon Sep 17 00:00:00 2001 From: m1ke Date: Wed, 28 Feb 2024 10:38:32 +0000 Subject: [PATCH] Add psalm to require dev and initial run --- composer.json | 3 ++- psalm.xml | 23 +++++++++++++++++++++++ src/Extensions/ExceptionReporter.php | 2 +- src/Model/Breadcrumb.php | 6 +++++- src/Model/Request.php | 4 ++-- 5 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 psalm.xml diff --git a/composer.json b/composer.json index e3a43d2..3322a63 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "require-dev": { "nyholm/psr7": "^1.0", "codeception/codeception": "^5.0", - "codeception/module-asserts": "*" + "codeception/module-asserts": "*", + "vimeo/psalm": "^5" }, "autoload": { "psr-4": { diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..355e018 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/src/Extensions/ExceptionReporter.php b/src/Extensions/ExceptionReporter.php index bc4a291..82dddcf 100644 --- a/src/Extensions/ExceptionReporter.php +++ b/src/Extensions/ExceptionReporter.php @@ -350,7 +350,7 @@ protected function getParameterNames(ReflectionFunctionAbstract $reflection): ar * * @param mixed[] $values raw PHP values * - * @return string[] formatted values + * @return list formatted values */ protected function formatValues(array $values): array { diff --git a/src/Model/Breadcrumb.php b/src/Model/Breadcrumb.php index e04938b..c5bf0c6 100644 --- a/src/Model/Breadcrumb.php +++ b/src/Model/Breadcrumb.php @@ -44,6 +44,10 @@ public function __construct(int $timestamp, string $level, string $message, arra */ public function jsonSerialize(): array { - return array_filter(get_object_vars($this)); + // Avoids a psalm error for unused property on "data" + $out = array_merge(get_object_vars($this), [ + 'data' => $this->data, + ]); + return array_filter($out); } } diff --git a/src/Model/Request.php b/src/Model/Request.php index 4ae7181..679f7b8 100644 --- a/src/Model/Request.php +++ b/src/Model/Request.php @@ -25,9 +25,9 @@ class Request implements JsonSerializable public $query_string; /** - * @var string|null cookie values (unparsed, as a string) + * @var array cookie values (unparsed, as a string) */ - public $cookies; + public $cookies = []; /** * @var string[] map where header-name => header-value