Skip to content

Commit 20e766c

Browse files
authored
Merge pull request #18 from simPod/update
Modernize
2 parents edcd047 + f830be3 commit 20e766c

16 files changed

Lines changed: 89 additions & 135 deletions

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/tests export-ignore
2+
/.gitattributes export-ignore
3+
/.github export-ignore
4+
/.gitignore export-ignore
5+
/phpcs.xml.dist export-ignore
6+
/phpstan.neon.dist export-ignore
7+
/phpunit.xml.dist export-ignore

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
strategy:
66
matrix:
77
operating-system: ['ubuntu-latest']
8-
php-versions: ['7.4', '8.0', '8.1']
8+
php-versions: ['8.2', '8.3', '8.4', '8.5']
99
runs-on: ${{ matrix.operating-system }}
1010
steps:
1111
- name: Checkout
@@ -22,7 +22,7 @@ jobs:
2222
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
2323

2424
- name: Cache composer dependencies
25-
uses: actions/cache@v2
25+
uses: actions/cache@v3
2626
with:
2727
path: ${{ steps.composercache.outputs.dir }}
2828
# Use composer.json for key, if composer.lock is not committed.

CHANGELOG.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

composer.json

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414
}
1515
],
1616
"require": {
17-
"php" : ">=7.4",
18-
"psr/log": "^1.0 || ^2.0 || ^3.0",
17+
"php" : "^8.2",
18+
"psr/log": "^2.0 || ^3.0",
1919
"league/tactician": "dev-master"
2020
},
2121
"require-dev": {
22-
"phpunit/phpunit" : "^8.5",
23-
"squizlabs/php_codesniffer": "^3.5",
24-
"phpstan/phpstan": "^0.12.3",
25-
"phpstan/phpstan-phpunit": "^0.12.3",
26-
"phpstan/extension-installer": "^1.0",
27-
"doctrine/coding-standard": "^8.2"
22+
"phpunit/phpunit" : "^11.5",
23+
"phpstan/phpstan": "^2.1",
24+
"phpstan/phpstan-phpunit": "^2.0",
25+
"phpstan/extension-installer": "^1.4",
26+
"doctrine/coding-standard": "^14.0"
2827
},
2928
"autoload": {
3029
"psr-4": {
@@ -35,5 +34,11 @@
3534
"psr-4": {
3635
"League\\Tactician\\Logger\\Tests\\": "tests"
3736
}
37+
},
38+
"config": {
39+
"allow-plugins": {
40+
"dealerdirect/phpcodesniffer-composer-installer": true,
41+
"phpstan/extension-installer": true
42+
}
3843
}
3944
}

phpcs.xml renamed to phpcs.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<arg name="cache" value=".phpcs-cache"/>
77
<arg name="colors"/>
88

9+
<config name="php_version" value="80200" />
10+
911
<!-- Ignore warnings, show progress of the run and show sniff names -->
1012
<arg value="nps"/>
1113

phpstan.neon.dist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- %currentWorkingDirectory%/src
5+
- %currentWorkingDirectory%/tests
6+
7+
ignoreErrors:
8+
-
9+
identifier: property.onlyWritten
10+
path: tests/Fixtures/RegisterUserCommand.php

phpunit.xml.dist

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
verbose="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
bootstrap="vendor/autoload.php"
6+
colors="true"
7+
>
128
<testsuites>
139
<testsuite name="League Test Suite">
1410
<directory>tests</directory>
1511
</testsuite>
1612
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory suffix=".php">src/</directory>
20-
</whitelist>
21-
</filter>
22-
<logging>
23-
<log type="tap" target="build/report.tap"/>
24-
<log type="junit" target="build/report.junit.xml"/>
25-
<log type="coverage-html" target="build/coverage" />
26-
<log type="coverage-text" target="build/coverage.txt"/>
27-
<log type="coverage-clover" target="build/logs/clover.xml"/>
28-
</logging>
13+
<source>
14+
<include>
15+
<directory>src</directory>
16+
</include>
17+
</source>
2918
</phpunit>

src/Formatter/ClassNameFormatter.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,34 @@
88
use Psr\Log\LogLevel;
99
use Throwable;
1010

11-
use function get_class;
12-
1311
/**
1412
* Returns log messages only dump the Command & Exception's class names.
1513
*/
1614
class ClassNameFormatter implements Formatter
1715
{
18-
private string $commandReceivedLevel;
19-
20-
private string $commandSucceededLevel;
21-
22-
private string $commandFailedLevel;
23-
2416
public function __construct(
25-
string $commandReceivedLevel = LogLevel::DEBUG,
26-
string $commandSucceededLevel = LogLevel::DEBUG,
27-
string $commandFailedLevel = LogLevel::ERROR
17+
private string $commandReceivedLevel = LogLevel::DEBUG,
18+
private string $commandSucceededLevel = LogLevel::DEBUG,
19+
private string $commandFailedLevel = LogLevel::ERROR,
2820
) {
29-
$this->commandReceivedLevel = $commandReceivedLevel;
30-
$this->commandSucceededLevel = $commandSucceededLevel;
31-
$this->commandFailedLevel = $commandFailedLevel;
3221
}
3322

3423
public function logCommandReceived(LoggerInterface $logger, object $command): void
3524
{
36-
$logger->log($this->commandReceivedLevel, 'Command received: ' . get_class($command), []);
25+
$logger->log($this->commandReceivedLevel, 'Command received: ' . $command::class, []);
3726
}
3827

39-
/**
40-
* {@inheritDoc}
41-
*/
42-
public function logCommandSucceeded(LoggerInterface $logger, object $command, $returnValue): void
28+
public function logCommandSucceeded(LoggerInterface $logger, object $command, mixed $returnValue): void
4329
{
44-
$logger->log($this->commandSucceededLevel, 'Command succeeded: ' . get_class($command), []);
30+
$logger->log($this->commandSucceededLevel, 'Command succeeded: ' . $command::class, []);
4531
}
4632

4733
public function logCommandFailed(LoggerInterface $logger, object $command, Throwable $e): void
4834
{
4935
$logger->log(
5036
$this->commandFailedLevel,
51-
'Command failed: ' . get_class($command),
52-
['exception' => $e]
37+
'Command failed: ' . $command::class,
38+
['exception' => $e],
5339
);
5440
}
5541
}

src/Formatter/ClassPropertiesFormatter.php

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,62 +10,48 @@
1010
use Psr\Log\LogLevel;
1111
use Throwable;
1212

13-
use function get_class;
14-
1513
/**
1614
* Formatter that includes the Command's name and properties for more detail
1715
*/
1816
class ClassPropertiesFormatter implements Formatter
1917
{
2018
private PropertyNormalizer $normalizer;
2119

22-
private string $commandReceivedLevel;
23-
24-
private string $commandSucceededLevel;
25-
26-
private string $commandFailedLevel;
27-
2820
public function __construct(
29-
?PropertyNormalizer $normalizer = null,
30-
string $commandReceivedLevel = LogLevel::DEBUG,
31-
string $commandSucceededLevel = LogLevel::DEBUG,
32-
string $commandFailedLevel = LogLevel::ERROR
21+
PropertyNormalizer|null $normalizer = null,
22+
private string $commandReceivedLevel = LogLevel::DEBUG,
23+
private string $commandSucceededLevel = LogLevel::DEBUG,
24+
private string $commandFailedLevel = LogLevel::ERROR,
3325
) {
34-
$this->normalizer = $normalizer ?: new SimplePropertyNormalizer();
35-
$this->commandReceivedLevel = $commandReceivedLevel;
36-
$this->commandSucceededLevel = $commandSucceededLevel;
37-
$this->commandFailedLevel = $commandFailedLevel;
26+
$this->normalizer = $normalizer ?: new SimplePropertyNormalizer();
3827
}
3928

4029
public function logCommandReceived(LoggerInterface $logger, object $command): void
4130
{
4231
$logger->log(
4332
$this->commandReceivedLevel,
44-
'Command received: ' . get_class($command),
45-
['command' => $this->normalizer->normalize($command)]
33+
'Command received: ' . $command::class,
34+
['command' => $this->normalizer->normalize($command)],
4635
);
4736
}
4837

49-
/**
50-
* {@inheritDoc}
51-
*/
52-
public function logCommandSucceeded(LoggerInterface $logger, object $command, $returnValue): void
38+
public function logCommandSucceeded(LoggerInterface $logger, object $command, mixed $returnValue): void
5339
{
5440
$logger->log(
5541
$this->commandSucceededLevel,
56-
'Command succeeded: ' . get_class($command),
42+
'Command succeeded: ' . $command::class,
5743
[
5844
'command' => $this->normalizer->normalize($command),
59-
]
45+
],
6046
);
6147
}
6248

6349
public function logCommandFailed(LoggerInterface $logger, object $command, Throwable $e): void
6450
{
6551
$logger->log(
6652
$this->commandFailedLevel,
67-
'Command failed: ' . get_class($command),
68-
['exception' => $e]
53+
'Command failed: ' . $command::class,
54+
['exception' => $e],
6955
);
7056
}
7157
}

src/Formatter/Formatter.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ interface Formatter
2727
{
2828
public function logCommandReceived(LoggerInterface $logger, object $command): void;
2929

30-
/**
31-
* @param mixed $returnValue
32-
*/
33-
public function logCommandSucceeded(LoggerInterface $logger, object $command, $returnValue): void;
30+
public function logCommandSucceeded(LoggerInterface $logger, object $command, mixed $returnValue): void;
3431

3532
public function logCommandFailed(LoggerInterface $logger, object $command, Throwable $e): void;
3633
}

0 commit comments

Comments
 (0)