8000 [HttpKernel] Rename the attribute class to WithLogLevel · symfony/symfony@33c3a7c · GitHub
[go: up one dir, main page]

Skip to content

Commit 33c3a7c

Browse files
committed
[HttpKernel] Rename the attribute class to WithLogLevel
1 parent 2c2453c commit 33c3a7c

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

src/Symfony/Component/HttpKernel/Attribute/LogLevel.php renamed to src/Symfony/Component/HttpKernel/Attribute/WithLogLevel.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111

1212
namespace Symfony\Component\HttpKernel\Attribute;
1313

14+
use Psr\Log\LogLevel;
15+
1416
/**
1517
* @author Dejan Angelov <angelovdejan@protonmail.com>
1618
*/
1719
#[\Attribute(\Attribute::TARGET_CLASS)]
18-
final class LogLevel
20+
final class WithLogLevel
1921
{
2022
/**
21-
* @param \Psr\Log\LogLevel::* $level
23+
* @param LogLevel::* $level
2224
*/
2325
public function __construct(public readonly string $level)
2426
{

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CHANGELOG
88
* `FileProfilerStorage` removes profiles automatically after two days
99
* Add `#[HttpStatus]` for defining status codes for exceptions
1010
* Use an instance of `Psr\Clock\ClockInterface` to generate the current date time in `DateTimeValueResolver`
11-
* Add `#[LogLevel]` for defining log levels for exceptions
11+
* Add `#[WithLogLevel]` for defining log levels for exceptions
1212

1313
6.2
1414
---

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1818
use Symfony\Component\HttpFoundation\Request;
1919
use Symfony\Component\HttpKernel\Attribute\HttpStatus;
20-
use Symfony\Component\HttpKernel\Attribute\LogLevel;
20+
use Symfony\Component\HttpKernel\Attribute\WithLogLevel;
2121
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
2222
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
2323
use Symfony\Component\HttpKernel\Event\ResponseEvent;
@@ -185,10 +185,10 @@ private function resolveLogLevel(\Throwable $throwable): string
185185
}
186186
}
187187

188-
$attributes = (new \ReflectionClass($throwable))->getAttributes(LogLevel::class);
188+
$attributes = (new \ReflectionClass($throwable))->getAttributes(WithLogLevel::class);
189189

190190
if ($attributes) {
191-
/** @var LogLevel $instance */
191+
/** @var WithLogLevel $instance */
192192
$instance = $attributes[0]->newInstance();
193193

194194
return $instance->level;

src/Symfony/Component/HttpKernel/Tests/Attribute/LogLevelTest.php renamed to src/Symfony/Component/HttpKernel/Tests/Attribute/WithLogLevelTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
namespace Symfony\Component\HttpKernel\Tests\Attribute;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Psr\Log\LogLevel as PsrLogLevel;
16-
use Symfony\Component\HttpKernel\Attribute\LogLevel;
15+
use Psr\Log\LogLevel;
16+
use Symfony\Component\HttpKernel\Attribute\WithLogLevel;
1717

1818
/**
1919
* @author Dejan Angelov <angelovdejan@protonmail.com>
2020
*/
21-
class LogLevelTest extends TestCase
21+
class WithLogLevelTest extends TestCase
2222
{
2323
public function testWithValidLogLevel()
2424
{
25-
$logLevel = PsrLogLevel::NOTICE;
25+
$logLevel = LogLevel::NOTICE;
2626

27-
$attribute = new LogLevel($logLevel);
27+
$attribute = new WithLogLevel($logLevel);
2828

2929
$this->assertSame($logLevel, $attribute->level);
3030
}
@@ -34,6 +34,6 @@ public function testWithInvalidLogLevel()
3434
$this->expectException(\InvalidArgumentException::class);
3535
$this->expectExceptionMessage('Invalid log level "invalid".');
3636

37-
new LogLevel('invalid');
37+
new WithLogLevel('invalid');
3838
}
3939
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Log\LoggerInterface;
16+
use Psr\Log\LogLevel;
1617
use Symfony\Component\ErrorHandler\Exception\FlattenException;
1718
use Symfony\Component\EventDispatcher\EventDispatcher;
1819
use Symfony\Component\HttpFoundation\Request;
1920
use Symfony\Component\HttpFoundation\Response;
2021
use Symfony\Component\HttpKernel\Attribute\HttpStatus;
21-
use Symfony\Component\HttpKernel\Attribute\LogLevel;
22+
use Symfony\Component\HttpKernel\Attribute\WithLogLevel;
2223
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
2324
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
2425
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
@@ -348,7 +349,7 @@ class WithGeneralAttribute extends \Exception
348349
{
349350
}
350351

351-
#[LogLevel(\Psr\Log\LogLevel::WARNING)]
352+
#[WithLogLevel(LogLevel::WARNING)]
352353
class WarningWithLogLevelAttribute extends \Exception
353354
{
354355
}

0 commit comments

Comments
 (0)
0