Skip to content

Commit 486a4e8

Browse files
committed
feature #819 drop symfony 3.x support && firm up PHP 8 tests (jrushlow)
This PR was squashed before being merged into the 1.0-dev branch. Discussion ---------- drop symfony 3.x support && firm up PHP 8 tests - upgrade `twigcs` to version 5.x for PHP8 support. `twigcs` v4.x is required for PHP 7.1 support - drops official support for Symfony 3.x in MakerBundle Commits ------- d69c9f8 drop symfony 3.x support && firm up PHP 8 tests
2 parents f461d07 + d69c9f8 commit 486a4e8

File tree

5 files changed

+72
-16
lines changed

5 files changed

+72
-16
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
env:
1010
PHPUNIT_FLAGS: "-v"
1111
SYMFONY_PHPUNIT_DIR: "$HOME/symfony-bridge/.phpunit"
12-
SYMFONY_REQUIRE: ">=3.4"
12+
SYMFONY_REQUIRE: ">=4.0"
1313

1414
jobs:
1515
coding-standards:
@@ -43,7 +43,7 @@ jobs:
4343
name: "Composer install"
4444
uses: "ramsey/composer-install@v1"
4545
with:
46-
composer-options: "--no-suggest --no-scripts"
46+
composer-options: "--no-scripts"
4747

4848
-
4949
name: "Run friendsofphp/php-cs-fixer"
@@ -84,11 +84,9 @@ jobs:
8484
include:
8585
- php-version: '7.4'
8686
symfony-skeleton-stability: 'dev'
87-
composer-options: '--no-suggest'
8887
allow-failures: true
8988
- php-version: '8.0'
9089
symfony-skeleton-stability: 'dev'
91-
composer-options: '--no-suggest --ignore-platform-req=php'
9290
allow-failures: true
9391

9492
steps:

.twig_cs.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
use FriendsOfTwig\Twigcs\Config\Config;
4+
use Symfony\Bundle\MakerBundle\Test\MakerTwigRuleSet;
5+
6+
return Config::create()
7+
->setRuleSet(MakerTwigRuleSet::class)
8+
;

composer.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,26 @@
1616
"php": ">=7.1.3",
1717
"doctrine/inflector": "^1.2|^2.0",
1818
"nikic/php-parser": "^4.0",
19-
"symfony/config": "^3.4|^4.0|^5.0",
20-
"symfony/console": "^3.4|^4.0|^5.0",
21-
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
19+
"symfony/config": "^4.0|^5.0",
20+
"symfony/console": "^4.0|^5.0",
21+
"symfony/dependency-injection": "^4.0|^5.0",
2222
"symfony/deprecation-contracts": "^2.2",
23-
"symfony/filesystem": "^3.4|^4.0|^5.0",
24-
"symfony/finder": "^3.4|^4.0|^5.0",
25-
"symfony/framework-bundle": "^3.4|^4.0|^5.0",
26-
"symfony/http-kernel": "^3.4|^4.0|^5.0"
23+
"symfony/filesystem": "^4.0|^5.0",
24+
"symfony/finder": "^4.0|^5.0",
25+
"symfony/framework-bundle": "^4.0|^5.0",
26+
"symfony/http-kernel": "^4.0|^5.0"
2727
},
2828
"require-dev": {
2929
"composer/semver": "^3.0@dev",
3030
"doctrine/doctrine-bundle": "^1.8|^2.0",
3131
"doctrine/orm": "^2.3",
3232
"friendsofphp/php-cs-fixer": "^2.8",
33-
"friendsoftwig/twigcs": "^3.1.2",
33+
"friendsoftwig/twigcs": "^4.1.0|^5.0.0",
3434
"symfony/http-client": "^4.3|^5.0",
3535
"symfony/phpunit-bridge": "^4.3|^5.0",
36-
"symfony/process": "^3.4|^4.0|^5.0",
37-
"symfony/security-core": "^3.4|^4.0|^5.0",
38-
"symfony/yaml": "^3.4|^4.0|^5.0"
36+
"symfony/process": "^4.0|^5.0",
37+
"symfony/security-core": "^4.0|^5.0",
38+
"symfony/yaml": "^4.0|^5.0"
3939
},
4040
"config": {
4141
"preferred-install": "dist",

src/Test/MakerTestEnvironment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function runPhpCSFixer(string $file)
272272

273273
public function runTwigCSLint(string $file)
274274
{
275-
return MakerTestProcess::create(sprintf('php vendor/bin/twigcs lint %s', $this->path.'/'.$file), $this->rootPath)
275+
return MakerTestProcess::create(sprintf('php vendor/bin/twigcs --config ./.twig_cs.dist %s', $this->path.'/'.$file), $this->rootPath)
276276
->run(true);
277277
}
278278

src/Test/MakerTwigRuleSet.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony MakerBundle package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\MakerBundle\Test;
13+
14+
use FriendsOfTwig\Twigcs\RegEngine\RulesetBuilder;
15+
use FriendsOfTwig\Twigcs\RegEngine\RulesetConfigurator;
16+
use FriendsOfTwig\Twigcs\Rule;
17+
use FriendsOfTwig\Twigcs\Ruleset\RulesetInterface;
18+
use FriendsOfTwig\Twigcs\Validator\Violation;
19+
20+
/**
21+
* @author Jesse Rushlow <jr@rushlow.dev>
22+
*
23+
* @internal
24+
*/
25+
final class MakerTwigRuleSet implements RulesetInterface
26+
{
27+
private $twigMajorVersion;
28+
29+
public function __construct(int $twigMajorVersion)
30+
{
31+
$this->twigMajorVersion = $twigMajorVersion;
32+
}
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
public function getRules(): array
38+
{
39+
$configurator = new RulesetConfigurator();
40+
$configurator->setTwigMajorVersion($this->twigMajorVersion);
41+
$builder = new RulesetBuilder($configurator);
42+
43+
return [
44+
new Rule\RegEngineRule(Violation::SEVERITY_ERROR, $builder->build()),
45+
new Rule\TrailingSpace(Violation::SEVERITY_ERROR),
46+
new Rule\UnusedMacro(Violation::SEVERITY_WARNING),
47+
new Rule\UnusedVariable(Violation::SEVERITY_WARNING),
48+
];
49+
}
50+
}

0 commit comments

Comments
 (0)