Skip to content

Commit 78897ab

Browse files
committed
Add quality tools
1 parent ad08e92 commit 78897ab

File tree

6 files changed

+117
-0
lines changed

6 files changed

+117
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
/var/
12
/vendor/
23
composer.lock

.php-cs-fixer.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = (new PhpCsFixer\Finder())
6+
->in(['src', 'tests']);
7+
8+
return (new PhpCsFixer\Config())
9+
->setCacheFile('var/.php-cs-fixer.cache')
10+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
11+
->setRiskyAllowed(true)
12+
->setRules([
13+
'@PhpCsFixer' => true,
14+
'@Symfony' => true,
15+
'@PER-CS2.0' => true,
16+
'binary_operator_spaces' => false,
17+
'cast_spaces' => true,
18+
'concat_space' => ['spacing' => 'one'],
19+
'declare_strict_types' => true,
20+
'global_namespace_import' => [
21+
'import_classes' => true,
22+
'import_constants' => null,
23+
'import_functions' => null,
24+
],
25+
'multiline_whitespace_before_semicolons' => false,
26+
'phpdoc_align' => ['align' => 'left'],
27+
'phpdoc_order' => true,
28+
'phpdoc_to_comment' => false,
29+
'php_unit_test_class_requires_covers' => false,
30+
'single_line_throw' => false,
31+
'trailing_comma_in_multiline' => [
32+
'elements' => ['arrays', 'arguments', 'parameters'],
33+
],
34+
'void_return' => true,
35+
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
36+
])
37+
->setFinder($finder);

captainhook.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"pre-push": {
3+
"enabled": true,
4+
"actions": [
5+
{
6+
"action": "composer cs"
7+
},
8+
{
9+
"action": "composer phpstan"
10+
},
11+
{
12+
"action": "composer dependency-analyser"
13+
},
14+
{
15+
"action": "composer phpunit"
16+
},
17+
{
18+
"action": "composer coverage"
19+
}
20+
]
21+
}
22+
}

composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
"php": "^8.3",
2323
"symfony/serializer": "^7.0"
2424
},
25+
"require-dev": {
26+
"captainhook/captainhook": "^5.23",
27+
"friendsofphp/php-cs-fixer": "^3.58",
28+
"phpstan/phpstan": "^1.11",
29+
"phpunit/phpunit": "^11.1",
30+
"rregeer/phpunit-coverage-check": "^0.3.1",
31+
"shipmonk/composer-dependency-analyser": "^1.5"
32+
},
2533
"autoload": {
2634
"psr-4": {
2735
"Gember\\SerializerSymfony\\": "src/"
@@ -34,5 +42,20 @@
3442
},
3543
"config": {
3644
"sort-packages": true
45+
},
46+
"scripts": {
47+
"coverage": "vendor/bin/coverage-check var/coverage/clover.xml 95",
48+
"cs": "vendor/bin/php-cs-fixer fix --diff --dry-run --config=.php-cs-fixer.php",
49+
"cs:fix": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php",
50+
"dependency-analyser": "vendor/bin/composer-dependency-analyser",
51+
"phpstan": "vendor/bin/phpstan analyse -c phpstan.neon",
52+
"phpunit": "XDEBUG_MODE=coverage vendor/bin/phpunit",
53+
"test": [
54+
"@cs",
55+
"@dependency-analyser",
56+
"@phpstan",
57+
"@phpunit",
58+
"@coverage"
59+
]
3760
}
3861
}

phpstan.neon

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

phpunit.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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/11.1/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory="var/.phpunit.cache"
6+
colors="true"
7+
executionOrder="depends,defects"
8+
requireCoverageMetadata="false"
9+
beStrictAboutCoverageMetadata="false"
10+
beStrictAboutOutputDuringTests="true"
11+
failOnRisky="true"
12+
failOnWarning="true">
13+
<testsuites>
14+
<testsuite name="default">
15+
<directory>tests</directory>
16+
</testsuite>
17+
</testsuites>
18+
<coverage includeUncoveredFiles="true">
19+
<report>
20+
<clover outputFile="var/coverage/clover.xml"/>
21+
<html outputDirectory="var/coverage/html-coverage"/>
22+
</report>
23+
</coverage>
24+
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
25+
<include>
26+
<directory>src</directory>
27+
</include>
28+
</source>
29+
</phpunit>

0 commit comments

Comments
 (0)