Skip to content

Commit 282d40c

Browse files
Roman3349f3l1x
authored andcommitted
Modernize code base and fix issues reported by linters
Signed-off-by: Roman Ondráček <[email protected]>
1 parent 20046c9 commit 282d40c

File tree

97 files changed

+365
-468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+365
-468
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,9 @@ jobs:
3535
with:
3636
php: "8.2"
3737

38-
test81:
39-
name: "Nette Tester"
40-
uses: contributte/.github/.github/workflows/nette-tester.yml@master
41-
with:
42-
php: "8.1"
43-
4438
testlower:
4539
name: "Nette Tester"
4640
uses: contributte/.github/.github/workflows/nette-tester.yml@master
4741
with:
48-
php: "8.1"
42+
php: "8.2"
4943
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
],
2121
"require": {
22-
"php": ">=8.1",
22+
"php": ">=8.2",
2323
"ext-json": "*",
2424
"nette/di": "^3.1.8",
2525
"contributte/psr7-http-message": "^0.9.0 || ^0.10.0",
@@ -33,16 +33,16 @@
3333
"contributte/qa": "^0.4",
3434
"contributte/dev": "^0.4",
3535
"contributte/tester": "^0.3",
36-
"contributte/phpstan": "^0.1",
36+
"contributte/phpstan": "^0.2",
3737
"mockery/mockery": "^1.6.6",
3838
"nette/application": "^3.1.4",
3939
"nette/di": "^3.1.8",
4040
"nette/http": "^3.2.3",
4141
"psr/log": "^2.0.0 || ^3.0.0",
42-
"symfony/console": "^6.4.0 || ^7.0.0",
43-
"symfony/translation": "^6.4.0 | ^7.0.0",
44-
"symfony/validator": "^6.4.0 || ^7.0.0",
45-
"symfony/yaml": "^6.4.0 || ^7.0.0",
42+
"symfony/console": "^6.4.0 || ^7.0.0 || ^8.0.0",
43+
"symfony/translation": "^6.4.0 | ^7.0.0 || ^8.0.0",
44+
"symfony/validator": "^6.4.0 || ^7.0.0 || ^8.0.0",
45+
"symfony/yaml": "^6.4.0 || ^7.0.0 || ^8.0.0",
4646
"tracy/tracy": "^2.10.5"
4747
},
4848
"provide": {

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ parameters:
5050
# Support for doctrine/annotations ^1
5151
- message: "#^Call to function method_exists\\(\\) with 'Doctrine\\\\\\\\Common\\\\\\\\Annotations\\\\\\\\AnnotationRegistry' and 'registerUniqueLoader' will always evaluate to false\\.$#"
5252
path: src/Core/DI/LoaderFactory/DualReaderFactory.php
53+
54+
- message: "#^Dead catch - TypeError is never thrown in the try block.$#"
55+
path: src/Core/Mapping/Parameter/DateTimeTypeMapper.php
56+
count: 1

ruleset.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<description>Contributte</description>
44

55
<!-- Extending rulesets -->
6-
<rule ref="./vendor/contributte/qa/ruleset-8.0.xml"/>
6+
<rule ref="./vendor/contributte/qa/ruleset-8.2.xml"/>
77

88
<!-- Specific rules -->
99
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
@@ -26,7 +26,7 @@
2626
</rule>
2727

2828
<rule ref="SlevomatCodingStandard.PHP.DisallowReference">
29-
<exclude-pattern>src/Core/Schema/Serialization/ArraySerializator.php</exclude-pattern>
29+
<exclude-pattern>src/Core/Schema/Serialization/ArraySerializer.php</exclude-pattern>
3030
<exclude-pattern>tests/Cases/OpenApi/Schema/ExamplesTest.php</exclude-pattern>
3131
</rule>
3232

src/Console/Command/RouteDumpCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ class RouteDumpCommand extends Command
2121

2222
private const TABLE_HEADER = ['Method', 'Path', 'Handler', ' ', 'Parameters'];
2323

24-
private Schema $schema;
25-
26-
public function __construct(Schema $schema)
24+
public function __construct(
25+
private readonly Schema $schema,
26+
)
2727
{
2828
parent::__construct();
29-
30-
$this->schema = $schema;
3129
}
3230

3331
protected function configure(): void
@@ -59,6 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5957

6058
/** @var Endpoint[][] $endpointsByHandler */
6159
$endpointsByHandler = [];
60+
6261
foreach ($endpoints as $endpoint) {
6362
$endpointsByHandler[$endpoint->getHandler()->getClass()][] = $endpoint;
6463
}
@@ -115,6 +114,7 @@ private function formatParameters(array $parameters): string
115114

116115
foreach ($paramsByIn as $in => $params) {
117116
$result .= sprintf('<fg=cyan>%s</>', $in) . ': ' . implode(', ', $params);
117+
118118
if ($params !== end($paramsByIn)) {
119119
$result .= ' | ';
120120
}

src/Core/Annotation/Controller/Id.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
class Id
1717
{
1818

19-
private string $name;
20-
21-
public function __construct(string $name)
19+
public function __construct(
20+
private readonly string $name,
21+
)
2222
{
2323
if ($name === '') {
2424
throw new AnnotationException('Empty @Id given');
2525
}
26-
27-
$this->name = $name;
2826
}
2927

3028
public function getName(): string

src/Core/Annotation/Controller/Method.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Method
1717
{
1818

1919
/** @var string[] */
20-
private array $methods = [];
20+
private readonly array $methods;
2121

2222
/**
2323
* @param string[]|string $methods
@@ -29,7 +29,7 @@ public function __construct(array|string $methods)
2929
}
3030

3131
// Wrap single given method into array
32-
if (! is_array($methods)) {
32+
if (!is_array($methods)) {
3333
$methods = [$methods];
3434
}
3535

src/Core/Annotation/Controller/Negotiation.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,12 @@
1515
class Negotiation
1616
{
1717

18-
private string $suffix;
19-
20-
private bool $default;
21-
22-
private ?string $renderer;
23-
24-
public function __construct(string $suffix, bool $default = false, ?string $renderer = null)
18+
public function __construct(
19+
private readonly string $suffix,
20+
private readonly bool $default = false,
21+
private readonly ?string $renderer = null,
22+
)
2523
{
26-
$this->suffix = $suffix;
27-
$this->default = $default;
28-
$this->renderer = $renderer;
2924
}
3025

3126
public function getSuffix(): string

src/Core/Annotation/Controller/Negotiations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Negotiations
1515
{
1616

1717
/** @var Negotiation[] */
18-
private array $negotiations = [];
18+
private readonly array $negotiations;
1919

2020
/**
2121
* @param Negotiation[]|Negotiation $negotiations

src/Core/Annotation/Controller/OpenApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class OpenApi
1616
{
1717

18-
private string $data;
18+
private readonly string $data;
1919

2020
public function __construct(string $data)
2121
{

0 commit comments

Comments
 (0)