Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f4a9a5d

Browse files
committed
feature #48876 [HttpKernel] Rename HttpStatus atribute to WithHttpStatus (fabpot)
This PR was merged into the 6.3 branch. Discussion ---------- [HttpKernel] Rename HttpStatus atribute to WithHttpStatus | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes-ish | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Refs #48352 and #48747 As discussed in the 2 referenced PRs for better naming consistency. Commits ------- fece766 [HttpKernel] Rename HttpStatus atribute to WithHttpStatus
2 parents ed96673 + fece766 commit f4a9a5d

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/Symfony/Component/HttpKernel/Attribute/HttpStatus.php renamed to src/Symfony/Component/HttpKernel/Attribute/WithHttpStatus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @author Dejan Angelov <[email protected]>
1616
*/
1717
#[\Attribute(\Attribute::TARGET_CLASS)]
18-
class HttpStatus
18+
class WithHttpStatus
1919
{
2020
/**
2121
* @param array<string, string> $headers

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CHANGELOG
66

77
* Deprecate parameters `container.dumper.inline_factories` and `container.dumper.inline_class_loader`, use `.container.dumper.inline_factories` and `.container.dumper.inline_class_loader` instead
88
* `FileProfilerStorage` removes profiles automatically after two days
9-
* Add `#[HttpStatus]` for defining status codes for exceptions
9+
* Add `#[WithHttpStatus]` for defining status codes for exceptions
1010
* Use an instance of `Psr\Clock\ClockInterface` to generate the current date time in `DateTimeValueResolver`
1111
* Add `#[WithLogLevel]` for defining log levels for exceptions
1212

src/Symfony/Component/HttpKernel/EventListener/ErrorListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\ErrorHandler\Exception\FlattenException;
1717
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1818
use Symfony\Component\HttpFoundation\Request;
19-
use Symfony\Component\HttpKernel\Attribute\HttpStatus;
19+
use Symfony\Component\HttpKernel\Attribute\WithHttpStatus;
2020
use Symfony\Component\HttpKernel\Attribute\WithLogLevel;
2121
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
2222
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
@@ -71,10 +71,10 @@ public function logKernelException(ExceptionEvent $event)
7171
// There's no specific status code defined in the configuration for this exception
7272
if (!$throwable instanceof HttpExceptionInterface) {
7373
$class = new \ReflectionClass($throwable);
74-
$attributes = $class->getAttributes(HttpStatus::class, \ReflectionAttribute::IS_INSTANCEOF);
74+
$attributes = $class->getAttributes(WithHttpStatus::class, \ReflectionAttribute::IS_INSTANCEOF);
7575

7676
if ($attributes) {
77-
/** @var HttpStatus $instance */
77+
/** @var WithHttpStatus $instance */
7878
$instance = $attributes[0]->newInstance();
7979

8080
$throwable = new HttpException($instance->statusCode, $throwable->getMessage(), $throwable, $instance->headers);

src/Symfony/Component/HttpKernel/Tests/EventListener/ErrorListenerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\EventDispatcher\EventDispatcher;
1919
use Symfony\Component\HttpFoundation\Request;
2020
use Symfony\Component\HttpFoundation\Response;
21-
use Symfony\Component\HttpKernel\Attribute\HttpStatus;
21+
use Symfony\Component\HttpKernel\Attribute\WithHttpStatus;
2222
use Symfony\Component\HttpKernel\Attribute\WithLogLevel;
2323
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
2424
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
@@ -321,7 +321,7 @@ public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = tr
321321
}
322322

323323
#[\Attribute(\Attribute::TARGET_CLASS)]
324-
class UserProvidedHttpStatusCodeAttribute extends HttpStatus
324+
class UserProvidedHttpStatusCodeAttribute extends WithHttpStatus
325325
{
326326
public function __construct(array $headers = [])
327327
{
@@ -339,7 +339,7 @@ class WithCustomUserProvidedAttribute extends \Exception
339339
{
340340
}
341341

342-
#[HttpStatus(
342+
#[WithHttpStatus(
343343
statusCode: Response::HTTP_PRECONDITION_FAILED,
344344
headers: [
345345
'some' => 'thing',

0 commit comments

Comments
 (0)