Skip to content

Commit

Permalink
fix(lexik#944): separate CompatFailureResponse from FailureResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
GErpeldinger committed May 3, 2022
1 parent 5ef8b77 commit c943538
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 48 deletions.
48 changes: 0 additions & 48 deletions Response/JWTAuthenticationFailureResponse.php
Expand Up @@ -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.
*
Expand Down
53 changes: 53 additions & 0 deletions Response/JWTCompatAuthenticationFailureResponse.php
@@ -0,0 +1,53 @@
<?php

namespace Lexik\Bundle\JWTAuthenticationBundle\Response;

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()]);
}
}
}

0 comments on commit c943538

Please sign in to comment.