This commit is contained in:
Chicory ☕ 2024-07-25 22:10:23 +03:00
commit 4a17f31e55
Signed by: chicory
GPG Key ID: AC95A793F70BEDCD
9 changed files with 161 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/vendor/
composer.lock
.phpunit.cache

25
.php-cs-fixer.php Normal file
View File

@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
$config = new PhpCsFixer\Config();
return $config
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'@Symfony' => true,
'assign_null_coalescing_to_coalesce_equal' => true,
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'declare_strict_types' => true,
'nullable_type_declaration' => true,
'phpdoc_var_annotation_correct_order' => true,
'single_line_empty_body' => true,
'ternary_to_null_coalescing' => true,
])
->setFinder(PhpCsFixer\Finder::create()
// ->exclude('folder-to-exclude') // if you want to exclude some folders, you can do it like this!
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
);

14
Makefile Normal file
View File

@ -0,0 +1,14 @@
code-style-fix:
@composer code-style-fix
code-style-check:
@composer code-style-check
analyze-code:
@composer analyze-code
run-unit-tests:
@composer run-unit-tests
full-test:
@composer full-test

1
README.md Normal file
View File

@ -0,0 +1 @@
# Composer package template

50
composer.json Normal file
View File

@ -0,0 +1,50 @@
{
"name": "chicory/package-template",
"description": "Composer package template",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {
"Chicory\\PackageTemplate\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Chicory\\Tests\\PackageTemplate\\": "tests/"
}
},
"authors": [
{
"name": "Chicory",
"email": "chicory@fossee.net"
}
],
"minimum-stability": "stable",
"require": {
"php": "8.*"
},
"require-dev": {
"phpunit/phpunit": "11.*",
"phpstan/phpstan": "1.*",
"friendsofphp/php-cs-fixer": "^3.60"
},
"scripts": {
"code-style-check": [
"./vendor/bin/php-cs-fixer fix --dry-run --stop-on-violation --using-cache=no"
],
"code-style-fix": [
"./vendor/bin/php-cs-fixer fix -v --using-cache=no"
],
"analyze-code": [
"./vendor/bin/phpstan"
],
"run-unit-tests": [
"./vendor/bin/phpunit"
],
"full-test": [
"@code-style-check",
"@analyze-code",
"@run-unit-tests"
]
}
}

5
phpstan.neon Normal file
View File

@ -0,0 +1,5 @@
parameters:
level: max
paths:
- src
- tests

23
phpunit.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>

13
src/ExampleClass.php Normal file
View File

@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace Chicory\PackageTemplate;
class ExampleClass
{
public function sayHello(): string
{
return 'Hello';
}
}

View File

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Chicory\Tests\PackageTemplate;
use Chicory\PackageTemplate\ExampleClass;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
#[CoversClass(ExampleClass::class)]
class ExampleClassTest extends TestCase
{
public ExampleClass $exampleClass;
protected function setUp(): void
{
$this->exampleClass = new ExampleClass();
parent::setUp();
}
public function testExampleClass(): void
{
$this->assertEquals('Hello', $this->exampleClass->sayHello());
}
}