Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4630c6c

Browse filesBrowse files
committed
[MonologBridge] Remove deprecated code
1 parent d131937 commit 4630c6c
Copy full SHA for 4630c6c

File tree

6 files changed

+20
-102
lines changed
Filter options

6 files changed

+20
-102
lines changed

‎src/Symfony/Bridge/Monolog/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
6.0
5+
---
6+
7+
* The `$actionLevel` constructor argument of `Symfony\Bridge\Monolog\Handler\FingersCrossed\NotFoundActivationStrategy` has been replaced by the `$inner` one which expects an ActivationStrategyInterface to decorate instead.
8+
* The `$actionLevel` constructor argument of `Symfony\Bridge\Monolog\Handler\FingersCrossed\HttpCodeActivationStrategy` has been replaced by the `$inner` one which expects an ActivationStrategyInterface to decorate instead.
9+
410
5.3
511
---
612

‎src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Handler/FingersCrossed/HttpCodeActivationStrategy.php
+7-23Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bridge\Monolog\Handler\FingersCrossed;
1313

1414
use Monolog\Handler\FingersCrossed\ActivationStrategyInterface;
15-
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
1615
use Symfony\Component\HttpFoundation\RequestStack;
1716
use Symfony\Component\HttpKernel\Exception\HttpException;
1817

@@ -21,28 +20,17 @@
2120
*
2221
* @author Shaun Simmons <shaun@envysphere.com>
2322
* @author Pierrick Vignand <pierrick.vignand@gmail.com>
24-
*
25-
* @final
2623
*/
27-
class HttpCodeActivationStrategy extends ErrorLevelActivationStrategy implements ActivationStrategyInterface
24+
final class HttpCodeActivationStrategy implements ActivationStrategyInterface
2825
{
29-
private $inner;
30-
private $exclusions;
31-
private $requestStack;
32-
3326
/**
34-
* @param array $exclusions each exclusion must have a "code" and "urls" keys
35-
* @param ActivationStrategyInterface|int|string $inner an ActivationStrategyInterface to decorate
27+
* @param array $exclusions each exclusion must have a "code" and "urls" keys
3628
*/
37-
public function __construct(RequestStack $requestStack, array $exclusions, $inner)
38-
{
39-
if (!$inner instanceof ActivationStrategyInterface) {
40-
trigger_deprecation('symfony/monolog-bridge', '5.2', 'Passing an actionLevel (int|string) as constructor\'s 3rd argument of "%s" is deprecated, "%s" expected.', __CLASS__, ActivationStrategyInterface::class);
41-
42-
$actionLevel = $inner;
43-
$inner = new ErrorLevelActivationStrategy($actionLevel);
44-
}
45-
29+
public function __construct(
30+
private RequestStack $requestStack,
31+
private array $exclusions,
32+
private ActivationStrategyInterface $inner,
33+
) {
4634
foreach ($exclusions as $exclusion) {
4735
if (!\array_key_exists('code', $exclusion)) {
4836
throw new \LogicException('An exclusion must have a "code" key.');
@@ -51,10 +39,6 @@ public function __construct(RequestStack $requestStack, array $exclusions, $inne
5139
throw new \LogicException('An exclusion must have a "urls" key.');
5240
}
5341
}
54-
55-
$this->inner = $inner;
56-
$this->requestStack = $requestStack;
57-
$this->exclusions = $exclusions;
5842
}
5943

6044
public function isHandlerActivated(array $record): bool

‎src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Handler/FingersCrossed/NotFoundActivationStrategy.php
+6-20Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bridge\Monolog\Handler\FingersCrossed;
1313

1414
use Monolog\Handler\FingersCrossed\ActivationStrategyInterface;
15-
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
1615
use Symfony\Component\HttpFoundation\RequestStack;
1716
use Symfony\Component\HttpKernel\Exception\HttpException;
1817

@@ -22,29 +21,16 @@
2221
* @author Jordi Boggiano <j.boggiano@seld.be>
2322
* @author Fabien Potencier <fabien@symfony.com>
2423
* @author Pierrick Vignand <pierrick.vignand@gmail.com>
25-
*
26-
* @final
2724
*/
28-
class NotFoundActivationStrategy extends ErrorLevelActivationStrategy implements ActivationStrategyInterface
25+
final class NotFoundActivationStrategy implements ActivationStrategyInterface
2926
{
30-
private $inner;
3127
private $exclude;
32-
private $requestStack;
33-
34-
/**
35-
* @param ActivationStrategyInterface|int|string $inner an ActivationStrategyInterface to decorate
36-
*/
37-
public function __construct(RequestStack $requestStack, array $excludedUrls, $inner)
38-
{
39-
if (!$inner instanceof ActivationStrategyInterface) {
40-
trigger_deprecation('symfony/monolog-bridge', '5.2', 'Passing an actionLevel (int|string) as constructor\'s 3rd argument of "%s" is deprecated, "%s" expected.', __CLASS__, ActivationStrategyInterface::class);
41-
42-
$actionLevel = $inner;
43-
$inner = new ErrorLevelActivationStrategy($actionLevel);
44-
}
4528

46-
$this->inner = $inner;
47-
$this->requestStack = $requestStack;
29+
public function __construct(
30+
private RequestStack $requestStack,
31+
array $excludedUrls,
32+
private ActivationStrategyInterface $inner
33+
) {
4834
$this->exclude = '{('.implode('|', $excludedUrls).')}i';
4935
}
5036

‎src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/HttpCodeActivationStrategyTest.php
-42Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,48 +21,6 @@
2121

2222
class HttpCodeActivationStrategyTest extends TestCase
2323
{
24-
/**
25-
* @group legacy
26-
*/
27-
public function testExclusionsWithoutCodeLegacy()
28-
{
29-
$this->expectException(\LogicException::class);
30-
new HttpCodeActivationStrategy(new RequestStack(), [['urls' => []]], Logger::WARNING);
31-
}
32-
33-
/**
34-
* @group legacy
35-
*/
36-
public function testExclusionsWithoutUrlsLegacy()
37-
{
38-
$this->expectException(\LogicException::class);
39-
new HttpCodeActivationStrategy(new RequestStack(), [['code' => 404]], Logger::WARNING);
40-
}
41-
42-
/**
43-
* @dataProvider isActivatedProvider
44-
*
45-
* @group legacy
46-
*/
47-
public function testIsActivatedLegacy($url, $record, $expected)
48-
{
49-
$requestStack = new RequestStack();
50-
$requestStack->push(Request::create($url));
51-
52-
$strategy = new HttpCodeActivationStrategy(
53-
$requestStack,
54-
[
55-
['code' => 403, 'urls' => []],
56-
['code' => 404, 'urls' => []],
57-
['code' => 405, 'urls' => []],
58-
['code' => 400, 'urls' => ['^/400/a', '^/400/b']],
59-
],
60-
Logger::WARNING
61-
);
62-
63-
self::assertEquals($expected, $strategy->isHandlerActivated($record));
64-
}
65-
6624
public function testExclusionsWithoutCode()
6725
{
6826
$this->expectException(\LogicException::class);

‎src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/Tests/Handler/FingersCrossed/NotFoundActivationStrategyTest.php
-15Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@
2121

2222
class NotFoundActivationStrategyTest extends TestCase
2323
{
24-
/**
25-
* @dataProvider isActivatedProvider
26-
*
27-
* @group legacy
28-
*/
29-
public function testIsActivatedLegacy(string $url, array $record, bool $expected)
30-
{
31-
$requestStack = new RequestStack();
32-
$requestStack->push(Request::create($url));
33-
34-
$strategy = new NotFoundActivationStrategy($requestStack, ['^/foo', 'bar'], Logger::WARNING);
35-
36-
self::assertEquals($expected, $strategy->isHandlerActivated($record));
37-
}
38-
3924
/**
4025
* @dataProvider isActivatedProvider
4126
*/

‎src/Symfony/Bridge/Monolog/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Monolog/composer.json
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"php": ">=8.0.2",
2020
"monolog/monolog": "^1.25.1|^2",
2121
"symfony/service-contracts": "^1.1|^2",
22-
"symfony/http-kernel": "^5.4|^6.0",
23-
"symfony/deprecation-contracts": "^2.1"
22+
"symfony/http-kernel": "^5.4|^6.0"
2423
},
2524
"require-dev": {
2625
"symfony/console": "^5.4|^6.0",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.