diff --git a/Response/JWTAuthenticationFailureResponse.php b/Response/JWTAuthenticationFailureResponse.php index febe725e..d7acf590 100644 --- a/Response/JWTAuthenticationFailureResponse.php +++ b/Response/JWTAuthenticationFailureResponse.php @@ -4,54 +4,6 @@ use Symfony\Component\HttpFoundation\JsonResponse; -if (80000 <= \PHP_VERSION_ID && (new \ReflectionMethod(JsonResponse::class, 'setData'))->hasReturnType()) { - eval(' - namespace Lexik\Bundle\JWTAuthenticationBundle\Response; - - use Symfony\Component\HttpFoundation\JsonResponse; - - /** - * Compatibility layer for Symfony 6.0 and later. - * - * @internal - */ - abstract class JWTCompatAuthenticationFailureResponse extends JsonResponse - { - /** - * Sets the response data with the statusCode & message included. - * - * {@inheritdoc} - * - * @return static - */ - public function setData($data = []): static - { - return parent::setData((array) $data + ["code" => $this->statusCode, "message" => $this->getMessage()]); - } - } - '); -} else { - /** - * Compatibility layer for Symfony 5.4 and earlier. - * - * @internal - */ - abstract class JWTCompatAuthenticationFailureResponse extends JsonResponse - { - /** - * Sets the response data with the statusCode & message included. - * - * {@inheritdoc} - * - * @return static - */ - public function setData($data = []) - { - return parent::setData((array) $data + ['code' => $this->statusCode, 'message' => $this->getMessage()]); - } - } -} - /** * JWTAuthenticationFailureResponse. * diff --git a/Response/JWTCompatAuthenticationFailureResponse.php b/Response/JWTCompatAuthenticationFailureResponse.php new file mode 100644 index 00000000..d57fa5ae --- /dev/null +++ b/Response/JWTCompatAuthenticationFailureResponse.php @@ -0,0 +1,58 @@ +hasReturnType()) { + eval(' + namespace Lexik\Bundle\JWTAuthenticationBundle\Response; + + use Symfony\Component\HttpFoundation\JsonResponse; + + /** + * Compatibility layer for Symfony 6.0 and later. + * + * @internal + */ + abstract class JWTCompatAuthenticationFailureResponse extends JsonResponse + { + /** + * Sets the response data with the statusCode & message included. + * + * {@inheritdoc} + * + * @return static + */ + public function setData($data = []): static + { + return parent::setData((array)$data + ["code" => $this->statusCode, "message" => $this->getMessage()]); + } + } + '); +} else { + /** + * Compatibility layer for Symfony 5.4 and earlier. + * + * @internal + */ + abstract class JWTCompatAuthenticationFailureResponse extends JsonResponse + { + /** + * Sets the response data with the statusCode & message included. + * + * {@inheritdoc} + * + * @return static + */ + public function setData($data = []) + { + return parent::setData((array)$data + ['code' => $this->statusCode, 'message' => $this->getMessage()]); + } + } +}