@@ -92,7 +92,6 @@ public function decode(string $serializedMessage): object
9292 {
9393 try
9494 {
95- /** @psalm-var array{message:array<string, string|int|float|null>, namespace:class-string} $data */
9695 $ data = $ this ->serializer ->unserialize ($ serializedMessage );
9796
9897 self ::validateUnserializedData ($ data );
@@ -162,7 +161,7 @@ public function normalize(object $message): array
162161 }
163162
164163 /**
165- * @psalm-param array{message:array<string, string|int|float|null >, namespace:class-string} $data
164+ * @psalm-assert array{message:array<string, mixed >, namespace:class-string} $data
166165 *
167166 * @throws \UnexpectedValueException
168167 */
@@ -178,12 +177,22 @@ private static function validateUnserializedData(array $data): void
178177 );
179178 }
180179
180+ if (false === \is_array ($ data ['message ' ]))
181+ {
182+ throw new \UnexpectedValueException ('"message" field from serialized data should be an array ' );
183+ }
184+
185+ if (false === \is_string ($ data ['namespace ' ]))
186+ {
187+ throw new \UnexpectedValueException ('"namespace" field from serialized data should be a string ' );
188+ }
189+
181190 /**
182191 * Let's check if the specified class exists.
183192 *
184193 * @psalm-suppress DocblockTypeContradiction
185194 */
186- if ($ data ['namespace ' ] === '' || \class_exists (( string ) $ data ['namespace ' ]) === false )
195+ if ($ data ['namespace ' ] === '' || \class_exists ($ data ['namespace ' ]) === false )
187196 {
188197 throw new \UnexpectedValueException (
189198 \sprintf ('Class "%s" not found ' , $ data ['namespace ' ])
0 commit comments