Skip to content

Commit ff6db17

Browse files
derrabusjohnstevenson
authored andcommitted
Allow psr/log 2 and 3
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent e16b05c commit ff6db17

6 files changed

Lines changed: 37 additions & 4 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"require": {
2121
"php": "^5.3.2 || ^7.0 || ^8.0",
22-
"psr/log": "^1.0"
22+
"psr/log": "^1 || ^2 || ^3"
2323
},
2424
"require-dev": {
2525
"symfony/phpunit-bridge": "^4.2 || ^5",

phpstan.neon.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ parameters:
55
paths:
66
- src
77
- tests
8+
excludePaths:
9+
- tests/Helpers/LegacyLogger.php

tests/ClassTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Composer\XdebugHandler;
1313

14+
use Composer\XdebugHandler\Helpers\LegacyLogger;
1415
use Composer\XdebugHandler\Helpers\Logger;
1516
use PHPUnit\Framework\TestCase;
1617

@@ -48,7 +49,7 @@ public function setterProvider()
4849
{
4950
// $setter, $value
5051
return array(
51-
'setLogger' => array('setLogger', new Logger()),
52+
'setLogger' => array('setLogger', \PHP_VERSION_ID < 70100 ? new LegacyLogger() : new Logger()),
5253
'setMainScript' => array('setMainScript', '--'),
5354
'setPersistent' => array('setPersistent', null),
5455
);

tests/Helpers/LegacyLogger.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of composer/xdebug-handler.
5+
*
6+
* (c) Composer <https://github.com/composer>
7+
*
8+
* For the full copyright and license information, please view
9+
* the LICENSE file that was distributed with this source code.
10+
*/
11+
12+
namespace Composer\XdebugHandler\Helpers;
13+
14+
use Psr\Log\AbstractLogger;
15+
16+
class LegacyLogger extends AbstractLogger
17+
{
18+
protected $output = array();
19+
20+
public function log($level, $message, array $context = array())
21+
{
22+
$this->output[] = array($level, $message, $context);
23+
}
24+
25+
public function getOutput()
26+
{
27+
return $this->output;
28+
}
29+
}

tests/Helpers/Logger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Logger extends AbstractLogger
1717
{
1818
protected $output = array();
1919

20-
public function log($level, $message, array $context = array())
20+
public function log($level, $message, array $context = array()): void
2121
{
2222
$this->output[] = array($level, $message, $context);
2323
}

tests/StatusTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Composer\XdebugHandler;
1313

1414
use Composer\XdebugHandler\Helpers\BaseTestCase;
15+
use Composer\XdebugHandler\Helpers\LegacyLogger;
1516
use Composer\XdebugHandler\Helpers\Logger;
1617
use Composer\XdebugHandler\Mocks\CoreMock;
1718
use Psr\Log\LogLevel;
@@ -27,7 +28,7 @@ public function testSetLoggerProvidesOutput()
2728
{
2829
$loaded = true;
2930

30-
$logger = new Logger();
31+
$logger = \PHP_VERSION_ID < 70100 ? new LegacyLogger() : new Logger();
3132
$settings = array('setLogger' => array($logger));
3233

3334
$xdebug = CoreMock::createAndCheck($loaded, null, $settings);

0 commit comments

Comments
 (0)