forked from lexik/LexikJWTAuthenticationBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lexik#944): separate CompatFailureResponse from FailureResponse
- Loading branch information
1 parent
5ef8b77
commit 1aa30e2
Showing
2 changed files
with
53 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()]); | ||
} | ||
} | ||
} |