From 7bd736ba69cebbb3540f95d5789b5a7d7a008034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faugeron?= Date: Sat, 14 Dec 2024 18:37:33 +0000 Subject: [PATCH 1/5] Configured `ssc/cs` to be used in all `ssc/lib` --- .php-cs-fixer.dist.php | 98 +++-------------------- composer.json | 2 +- packages/cs/README.md | 2 +- packages/cs/composer.json | 6 ++ packages/exception/.php-cs-fixer.dist.php | 12 +++ packages/exception/bin/test.sh | 43 ++++++++++ packages/exception/composer.json | 9 ++- 7 files changed, 80 insertions(+), 92 deletions(-) create mode 100644 packages/exception/.php-cs-fixer.dist.php create mode 100755 packages/exception/bin/test.sh diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 59aad00..d4448a0 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,92 +1,12 @@ in(__DIR__) - ->exclude('bin') - ->exclude('cache') - ->exclude('doc') - ->exclude('logs') - ->exclude('vendor') -; - -return (new PhpCsFixer\Config()) - ->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect()) - ->setRules([ - '@Symfony' => true, - - 'array_indentation' => true, - 'array_syntax' => [ - 'syntax' => 'short', - ], - 'trailing_comma_in_multiline' => [ - 'elements' => ['arrays', 'arguments', 'parameters'], - ], - 'dir_constant' => true, - 'ereg_to_preg' => true, - 'explicit_indirect_variable' => true, - 'explicit_string_variable' => true, - 'fopen_flag_order' => true, - 'single_line_comment_style' => [ - 'comment_types' => ['hash'], - ], - 'heredoc_indentation' => true, - 'heredoc_to_nowdoc' => true, - 'implode_call' => true, - 'is_null' => true, - 'linebreak_after_opening_tag' => true, - 'list_syntax' => [ - 'syntax' => 'short', - ], - 'logical_operators' => true, - 'method_chaining_indentation' => true, - 'modernize_types_casting' => true, - 'multiline_whitespace_before_semicolons' => true, - 'no_alias_functions' => true, - 'no_alternative_syntax' => true, - 'no_null_property_initialization' => true, - 'no_php4_constructor' => true, - 'echo_tag_syntax' => [ - 'format' => 'long', - ], - 'no_superfluous_elseif' => true, - 'no_unneeded_final_method' => true, - 'no_unreachable_default_argument_value' => true, - 'no_unset_cast' => true, - 'no_unset_on_property' => true, - 'no_useless_else' => true, - 'ordered_class_elements' => true, - 'ordered_interfaces' => true, - 'php_unit_expectation' => true, - 'php_unit_method_casing' => [ - 'case' => 'snake_case', - ], - 'php_unit_mock_short_will_return' => true, - 'php_unit_namespaced' => true, - 'php_unit_no_expectation_annotation' => true, - 'php_unit_set_up_tear_down_visibility' => true, - 'php_unit_strict' => true, - 'php_unit_test_annotation' => [ - 'style' => 'annotation', - ], - 'php_unit_test_case_static_method_calls' => [ - 'call_type' => 'self', - ], - 'pow_to_exponentiation' => true, - 'protected_to_private' => true, - 'psr_autoloading' => true, - 'self_accessor' => true, - 'set_type_to_cast' => true, - 'simple_to_complex_string_variable' => true, - 'static_lambda' => true, - 'strict_comparison' => true, - 'strict_param' => true, - 'ternary_to_null_coalescing' => true, - 'visibility_required' => [ - 'elements' => ['property', 'const'], - ], - 'void_return' => true, - 'declare_strict_types' => true, - ]) - ->setUsingCache(true) - ->setFinder($finder) +return \Ssc\Cs\ConfigBuilder::forPath(__DIR__) + ->withLicenseHeader(\Ssc\Cs\Factory\LicenseHeader::forPackage( + name: 'ssc/lib', + owners: [[ + 'name' => 'Loïc Faugeron', + 'email' => 'faugeron.loic@gmail.com', + ]], + )) + ->build() ; diff --git a/composer.json b/composer.json index 242e6b1..005b33a 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "friendsofphp/php-cs-fixer": "^3.65", "phpspec/phpspec": "^7.5", "phpspec/prophecy-phpunit": "^2.3", - "phpunit/phpunit": "^10.5.38", + "phpunit/phpunit": "^10.5.39", "ssc/cs": "*@dev", "symplify/monorepo-builder": "^11.2.22" }, diff --git a/packages/cs/README.md b/packages/cs/README.md index 485812a..3d63b1a 100644 --- a/packages/cs/README.md +++ b/packages/cs/README.md @@ -8,7 +8,7 @@ with default for the SSC projects. ## Installation ```console -composer require ssc/cs +composer require --dev ssc/cs ``` Configure in `.php-cs-fixer.dist.php`: diff --git a/packages/cs/composer.json b/packages/cs/composer.json index a0f1700..fdeab2d 100644 --- a/packages/cs/composer.json +++ b/packages/cs/composer.json @@ -17,6 +17,12 @@ "php": "^8.3", "friendsofphp/php-cs-fixer": "^3.65" }, + "repositories": [ + { + "type": "path", + "url": "../*" + } + ], "autoload": { "psr-4": { "Ssc\\Cs\\": "src" diff --git a/packages/exception/.php-cs-fixer.dist.php b/packages/exception/.php-cs-fixer.dist.php new file mode 100644 index 0000000..d4448a0 --- /dev/null +++ b/packages/exception/.php-cs-fixer.dist.php @@ -0,0 +1,12 @@ +withLicenseHeader(\Ssc\Cs\Factory\LicenseHeader::forPackage( + name: 'ssc/lib', + owners: [[ + 'name' => 'Loïc Faugeron', + 'email' => 'faugeron.loic@gmail.com', + ]], + )) + ->build() +; diff --git a/packages/exception/bin/test.sh b/packages/exception/bin/test.sh new file mode 100755 index 0000000..85da4ef --- /dev/null +++ b/packages/exception/bin/test.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +SHORT_HELP="$0 [-h] [-f]'" + +while getopts ":hf" opt; do + case $opt in + h) + echo 'Usage:' + echo " $SHORT_HELP" + echo '' + echo 'Options:' + echo ' -f Fix coding style' + echo '' + exit 0 + ;; + f) + echo '' + echo '// Fixing CS...' + echo '' + + vendor/bin/php-cs-fixer fix --allow-risky=yes + exit 0 + ;; + \?) + echo '' >&2 + echo " [KO] The \"-$OPTARG\" option does not exist" >&2 + echo '' >&2 + echo " $SHORT_HELP" >&2 + echo '' >&2 + exit 1 + ;; + esac +done +unset SHORT_HELP + +echo '' +echo '// Running tests...' + +composer --quiet dump --optimize + +vendor/bin/phpspec --no-interaction run -fdot && \ +# vendor/bin/phpunit && \ + vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run diff --git a/packages/exception/composer.json b/packages/exception/composer.json index 2c8e820..adc327b 100644 --- a/packages/exception/composer.json +++ b/packages/exception/composer.json @@ -18,8 +18,15 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.65", - "phpspec/phpspec": "^7.5" + "phpspec/phpspec": "^7.5", + "ssc/cs": "*@dev" }, + "repositories": [ + { + "type": "path", + "url": "../*" + } + ], "autoload": { "psr-4": { "Ssc\\Exception\\": "src" From 2f535487cf9610a16f62f1e6ba0442341581c3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faugeron?= Date: Sat, 14 Dec 2024 18:38:47 +0000 Subject: [PATCH 2/5] Fixed CS --- monorepo-builder.php | 9 +++++++++ packages/cs/src/Factory/LicenseHeader.php | 4 ++-- packages/cs/src/Factory/Rules.php | 2 +- packages/exception/spec/ClientErrorExceptionSpec.php | 2 +- packages/exception/spec/ForbiddenExceptionSpec.php | 2 +- packages/exception/spec/NotFoundExceptionSpec.php | 2 +- packages/exception/spec/ServerErrorExceptionSpec.php | 2 +- packages/exception/spec/SscExceptionSpec.php | 2 +- packages/exception/spec/UnauthorizedExceptionSpec.php | 2 +- .../exception/spec/ValidationFailedExceptionSpec.php | 2 +- packages/exception/src/ClientErrorException.php | 2 +- packages/exception/src/ForbiddenException.php | 2 +- packages/exception/src/NotFoundException.php | 2 +- packages/exception/src/ServerErrorException.php | 2 +- packages/exception/src/SscException.php | 2 +- packages/exception/src/UnauthorizedException.php | 2 +- packages/exception/src/ValidationFailedException.php | 2 +- 17 files changed, 26 insertions(+), 17 deletions(-) diff --git a/monorepo-builder.php b/monorepo-builder.php index b3c0c42..f7ae68a 100644 --- a/monorepo-builder.php +++ b/monorepo-builder.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); use Symplify\MonorepoBuilder\Config\MBConfig; diff --git a/packages/cs/src/Factory/LicenseHeader.php b/packages/cs/src/Factory/LicenseHeader.php index df17dd1..a212929 100644 --- a/packages/cs/src/Factory/LicenseHeader.php +++ b/packages/cs/src/Factory/LicenseHeader.php @@ -17,9 +17,9 @@ class LicenseHeader { private const DEFAULT_TEMPLATE = <<<'TPL' This file is part of the {{ package_name }} package. - + (c) {{ owner_name }} <{{ owner_email }}> - + For the full copyright and license information, please view the LICENSE file that was distributed with this source code. TPL; diff --git a/packages/cs/src/Factory/Rules.php b/packages/cs/src/Factory/Rules.php index 6631d36..9cc7b8b 100644 --- a/packages/cs/src/Factory/Rules.php +++ b/packages/cs/src/Factory/Rules.php @@ -47,7 +47,7 @@ public static function make(): array 'elements' => ['property', 'const'], ], - // control_structures + // control_structures 'no_superfluous_elseif' => true, // SSC 'no_useless_else' => true, // SSC diff --git a/packages/exception/spec/ClientErrorExceptionSpec.php b/packages/exception/spec/ClientErrorExceptionSpec.php index 1ccb028..2ed2a2d 100644 --- a/packages/exception/spec/ClientErrorExceptionSpec.php +++ b/packages/exception/spec/ClientErrorExceptionSpec.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/spec/ForbiddenExceptionSpec.php b/packages/exception/spec/ForbiddenExceptionSpec.php index ac3f8af..fe1980c 100644 --- a/packages/exception/spec/ForbiddenExceptionSpec.php +++ b/packages/exception/spec/ForbiddenExceptionSpec.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/spec/NotFoundExceptionSpec.php b/packages/exception/spec/NotFoundExceptionSpec.php index f897ed0..39b6831 100644 --- a/packages/exception/spec/NotFoundExceptionSpec.php +++ b/packages/exception/spec/NotFoundExceptionSpec.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/spec/ServerErrorExceptionSpec.php b/packages/exception/spec/ServerErrorExceptionSpec.php index 59f6bde..398b19a 100644 --- a/packages/exception/spec/ServerErrorExceptionSpec.php +++ b/packages/exception/spec/ServerErrorExceptionSpec.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/spec/SscExceptionSpec.php b/packages/exception/spec/SscExceptionSpec.php index feb6c33..743202a 100644 --- a/packages/exception/spec/SscExceptionSpec.php +++ b/packages/exception/spec/SscExceptionSpec.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/spec/UnauthorizedExceptionSpec.php b/packages/exception/spec/UnauthorizedExceptionSpec.php index 1cd1edb..d87f685 100644 --- a/packages/exception/spec/UnauthorizedExceptionSpec.php +++ b/packages/exception/spec/UnauthorizedExceptionSpec.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/spec/ValidationFailedExceptionSpec.php b/packages/exception/spec/ValidationFailedExceptionSpec.php index 1811498..0b554c9 100644 --- a/packages/exception/spec/ValidationFailedExceptionSpec.php +++ b/packages/exception/spec/ValidationFailedExceptionSpec.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/src/ClientErrorException.php b/packages/exception/src/ClientErrorException.php index 280f4a1..443f028 100644 --- a/packages/exception/src/ClientErrorException.php +++ b/packages/exception/src/ClientErrorException.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/src/ForbiddenException.php b/packages/exception/src/ForbiddenException.php index 356ca3a..1ca3d9a 100644 --- a/packages/exception/src/ForbiddenException.php +++ b/packages/exception/src/ForbiddenException.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/src/NotFoundException.php b/packages/exception/src/NotFoundException.php index 53ff407..89ccd56 100644 --- a/packages/exception/src/NotFoundException.php +++ b/packages/exception/src/NotFoundException.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/src/ServerErrorException.php b/packages/exception/src/ServerErrorException.php index c156636..89f10f9 100644 --- a/packages/exception/src/ServerErrorException.php +++ b/packages/exception/src/ServerErrorException.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/src/SscException.php b/packages/exception/src/SscException.php index 041c5ff..beca6ce 100644 --- a/packages/exception/src/SscException.php +++ b/packages/exception/src/SscException.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/src/UnauthorizedException.php b/packages/exception/src/UnauthorizedException.php index d1abe35..34d1c1c 100644 --- a/packages/exception/src/UnauthorizedException.php +++ b/packages/exception/src/UnauthorizedException.php @@ -1,6 +1,6 @@ diff --git a/packages/exception/src/ValidationFailedException.php b/packages/exception/src/ValidationFailedException.php index c8a40a7..98b7b9f 100644 --- a/packages/exception/src/ValidationFailedException.php +++ b/packages/exception/src/ValidationFailedException.php @@ -1,6 +1,6 @@ From 4d987558f05929334596cfe3ea2a28f638eb6734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faugeron?= Date: Sat, 14 Dec 2024 18:42:34 +0000 Subject: [PATCH 3/5] Fixed documentation typos --- CONTRIBUTING.md | 4 ++-- README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f882917..1c50086 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ git push -f origin Your pull request will be automatically updated. -## Monorepo Maintainance +## Monorepo Maintenance Instead of managing X packages each in their own repo, they're all being managed in `ssc/lib`, as a monorepo. @@ -63,7 +63,7 @@ To help maintain the monorepo, we use the tool [monorepo-builder](https://github ### bump-interdependency -When releasing a version for the monorepo (eg `4.0`), and we need tu bump the packages that depend on it to version `^4.0`: +When releasing a version for the monorepo (eg `4.0`), and we need to bump the packages that depend on it to version `^4.0`: ```console vendor/bin/monorepo-builder bump-interdependency "^4.0" diff --git a/README.md b/README.md index 45ba6f8..a3d75a5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Decoupled PHP libraries. -> _Note_: `ssc/lib` is a **monorepo**, it is not possbile to install it in your projects. +> _Note_: `ssc/lib` is a **monorepo**, it is not possible to install it in your projects. > It contains the code for multiple packages, this is where the changes for these are done. > Each package can be installed, individually, in your projects (eg `composer require `ssc/`). From c7f0af620254b1a132a6c5f98546bf2be8c808f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faugeron?= Date: Sat, 14 Dec 2024 18:49:48 +0000 Subject: [PATCH 4/5] Updated couscous --- CONTRIBUTING.md | 19 ++++++++++++++++++- couscous.yml | 6 ++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c50086..1d880b4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -116,14 +116,18 @@ Next, create a new folder in `./packages` with the following tree structure: ``` ./packages/exception/ +├── .gitignore +├── .php-cs-fixer.dist.php ├── composer.json +├── phpspec.yml.dist ├── LICENSE ├── README.md +├── bin/test.sh ├── spec/ └── src/ ``` -Then, add a section in the root `phpspec.yml`: +Then, add a section in the root `phpspec.yml.dist`: ```yaml suites: @@ -182,6 +186,19 @@ throw NotFoundException::make('No Product found for ID 42') [...] ``` +Almost done, make sure to update couscous: + +```yaml +menu: + items: + home: + text: Home + relativeUrl: + exception: + text: exception + relativeUrl: packages/exception/README.html +`` + Finally, add library to `.github/workflows/split_monorepo.yaml`: ```yaml diff --git a/couscous.yml b/couscous.yml index b466b81..d005647 100644 --- a/couscous.yml +++ b/couscous.yml @@ -33,3 +33,9 @@ menu: home: text: Home relativeUrl: + cs: + text: cs + relativeUrl: packages/cs/README.html + exception: + text: exception + relativeUrl: packages/exception/README.html From 8de139bbbb906439518782a03033c1b7627fd42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faugeron?= Date: Sat, 14 Dec 2024 18:51:35 +0000 Subject: [PATCH 5/5] Prepared 0.0.5 release --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index db608df..d62f4a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## 0.0.5: Tidied up project + +* Configured and Applied `ssc/cs` in all of `ssc/lib` +* Fixed documentation typo +* Updated couscous + ## 0.0.4: Created `ssc/cs` Shared Coding Standards configuration, for SSC.