Skip to content

Commit 67a5bb7

Browse files
#4 Add rector, phpstan & php-cs-fixer configurations
1 parent 037ad76 commit 67a5bb7

6 files changed

Lines changed: 118 additions & 0 deletions

File tree

.php-cs-fixer.dist.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the CleverAge/CacheProcessBundle 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/CacheProcessBundle 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;
24+
25+
return (new PhpCsFixer\Config())
26+
->setRules([
27+
'@PHP71Migration' => true,
28+
'@PHP82Migration' => true,
29+
'@PHPUnit75Migration:risky' => true,
30+
'@Symfony' => true,
31+
'@Symfony:risky' => true,
32+
'protected_to_private' => false,
33+
'native_constant_invocation' => ['strict' => false],
34+
'header_comment' => ['header' => $fileHeaderComment],
35+
'modernize_strpos' => true,
36+
'get_class_to_class_keyword' => true,
37+
])
38+
->setRiskyAllowed(true)
39+
->setFinder(
40+
(new PhpCsFixer\Finder())
41+
->in(__DIR__.'/src')
42+
->in(__DIR__.'/tests')
43+
->append([__FILE__])
44+
)
45+
->setCacheFile('.php-cs-fixer.cache')
46+
;

composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,19 @@
3131
"symfony/cache": "^6.4|^7.1"
3232
},
3333
"require-dev": {
34+
"friendsofphp/php-cs-fixer": "*",
35+
"phpstan/extension-installer": "*",
36+
"phpstan/phpstan": "*",
37+
"phpstan/phpstan-symfony": "*",
38+
"phpunit/phpunit": "*",
39+
"rector/rector": "*",
40+
"roave/security-advisories": "dev-latest",
41+
"symfony/test-pack": "^1.1"
3442
},
3543
"config": {
3644
"allow-plugins": {
45+
"phpstan/extension-installer": true,
46+
"symfony/flex": true,
3747
"symfony/runtime": true
3848
},
3949
"sort-packages": true

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
level: 10
3+
paths:
4+
- src
5+
- tests

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+
;

tests/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)