Skip to content

Commit 194de71

Browse files
Shoormaxvderudetshavounet
authored
Feat/support php8 (#68)
* feat: php8 support * feat: GHA ? * feat: removing composer.lock * feat: removing composer.lock * feat: type-hints in every files o/ * feat: self-review * feat: self review still * feat: fixing a dumb error :) * feat: fixing another error * feat: review * feat: review * feat: review * feat: constructor property promotion * feat: type hint ! * feat(quality): added PHPStan and rector * feat(quality): apply rector rules * feat(quality): fix phpstan warnings * feat(quality): removed useless constructor * feat(quality): updated ignore list * feat(quality): updated types and misc phpstan adjustments * feat(quality): apply rector & php-cs-fixer * feat(quality): simplify some code after adding better types * feat: merged vclavreul PR Co-authored-by: vderudet <vderudet.externe@bedrockstreaming.com> Co-authored-by: Valentin Clavreul <valentin.clavreul@bedrockstreaming.com>
1 parent b6e03f8 commit 194de71

63 files changed

Lines changed: 705 additions & 2284 deletions

Some content is hidden

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

.coke

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

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- uses: actions/checkout@master
1010
- uses: shivammathur/setup-php@v2
1111
with:
12-
php-version: 7.4
12+
php-version: 8.0
1313
- run: composer install --prefer-dist --no-interaction
1414
- run: bin/php-cs-fixer fix --dry-run --stop-on-violation --diff --ansi
1515

@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-18.04
1919
strategy:
2020
matrix:
21-
version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
21+
version: ['8.0', '8.1']
2222
flags: ['', '--prefer-lowest']
2323
fail-fast: false
2424
steps:

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
bin/
22
vendor/
3-
src/M6Web/Bundle/LogBridgeBundle/Tests/Resources/cache/*
4-
composer.lock
3+
src/M6Web/Bundle/LogBridgeBundle/Tests/Fixtures/Resources/cache/*
54
.php_cs.cache
5+
.php-cs-fixer.cache
6+
composer.lock

.php-cs-fixer.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
<?php
22

3-
$config = new class() extends \PhpCsFixer\Config {
4-
public function __construct()
5-
{
6-
parent::__construct('Bedrock(PHP 7.1)');
7-
}
8-
9-
public function getRules()
10-
{
11-
return (new \M6Web\CS\Config\Php71())->getRules() + ['increment_style' => false];
12-
}
13-
};
14-
15-
$config->getFinder()
16-
->in([
17-
__DIR__.'/src'
18-
])->exclude([
19-
'Tests'
20-
]);
21-
22-
return $config;
3+
return (new \M6Web\CS\Config\BedrockStreaming())
4+
->setFinder(
5+
PhpCsFixer\Finder::create()
6+
->in([
7+
__DIR__.'/src'
8+
])
9+
->exclude([
10+
'Tests'
11+
])
12+
);

composer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@
88
"minimum-stability" : "dev",
99
"prefer-stable": true,
1010
"require": {
11-
"php": ">=7.1.3",
11+
"php": ">=8.0",
1212
"symfony/config": "^4.4|^5.0|^6.0",
1313
"symfony/yaml": "^4.4|^5.0|^6.0",
1414
"symfony/routing": "^4.4|^5.0|^6.0",
1515
"symfony/expression-language": "^4.4|^5.0|^6.0",
16-
"symfony/security-core": "^4.4|^5.0|^6.0"
16+
"symfony/security-core": "^4.4|^5.0|^6.0",
17+
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
18+
"symfony/http-kernel": "^4.4|^5.0|^6.0"
1719
},
1820
"require-dev": {
1921
"atoum/atoum": "^3.4|^4.0",
20-
"friendsofphp/php-cs-fixer": "^2.19",
21-
"m6web/symfony2-coding-standard": "~1.2",
22-
"m6web/php-cs-fixer-config": "^1.0",
23-
"symfony/http-foundation": "^4.4|^5.0|^6.0"
22+
"m6web/php-cs-fixer-config": "^2.1",
23+
"symfony/http-foundation": "^4.4|^5.0|^6.0",
24+
"phpstan/phpstan": "^1.7",
25+
"rector/rector": "^0.13.2"
2426
},
2527
"extra": {
2628
"branch-alias": {

phpstan.neon

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
parameters:
2+
level: max
3+
paths:
4+
- src
5+
excludePaths:
6+
# This class is deprecated, we don't care about warnings
7+
- src/M6Web/Bundle/LogBridgeBundle/EventDispatcher/BuilderEvent.php
8+
- src/M6Web/Bundle/LogBridgeBundle/Tests/*
9+
10+
# Errors from DependencyInjection : hard to fix, not that useful
11+
ignoreErrors:
12+
-
13+
message: "#^Parameter \\#1 \\$id of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:findDefinition\\(\\) expects string, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
14+
count: 1
15+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php
16+
17+
-
18+
message: "#^Parameter \\#1 \\$object_or_class of function class_implements expects object\\|string, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
19+
count: 1
20+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php
21+
22+
-
23+
message: "#^Parameter \\#1 \\$string of function substr expects string, string\\|null given\\.$#"
24+
count: 1
25+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php
26+
27+
-
28+
message: "#^Parameter \\#2 \\$haystack of function in_array expects array, array\\<string, string\\>\\|false given\\.$#"
29+
count: 1
30+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php
31+
32+
-
33+
message: "#^Parameter \\#2 \\$subject of function preg_match expects string, string\\|null given\\.$#"
34+
count: 1
35+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php
36+
37+
-
38+
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
39+
count: 1
40+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php
41+
42+
-
43+
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
44+
count: 1
45+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/Configuration.php
46+
47+
-
48+
message: "#^Method M6Web\\\\Bundle\\\\LogBridgeBundle\\\\DependencyInjection\\\\M6WebLogBridgeExtension\\:\\:load\\(\\) has parameter \\$configs with no value type specified in iterable type array\\.$#"
49+
count: 1
50+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/M6WebLogBridgeExtension.php
51+
52+
-
53+
message: "#^Parameter \\#1 \\$class of class Symfony\\\\Component\\\\DependencyInjection\\\\Definition constructor expects string\\|null, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
54+
count: 2
55+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/M6WebLogBridgeExtension.php
56+
57+
-
58+
message: "#^Parameter \\#1 \\$id of class Symfony\\\\Component\\\\DependencyInjection\\\\Reference constructor expects string, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
59+
count: 3
60+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/M6WebLogBridgeExtension.php
61+
62+
-
63+
message: "#^Parameter \\#1 \\$id of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:setDefinition\\(\\) expects string, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
64+
count: 2
65+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/M6WebLogBridgeExtension.php
66+
67+
-
68+
message: "#^Parameter \\#1 \\.\\.\\.\\$arrays of function array_merge expects array, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
69+
count: 1
70+
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/M6WebLogBridgeExtension.php

rector.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Set\ValueObject\LevelSetList;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__ . '/src'
12+
]);
13+
14+
// register a single rule
15+
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
16+
17+
// define sets of rules
18+
$rectorConfig->sets([
19+
LevelSetList::UP_TO_PHP_80
20+
]);
21+
};

src/M6Web/Bundle/LogBridgeBundle/Config/Configuration.php

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,45 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace M6Web\Bundle\LogBridgeBundle\Config;
46

57
/**
68
* Class Configuration
79
*/
810
class Configuration
911
{
10-
/** @var FilterCollection */
11-
private $filters;
12-
13-
/** @var array */
14-
private $activeFilters;
12+
private ?FilterCollection $filters = null;
1513

16-
/**
17-
* Constructor
18-
*/
19-
public function __construct()
20-
{
21-
$this->filters = null;
22-
$this->activeFilters = null;
23-
}
14+
/** @var string[] */
15+
private ?array $activeFilters = null;
2416

2517
/**
26-
* setActiveFilters
27-
*
28-
* @return Configuration
18+
* @param string[] $activeFilters
2919
*/
30-
public function setActiveFilters(array $activeFilters)
20+
public function setActiveFilters(array $activeFilters): self
3121
{
3222
$this->activeFilters = $activeFilters;
3323

3424
return $this;
3525
}
3626

3727
/**
38-
* getActiveFilters
39-
*
40-
* @return array
28+
* @return string[]|null
4129
*/
42-
public function getActiveFilters()
30+
public function getActiveFilters(): ?array
4331
{
4432
return $this->activeFilters;
4533
}
4634

47-
/**
48-
* setFilters
49-
*
50-
* @param FilterCollection $filters Filters
51-
*
52-
* @return Configuration
53-
*/
54-
public function setFilters(FilterCollection $filters)
35+
public function setFilters(FilterCollection $filters): self
5536
{
5637
$this->filters = $filters;
5738

5839
return $this;
5940
}
6041

61-
/**
62-
* getFilters
63-
*
64-
* @return FilterCollection
65-
*/
66-
public function getFilters()
42+
public function getFilters(): ?FilterCollection
6743
{
6844
return $this->filters;
6945
}

0 commit comments

Comments
 (0)