Skip to content

Commit

Permalink
Feat/support php8 (#68)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Valentin Clavreul <[email protected]>
  • Loading branch information
3 people authored Jun 13, 2022
1 parent b6e03f8 commit 194de71
Show file tree
Hide file tree
Showing 63 changed files with 705 additions and 2,284 deletions.
11 changes: 0 additions & 11 deletions .coke

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@master
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
- run: composer install --prefer-dist --no-interaction
- run: bin/php-cs-fixer fix --dry-run --stop-on-violation --diff --ansi

Expand All @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
version: ['8.0', '8.1']
flags: ['', '--prefer-lowest']
fail-fast: false
steps:
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
bin/
vendor/
src/M6Web/Bundle/LogBridgeBundle/Tests/Resources/cache/*
composer.lock
src/M6Web/Bundle/LogBridgeBundle/Tests/Fixtures/Resources/cache/*
.php_cs.cache
.php-cs-fixer.cache
composer.lock
30 changes: 10 additions & 20 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
<?php

$config = new class() extends \PhpCsFixer\Config {
public function __construct()
{
parent::__construct('Bedrock(PHP 7.1)');
}

public function getRules()
{
return (new \M6Web\CS\Config\Php71())->getRules() + ['increment_style' => false];
}
};

$config->getFinder()
->in([
__DIR__.'/src'
])->exclude([
'Tests'
]);

return $config;
return (new \M6Web\CS\Config\BedrockStreaming())
->setFinder(
PhpCsFixer\Finder::create()
->in([
__DIR__.'/src'
])
->exclude([
'Tests'
])
);
14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@
"minimum-stability" : "dev",
"prefer-stable": true,
"require": {
"php": ">=7.1.3",
"php": ">=8.0",
"symfony/config": "^4.4|^5.0|^6.0",
"symfony/yaml": "^4.4|^5.0|^6.0",
"symfony/routing": "^4.4|^5.0|^6.0",
"symfony/expression-language": "^4.4|^5.0|^6.0",
"symfony/security-core": "^4.4|^5.0|^6.0"
"symfony/security-core": "^4.4|^5.0|^6.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
"symfony/http-kernel": "^4.4|^5.0|^6.0"
},
"require-dev": {
"atoum/atoum": "^3.4|^4.0",
"friendsofphp/php-cs-fixer": "^2.19",
"m6web/symfony2-coding-standard": "~1.2",
"m6web/php-cs-fixer-config": "^1.0",
"symfony/http-foundation": "^4.4|^5.0|^6.0"
"m6web/php-cs-fixer-config": "^2.1",
"symfony/http-foundation": "^4.4|^5.0|^6.0",
"phpstan/phpstan": "^1.7",
"rector/rector": "^0.13.2"
},
"extra": {
"branch-alias": {
Expand Down
70 changes: 70 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
parameters:
level: max
paths:
- src
excludePaths:
# This class is deprecated, we don't care about warnings
- src/M6Web/Bundle/LogBridgeBundle/EventDispatcher/BuilderEvent.php
- src/M6Web/Bundle/LogBridgeBundle/Tests/*

# Errors from DependencyInjection : hard to fix, not that useful
ignoreErrors:
-
message: "#^Parameter \\#1 \\$id of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:findDefinition\\(\\) expects string, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
count: 1
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php

-
message: "#^Parameter \\#1 \\$object_or_class of function class_implements expects object\\|string, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
count: 1
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php

-
message: "#^Parameter \\#1 \\$string of function substr expects string, string\\|null given\\.$#"
count: 1
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php

-
message: "#^Parameter \\#2 \\$haystack of function in_array expects array, array\\<string, string\\>\\|false given\\.$#"
count: 1
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php

-
message: "#^Parameter \\#2 \\$subject of function preg_match expects string, string\\|null given\\.$#"
count: 1
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
count: 1
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/CompilerPass/LoggerValidationPass.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
count: 1
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/Configuration.php

-
message: "#^Method M6Web\\\\Bundle\\\\LogBridgeBundle\\\\DependencyInjection\\\\M6WebLogBridgeExtension\\:\\:load\\(\\) has parameter \\$configs with no value type specified in iterable type array\\.$#"
count: 1
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/M6WebLogBridgeExtension.php

-
message: "#^Parameter \\#1 \\$class of class Symfony\\\\Component\\\\DependencyInjection\\\\Definition constructor expects string\\|null, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
count: 2
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/M6WebLogBridgeExtension.php

-
message: "#^Parameter \\#1 \\$id of class Symfony\\\\Component\\\\DependencyInjection\\\\Reference constructor expects string, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
count: 3
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/M6WebLogBridgeExtension.php

-
message: "#^Parameter \\#1 \\$id of method Symfony\\\\Component\\\\DependencyInjection\\\\ContainerBuilder\\:\\:setDefinition\\(\\) expects string, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
count: 2
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/M6WebLogBridgeExtension.php

-
message: "#^Parameter \\#1 \\.\\.\\.\\$arrays of function array_merge expects array, array\\|bool\\|float\\|int\\|string\\|UnitEnum\\|null given\\.$#"
count: 1
path: src/M6Web/Bundle/LogBridgeBundle/DependencyInjection/M6WebLogBridgeExtension.php
21 changes: 21 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src'
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80
]);
};
46 changes: 11 additions & 35 deletions src/M6Web/Bundle/LogBridgeBundle/Config/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,69 +1,45 @@
<?php

declare(strict_types=1);

namespace M6Web\Bundle\LogBridgeBundle\Config;

/**
* Class Configuration
*/
class Configuration
{
/** @var FilterCollection */
private $filters;

/** @var array */
private $activeFilters;
private ?FilterCollection $filters = null;

/**
* Constructor
*/
public function __construct()
{
$this->filters = null;
$this->activeFilters = null;
}
/** @var string[] */
private ?array $activeFilters = null;

/**
* setActiveFilters
*
* @return Configuration
* @param string[] $activeFilters
*/
public function setActiveFilters(array $activeFilters)
public function setActiveFilters(array $activeFilters): self
{
$this->activeFilters = $activeFilters;

return $this;
}

/**
* getActiveFilters
*
* @return array
* @return string[]|null
*/
public function getActiveFilters()
public function getActiveFilters(): ?array
{
return $this->activeFilters;
}

/**
* setFilters
*
* @param FilterCollection $filters Filters
*
* @return Configuration
*/
public function setFilters(FilterCollection $filters)
public function setFilters(FilterCollection $filters): self
{
$this->filters = $filters;

return $this;
}

/**
* getFilters
*
* @return FilterCollection
*/
public function getFilters()
public function getFilters(): ?FilterCollection
{
return $this->filters;
}
Expand Down
Loading

0 comments on commit 194de71

Please sign in to comment.