Skip to content

Commit 6f71c50

Browse files
#1 Add/Update rector, phpstan & php-cs-fixer configurations. Remove phpcs configuration.
1 parent d1c1149 commit 6f71c50

File tree

11 files changed

+185
-18
lines changed

11 files changed

+185
-18
lines changed

.env.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS='App\Kernel'
3+
APP_SECRET='$ecretf0rt3st'
4+
SYMFONY_DEPRECATIONS_HELPER=999999
5+
PANTHER_APP_ENV=panther
6+
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots

.gitignore

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
/.php-cs-fixer.cache
1818
###< friendsofphp/php-cs-fixer ###
1919

20-
###> phpstan/phpstan ###
21-
phpstan.neon
22-
###< phpstan/phpstan ###
20+
###> symfony/phpunit-bridge ###
21+
.phpunit.cache
22+
/phpunit.xml
23+
###< symfony/phpunit-bridge ###
2324

24-
###> php-cs-fixer/shim ###
25-
/.php-cs-fixer.php
26-
/.php-cs-fixer.cache
27-
###< php-cs-fixer/shim ###
25+
###> phpunit/phpunit ###
26+
/phpunit.xml
27+
.phpunit.result.cache
28+
###< phpunit/phpunit ###

.php-cs-fixer.dist.php

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,47 @@
11
<?php
22

3-
$finder = (new PhpCsFixer\Finder())
4-
->in(__DIR__)
5-
->exclude('var')
6-
;
3+
/*
4+
* This file is part of the CleverAge/ProcessBundleDemo package.
5+
*
6+
* Copyright (c) Clever-Age
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+
if (!file_exists(__DIR__.'/src')) {
13+
exit(0);
14+
}
15+
16+
$fileHeaderComment = <<<'EOF'
17+
This file is part of the CleverAge/ProcessBundleDemo package.
18+
19+
Copyright (c) Clever-Age
20+
21+
For the full copyright and license information, please view the LICENSE
22+
file that was distributed with this source code.
23+
EOF;
724

825
return (new PhpCsFixer\Config())
926
->setRules([
27+
'@PHP71Migration' => true,
28+
'@PHP82Migration' => true,
29+
'@PHPUnit75Migration:risky' => true,
1030
'@Symfony' => true,
31+
'@Symfony:risky' => true,
32+
'@DoctrineAnnotation' => true,
33+
'protected_to_private' => false,
34+
'native_constant_invocation' => ['strict' => false],
35+
'header_comment' => ['header' => $fileHeaderComment],
36+
'modernize_strpos' => true,
37+
'get_class_to_class_keyword' => true,
1138
])
12-
->setFinder($finder)
39+
->setRiskyAllowed(true)
40+
->setFinder(
41+
(new PhpCsFixer\Finder())
42+
->in(__DIR__.'/src')
43+
->in(__DIR__.'/tests')
44+
->append([__FILE__])
45+
)
46+
->setCacheFile('.php-cs-fixer.cache')
1347
;

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,19 @@ xdebug/on: #[Docker] Enable xdebug
5050
xdebug/off: #[Docker] Disable xdebug
5151
$(DOCKER_COMPOSE) stop php
5252
XDEBUG_MODE=off $(DOCKER_COMPOSE) up --remove-orphans --detach
53+
54+
quality: phpstan php-cs-fixer rector #[Quality] Run all quality checks
55+
56+
phpstan: #[Quality] Run PHPStan
57+
$(DOCKER_RUN_PHP) "vendor/bin/phpstan --no-progress --memory-limit=1G analyse"
58+
59+
php-cs-fixer: #[Quality] Run PHP-CS-Fixer
60+
$(DOCKER_RUN_PHP) "vendor/bin/php-cs-fixer fix --diff --verbose"
61+
62+
rector: #[Quality] Run Rector
63+
$(DOCKER_RUN_PHP) "vendor/bin/rector"
64+
65+
tests: phpunit #[Tests] Run all tests
66+
67+
phpunit: #[Tests] Run PHPUnit
68+
$(DOCKER_RUN_PHP) "vendor/bin/phpunit"

composer.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@
1414
"symfony/flex": "^v2.3"
1515
},
1616
"require-dev": {
17-
"symfony/maker-bundle": "^1.51",
18-
"symfony/stopwatch": "^6.4",
19-
"symfony/web-profiler-bundle": "^6.4",
20-
"friendsofphp/php-cs-fixer": "^3.34",
21-
"phpstan/phpstan": "^1.10",
17+
"friendsofphp/php-cs-fixer": "*",
18+
"phpstan/extension-installer": "*",
19+
"phpstan/phpstan": "*",
20+
"phpstan/phpstan-doctrine": "*",
21+
"phpstan/phpstan-symfony": "*",
22+
"phpunit/phpunit": "<10.0",
23+
"rector/rector": "*",
2224
"roave/security-advisories": "dev-latest",
23-
"symfony/debug-bundle": "^6.4"
25+
"symfony/browser-kit": "7.2.x-dev",
26+
"symfony/css-selector": "7.2.x-dev",
27+
"symfony/debug-bundle": "^6.4|^7.1",
28+
"symfony/maker-bundle": "^1.51",
29+
"symfony/stopwatch": "^6.4|^7.1",
30+
"symfony/web-profiler-bundle": "^6.4|^7.1"
2431
},
2532
"scripts": {
2633
"auto-scripts": {
@@ -30,6 +37,7 @@
3037
},
3138
"config": {
3239
"allow-plugins": {
40+
"phpstan/extension-installer": true,
3341
"symfony/flex": true,
3442
"symfony/runtime": true
3543
},

phpstan.neon

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
parameters:
2+
level: 8
3+
paths:
4+
- src
5+
- tests
6+
excludePaths:
7+
- src/DependencyInjection/Configuration.php
8+
ignoreErrors:
9+
- '#type has no value type specified in iterable type#'
10+
- '#has parameter .* with no value type specified in iterable type#'
11+
- '#has no value type specified in iterable type array#'
12+
- '#configureOptions\(\) has no return type specified.#'
13+
- '#configure\(\) has no return type specified#'
14+
- '#process\(\) has no return type specified#'
15+
- '#should return Iterator but returns Traversable#'
16+
- '#Negated boolean expression is always false#'
17+
checkGenericClassInNonGenericObjectType: false
18+
reportUnmatchedIgnoredErrors: false
19+
inferPrivatePropertyTypeFromConstructor: true
20+
treatPhpDocTypesAsCertain: false

phpunit.xml.dist

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheResultFile=".phpunit.cache/test-results"
6+
executionOrder="depends,defects"
7+
forceCoversAnnotation="true"
8+
beStrictAboutCoversAnnotation="true"
9+
beStrictAboutOutputDuringTests="true"
10+
beStrictAboutTodoAnnotatedTests="true"
11+
convertDeprecationsToExceptions="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
verbose="true">
15+
<testsuites>
16+
<testsuite name="default">
17+
<directory>tests</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<coverage cacheDirectory=".phpunit.cache/code-coverage"
22+
processUncoveredFiles="true">
23+
<include>
24+
<directory suffix=".php">src</directory>
25+
</include>
26+
</coverage>
27+
</phpunit>

rector.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Set\ValueObject\LevelSetList;
7+
use Rector\Symfony\Set\SymfonySetList;
8+
use Rector\ValueObject\PhpVersion;
9+
10+
return RectorConfig::configure()
11+
->withPhpVersion(PhpVersion::PHP_82)
12+
->withPaths([
13+
__DIR__.'/src',
14+
__DIR__.'/tests',
15+
])
16+
->withPhpSets(php82: true)
17+
// here we can define, what prepared sets of rules will be applied
18+
->withPreparedSets(
19+
deadCode: true,
20+
codeQuality: true
21+
)
22+
->withSets([
23+
LevelSetList::UP_TO_PHP_82,
24+
SymfonySetList::SYMFONY_64,
25+
SymfonySetList::SYMFONY_71,
26+
SymfonySetList::SYMFONY_CODE_QUALITY,
27+
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
28+
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
29+
])
30+
;

symfony.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,20 @@
9393
"phpstan.dist.neon"
9494
]
9595
},
96+
"phpunit/phpunit": {
97+
"version": "9.6",
98+
"recipe": {
99+
"repo": "github.com/symfony/recipes",
100+
"branch": "main",
101+
"version": "9.6",
102+
"ref": "7364a21d87e658eb363c5020c072ecfdc12e2326"
103+
},
104+
"files": [
105+
".env.test",
106+
"phpunit.xml.dist",
107+
"tests/bootstrap.php"
108+
]
109+
},
96110
"symfony/console": {
97111
"version": "6.3",
98112
"recipe": {

tests/.gitkeep

Whitespace-only changes.

tests/bootstrap.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Symfony\Component\Dotenv\Dotenv;
4+
5+
require dirname(__DIR__).'/vendor/autoload.php';
6+
7+
if (file_exists(dirname(__DIR__).'/config/bootstrap.php')) {
8+
require dirname(__DIR__).'/config/bootstrap.php';
9+
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
10+
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
11+
}

0 commit comments

Comments
 (0)