From a5e66e52e6f087eb6f88f2cbb22ff346312ce503 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Mon, 17 Jan 2022 12:08:04 +0100 Subject: [PATCH] Avoid php8 only syntax when possible This resulted in phpstan to fail if the active PHP version is <8.0: Internal error: syntax error, unexpected 'static' (T_STATIC) In case a project depending on api-platform/core would use ClientTrait directly, or indirectly, phpstan would try to parse it and fail with the above syntax error. Move the type declarations into a comment instead. Fixes #4614 --- src/Util/ClientTrait80.php | 5 ++++- src/Util/ResponseTrait80.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Util/ClientTrait80.php b/src/Util/ClientTrait80.php index d0c372a47ea..40073bb54ab 100644 --- a/src/Util/ClientTrait80.php +++ b/src/Util/ClientTrait80.php @@ -15,7 +15,10 @@ trait ClientTrait80 { - public function withOptions(array $options): static + /** + * @return static + */ + public function withOptions(array $options) { $clone = clone $this; $clone->defaultOptions = self::mergeDefaultOptions($options, $this->defaultOptions); diff --git a/src/Util/ResponseTrait80.php b/src/Util/ResponseTrait80.php index a63a8819711..ef1b9357d29 100644 --- a/src/Util/ResponseTrait80.php +++ b/src/Util/ResponseTrait80.php @@ -15,7 +15,10 @@ trait ResponseTrait80 { - public function getInfo(?string $type = null): mixed + /** + * @return mixed + */ + public function getInfo(?string $type = null) { if ($type) { return $this->info[$type] ?? null;