Skip to content

Commit d60e6ca

Browse files
committed
chore: composer create-project koriym/php-skeleton phpunit-helper
1 parent 89328f6 commit d60e6ca

18 files changed

+4924
-0
lines changed

.gitattributes

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# https://php.watch/articles/composer-gitattributes
2+
3+
# Exclude build/test files from archive
4+
/tests export-ignore
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/.scrutinizer.yml export-ignore
8+
/.travis.yml export-ignore
9+
/codecov.yml export-ignore
10+
/phpcs.xml export-ignore
11+
/phpmd.xml export-ignore
12+
/phpstan.neon export-ignore
13+
/phpunit.xml.dist export-ignore
14+
15+
# Configure diff output for .php and .phar files.
16+
*.php diff=php
17+
*.phar -diff

.scrutinizer.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
filter:
2+
paths: ["src/*"]
3+
tools:
4+
php_sim: true
5+
php_pdepend: true
6+
php_analyzer: true
7+
php_cpd: true
8+
php_mess_detector:
9+
enabled: true
10+
config:
11+
ruleset: ./phpmd.xml
12+
php_code_sniffer:
13+
enabled: true
14+
config:
15+
ruleset: ./phpcs.xml

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) <2021> <kenjis>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# kenjis/php-unit-helper
2+
3+
## Installation
4+
5+
composer install
6+
7+
## Available Commands
8+
9+
composer test // Run unit test
10+
composer tests // Test and quality checks
11+
composer cs-fix // Fix the coding style
12+
composer sa // Run static analysys tools
13+
composer run-script --list // List all commands
14+

codecov.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
codecov:
2+
notify:
3+
require_ci_to_pass: yes
4+
5+
coverage:
6+
status:
7+
project:
8+
default:
9+
target: 100%
10+
patch:
11+
default:
12+
target: 100%
13+
14+
comment: false

composer.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"name": "kenjis/php-unit-helper",
3+
"description": "",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "kenjis",
8+
"email": "kenji.uui@gmail.com"
9+
}
10+
],
11+
"require": {
12+
"php": "^7.2 || ^8.0"
13+
},
14+
"require-dev": {
15+
"bamarni/composer-bin-plugin": "^1.4",
16+
"phpunit/phpunit": "^9.5"
17+
},
18+
"autoload": {
19+
"psr-4": {
20+
"Kenjis\\PhpUnitHelper\\": "src/"
21+
}
22+
},
23+
"autoload-dev": {
24+
"psr-4": {
25+
"Kenjis\\PhpUnitHelper\\": [
26+
"tests/",
27+
"tests/Fake"
28+
]
29+
}
30+
},
31+
"scripts": {
32+
"setup": "php bin/setup.php",
33+
"test": "./vendor/bin/phpunit",
34+
"coverage": "php -dzend_extension=xdebug.so -dxdebug.mode=coverage ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage",
35+
"pcov": "php -dextension=pcov.so -d pcov.enabled=1 ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage --coverage-clover=coverage.xml",
36+
"cs": "./vendor/bin/phpcs",
37+
"cs-fix": "./vendor/bin/phpcbf src tests",
38+
"metrics": "./vendor/bin/phpmetrics --report-html=build/metrics --exclude=Exception src",
39+
"clean": [
40+
"./vendor/bin/phpstan clear-result-cache",
41+
"./vendor/bin/psalm --clear-cache"
42+
],
43+
"sa": [
44+
"./vendor/bin/phpstan analyse -c phpstan.neon",
45+
"psalm --show-info=true"
46+
],
47+
"tests": [
48+
"@cs",
49+
"@sa",
50+
"@test"
51+
],
52+
"build": [
53+
"@clean",
54+
"@cs",
55+
"@sa",
56+
"@pcov",
57+
"@metrics"
58+
],
59+
"post-install-cmd": "@composer bin all install --ansi",
60+
"post-update-cmd": "@composer bin all update --ansi"
61+
},
62+
"scripts-descriptions": {
63+
"test": "Run unit tests",
64+
"coverage": "Generate test coverage report",
65+
"pcov": "Generate test coverage report (pcov)",
66+
"cs": "Check the coding style",
67+
"cs-fix": "Fix the coding style",
68+
"clean": "Delete tmp files",
69+
"sa": "Run static analysis",
70+
"metrics": "Build metrics report",
71+
"tests": "Run tests and quality checks",
72+
"build": "Build project"
73+
}
74+
}

phpcs.xml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0"?>
2+
<ruleset
3+
name=""
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
6+
7+
<arg name="basepath" value="."/>
8+
<arg name="extensions" value="php"/>
9+
<arg name="parallel" value="80"/>
10+
<arg name="cache" value=".phpcs-cache"/>
11+
12+
<!-- Compatibility with PHP 7.2.0 -->
13+
<config name="php_version" value="70200"/>
14+
15+
<!-- Ignore warnings, show progress of the run and show sniff names -->
16+
<arg value="nps"/>
17+
18+
<!-- Directories to be checked -->
19+
<file>src</file>
20+
<file>tests</file>
21+
<exclude-pattern>*/tmp/*</exclude-pattern>
22+
<exclude-pattern>*/Fake/*</exclude-pattern>
23+
24+
<!-- PSR12 Coding Standard -->
25+
<rule ref="PSR12"/>
26+
27+
<!-- Doctrine Coding Standard -->
28+
<rule ref="Doctrine">
29+
30+
<!-- Exclude Rules -->
31+
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame"/>
32+
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
33+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix"/>
34+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming.SuperfluousSuffix"/>
35+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix"/>
36+
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable"/>
37+
<exclude name="SlevomatCodingStandard.Commenting.UselessInheritDocComment.UselessInheritDocComment"/>
38+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
39+
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed"/>
40+
</rule>
41+
42+
<!-- Additional Rules -->
43+
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
44+
<properties>
45+
<property name="annotationsGroups" type="array">
46+
<element value="@param, @psalm-param, @phpstan-param"/>
47+
<element value="@return, @psalm-return, @phpstan-return"/>
48+
<element value="@throws"/>
49+
</property>
50+
</properties>
51+
</rule>
52+
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing">
53+
<properties>
54+
<property name="minLinesCountBeforeWithComment" value="1"/>
55+
<property name="maxLinesCountBeforeWithComment" value="1"/>
56+
<property name="maxLinesCountBeforeWithoutComment" value="0"/>
57+
</properties>
58+
</rule>
59+
</ruleset>

phpmd.xml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="PHPMD rule set"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
7+
<!--codesize-->
8+
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
9+
<properties>
10+
<property name="reportLevel" value="20"/>
11+
</properties>
12+
</rule>
13+
<rule ref="rulesets/codesize.xml/NPathComplexity">
14+
<properties>
15+
<property name="minimum" value="200"/>
16+
</properties>
17+
</rule>
18+
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity">
19+
<properties>
20+
<property name="maximum" value="100"/>
21+
</properties>
22+
</rule>
23+
<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>
24+
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>
25+
<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>
26+
<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>
27+
<rule ref="rulesets/codesize.xml/TooManyFields"/>
28+
<rule ref="rulesets/codesize.xml/TooManyMethods"/>
29+
<!--design-->
30+
<rule ref="rulesets/design.xml/EvalExpression"/>
31+
<rule ref="rulesets/design.xml/ExitExpression"/>
32+
<rule ref="rulesets/design.xml/GotoStatement" />
33+
<rule ref="rulesets/design.xml/NumberOfChildren"/>
34+
<rule ref="rulesets/design.xml/DepthOfInheritance"/>
35+
<!-- <rule ref="rulesets/design.xml/CouplingBetweenObjects" /> -->
36+
<!--naming-->
37+
<rule ref="rulesets/naming.xml/ConstantNamingConventions"/>
38+
<rule ref="rulesets/naming.xml/BooleanGetMethodName"/>
39+
<!--unusedcode-->
40+
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>
41+
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
42+
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
43+
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
44+
<!--controversial-->
45+
<rule ref="rulesets/controversial.xml/CamelCaseClassName"/>
46+
<rule ref="rulesets/controversial.xml/CamelCasePropertyName"/>
47+
<rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>
48+
<!--cleancode-->
49+
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag"/>
50+
<!-- <rule ref="rulesets/cleancode.xml/ElseExpression" /> -->
51+
</ruleset>

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.dist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php">
5+
<testsuites>
6+
<testsuite name="all">
7+
<directory>tests</directory>
8+
</testsuite>
9+
</testsuites>
10+
<php>
11+
<ini name="error_reporting" value="-1" />
12+
</php>
13+
<filter>
14+
<whitelist processUncoveredFilesFromWhitelist="true">
15+
<directory suffix=".php">src</directory>
16+
</whitelist>
17+
</filter>
18+
</phpunit>

0 commit comments

Comments
 (0)