From ccde576d9feb1fb0c9574456e6fa622b6952dbd4 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Sat, 13 Aug 2022 14:15:14 +0200 Subject: [PATCH] Various code cleanups and coding standards --- README.md | 31 ++++++++++++++++ composer.json | 9 ++++- ecs.php | 35 +++++-------------- .../HeadsnetMoneyExtension.php | 5 +-- 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 8027c84..bcf439f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,20 @@ Money Bundle A Symfony bundle to integrate [Money PHP](https://github.com/moneyphp/money) and provide various Twig and Doctrine helpers. +## Installation + +Simply install with Composer in the usual way. + +```bash +composer require headsnet/money-bundle +``` + +Then add to your `bundles.php` file. + +```php +Headsnet\MoneyBundle\HeadsnetMoneyBundle::class => ['all' => true] +``` + ## Doctrine The bundle provides a custom Doctrine Type for the `Currency` element of the Money object, and then a Doctrine @@ -62,3 +76,20 @@ $amount = Money::EUR(200); $serializer->serialize($amount, 'json'); // ==> '{"amount":"200","currency":"EUR"}' ``` + +## Contributing + +Contributions are welcome. Please submit pull requests with one fix/feature per +pull request. + +Composer scripts are configured for your convenience: + +``` +> composer cs # Run coding standards checks +> composer cs-fix # Fix coding standards violations +``` + +### Licence + +This code is released under the MIT licence. Please see the LICENSE file for more information. + diff --git a/composer.json b/composer.json index c7cc418..2121432 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,10 @@ "doctrine/doctrine-bundle": "^1.0|^2.0", "symfony/form": "^4.0|^5.0", "symfony/serializer": "^4.0|^5.0", - "symfony/twig-bundle": "^4.0|^5.0" + "symfony/twig-bundle": "^4.0|^5.0", + "phpunit/phpunit": "^8.0 || ^9.0", + "symplify/easy-coding-standard": "^11", + "phpstan/phpstan": "^1.8" }, "suggest": { "doctrine/doctrine-bundle": "Add a Money DBAL mapping type", @@ -29,5 +32,9 @@ "psr-4": { "Headsnet\\MoneyBundle\\": "src/" } + }, + "scripts": { + "cs": "vendor/bin/ecs check --ansi --config=ecs.php", + "cs-fix": "vendor/bin/ecs check --ansi --config=ecs.php --fix" } } diff --git a/ecs.php b/ecs.php index 85015a4..f341ec0 100644 --- a/ecs.php +++ b/ecs.php @@ -2,46 +2,27 @@ /* * This file is part of the Symfony HeadsnetMoneyBundle. * - * (c) Headstrong Internet Services Ltd 2021 + * (c) Headstrong Internet Services Ltd 2022 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -/** @noinspection ALL */ declare(strict_types=1); -use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer; -use PhpCsFixer\Fixer\ArrayNotation\TrailingCommaInMultilineArrayFixer; -use PhpCsFixer\Fixer\Basic\BracesFixer; -use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer; -use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer; -use PhpCsFixer\Fixer\FunctionNotation\SingleLineThrowFixer; -use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer; -use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer; -use PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer; -use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer; -use SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff; -use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer; -use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer; -use Symplify\EasyCodingStandard\ValueObject\Option; +use Symplify\EasyCodingStandard\Config\ECSConfig; use Symplify\EasyCodingStandard\ValueObject\Set\SetList; -return static function (ContainerConfigurator $containerConfigurator): void -{ - $services = $containerConfigurator->services(); +/** + * + */ +return static function (ECSConfig $ecsConfig): void { - $parameters = $containerConfigurator->parameters(); - $parameters->set(Option::PATHS, [ + $ecsConfig->paths([ __DIR__ . '/src' ]); - $parameters->set(Option::SKIP, [ - __DIR__ . '/tests/_support/_generated/*', - ]); - - $parameters->set(Option::SETS, [ + $ecsConfig->sets([ SetList::PSR_12 ]); }; diff --git a/src/DependencyInjection/HeadsnetMoneyExtension.php b/src/DependencyInjection/HeadsnetMoneyExtension.php index 0391896..d1f3e64 100644 --- a/src/DependencyInjection/HeadsnetMoneyExtension.php +++ b/src/DependencyInjection/HeadsnetMoneyExtension.php @@ -2,7 +2,7 @@ /* * This file is part of the Symfony HeadsnetMoneyBundle. * - * (c) Headstrong Internet Services Ltd 2021 + * (c) Headstrong Internet Services Ltd 2022 * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -15,9 +15,6 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -/** - * Bundle extension. - */ class HeadsnetMoneyExtension extends Extension { /**