From 4a17f31e55821786701b949a542d86da929f92e1 Mon Sep 17 00:00:00 2001 From: Chicory Date: Thu, 25 Jul 2024 22:10:23 +0300 Subject: [PATCH] Upload --- .gitignore | 3 +++ .php-cs-fixer.php | 25 +++++++++++++++++++ Makefile | 14 +++++++++++ README.md | 1 + composer.json | 50 ++++++++++++++++++++++++++++++++++++++ phpstan.neon | 5 ++++ phpunit.xml | 23 ++++++++++++++++++ src/ExampleClass.php | 13 ++++++++++ tests/ExampleClassTest.php | 27 ++++++++++++++++++++ 9 files changed, 161 insertions(+) create mode 100644 .gitignore create mode 100644 .php-cs-fixer.php create mode 100644 Makefile create mode 100644 README.md create mode 100644 composer.json create mode 100644 phpstan.neon create mode 100644 phpunit.xml create mode 100644 src/ExampleClass.php create mode 100644 tests/ExampleClassTest.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed0f829 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/vendor/ +composer.lock +.phpunit.cache \ No newline at end of file diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..b885676 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,25 @@ +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') + ); diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8305882 --- /dev/null +++ b/Makefile @@ -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 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..776526a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Composer package template \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..44b1a57 --- /dev/null +++ b/composer.json @@ -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" + ] + } +} diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..bc72a37 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: max + paths: + - src + - tests \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..222528b --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,23 @@ + + + + + tests + + + + + + src + + + diff --git a/src/ExampleClass.php b/src/ExampleClass.php new file mode 100644 index 0000000..d94784d --- /dev/null +++ b/src/ExampleClass.php @@ -0,0 +1,13 @@ +exampleClass = new ExampleClass(); + + parent::setUp(); + } + + public function testExampleClass(): void + { + $this->assertEquals('Hello', $this->exampleClass->sayHello()); + } +}