From 6081d4dc2b3b4fb26a019ae3ffde059745345a60 Mon Sep 17 00:00:00 2001 From: Guido Faust Date: Fri, 13 Feb 2026 12:45:09 +0100 Subject: [PATCH 1/5] feat: Add scripts section to composer.json for improved development workflow. --- composer.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/composer.json b/composer.json index bb417bb..2a87c73 100644 --- a/composer.json +++ b/composer.json @@ -28,5 +28,21 @@ "psr-4": { "PHPMolecules\\DDD\\": "tests/DDD" } + }, + "scripts": { + "unit": "phpunit --colors=always", + "stan": "phpstan analyse", + "cs-check": "phpcs", + "cs-fix": "phpcbf", + "composer-audit": "composer audit", + "fix": [ + "@cs-fix" + ], + "test": [ + "@unit", + "@cs-check", + "@stan", + "@composer-audit" + ] } } From aab92c50ee6e86d1271f6002a3e5ad50f8941448 Mon Sep 17 00:00:00 2001 From: Guido Faust Date: Fri, 13 Feb 2026 12:47:10 +0100 Subject: [PATCH 2/5] feat: Enhance README with detailed development scripts for testing and code quality --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 4ef4529..2955da9 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,25 @@ To use phpMolecules in your project just install it with Composer from Packagist composer require xmolecules/phpmolecules ``` +## Development Scripts + +This project includes several Composer scripts to assist with development, testing, and code quality checks. You can run these scripts using `composer run `. + +- `unit`: Runs PHPUnit tests with colored output. +- `stan`: Performs static analysis using PHPStan. +- `cs-check`: Checks code style compliance using PHP CodeSniffer. +- `cs-fix`: Automatically fixes code style issues using PHP CodeSniffer. +- `composer-audit`: Runs Composer audit to check for security vulnerabilities in dependencies. +- `fix`: Alias for `cs-fix` to fix code style issues. +- `test`: Runs a comprehensive test suite including unit tests, code style checks, static analysis, and security audit. + +Example usage: + +```fish +composer run test +composer run fix +``` + ## Release Instructions Create a new Git version tag and push it: From 64f0d130851854823bae7a0c842ab2c371366a27 Mon Sep 17 00:00:00 2001 From: Guido Faust Date: Fri, 13 Feb 2026 16:30:30 +0100 Subject: [PATCH 3/5] feat: Add rector configuration and enhance composer scripts for improved code quality checks --- composer.json | 11 ++++++++--- rector.php | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 rector.php diff --git a/composer.json b/composer.json index 2a87c73..1a109a2 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,8 @@ "require-dev": { "phpunit/phpunit": "^9.6", "phpstan/phpstan": "^1.10", - "squizlabs/php_codesniffer": "^3.7" + "squizlabs/php_codesniffer": "^3.7", + "rector/rector": "^1.2" }, "autoload": { "psr-4": { @@ -32,16 +33,20 @@ "scripts": { "unit": "phpunit --colors=always", "stan": "phpstan analyse", - "cs-check": "phpcs", + "cs-check": "phpcs --version && phpcs -p --cache", "cs-fix": "phpcbf", "composer-audit": "composer audit", + "rector": "vendor/bin/rector process --dry-run", + "rector-fix": "vendor/bin/rector process", "fix": [ - "@cs-fix" + "@cs-fix", + "@rector-fix" ], "test": [ "@unit", "@cs-check", "@stan", + "@rector", "@composer-audit" ] } diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..d71f9d4 --- /dev/null +++ b/rector.php @@ -0,0 +1,26 @@ +withPaths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->withPhpSets(php80: true) + ->withPhpVersion(PhpVersion::PHP_80) + ->withAttributesSets() + ->withPreparedSets( + deadCode: true, + codeQuality: true, + codingStyle: true, + naming: true, + privatization: true, + rectorPreset: true, + typeDeclarations: true, + earlyReturn: true, + strictBooleans: true + ); From f0039a691dbf169b9c7b29549d8bc72071247c75 Mon Sep 17 00:00:00 2001 From: Guido Faust Date: Fri, 13 Feb 2026 16:32:34 +0100 Subject: [PATCH 4/5] docs: Enhance development scripts description in README with improved code style checks and Rector integration --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2955da9..c2ce304 100644 --- a/README.md +++ b/README.md @@ -53,11 +53,13 @@ This project includes several Composer scripts to assist with development, testi - `unit`: Runs PHPUnit tests with colored output. - `stan`: Performs static analysis using PHPStan. -- `cs-check`: Checks code style compliance using PHP CodeSniffer. +- `cs-check`: Checks code style compliance using PHP CodeSniffer, including version display and caching for performance. - `cs-fix`: Automatically fixes code style issues using PHP CodeSniffer. - `composer-audit`: Runs Composer audit to check for security vulnerabilities in dependencies. -- `fix`: Alias for `cs-fix` to fix code style issues. -- `test`: Runs a comprehensive test suite including unit tests, code style checks, static analysis, and security audit. +- `rector`: Runs Rector in dry-run mode to check for potential code improvements. +- `rector-fix`: Runs Rector to apply code improvements. +- `fix`: Runs both code style fixes and Rector improvements. +- `test`: Runs a comprehensive test suite including unit tests, code style checks, static analysis, Rector checks, and security audit. Example usage: From 730e14da576e6cf2d387a927982c21d3472a6db6 Mon Sep 17 00:00:00 2001 From: Guido Faust Date: Fri, 13 Feb 2026 16:33:03 +0100 Subject: [PATCH 5/5] refactor: Improve attribute reflection in DDDAttributesTest for consistency and clarity --- tests/DDD/Attribute/DDDAttributeTests.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/DDD/Attribute/DDDAttributeTests.php b/tests/DDD/Attribute/DDDAttributeTests.php index bc5947a..bd96e9c 100644 --- a/tests/DDD/Attribute/DDDAttributeTests.php +++ b/tests/DDD/Attribute/DDDAttributeTests.php @@ -20,22 +20,23 @@ class BankAccount private IBAN $iban; /* @phpstan-ignore-line */ } -class DDDAttributesTest extends TestCase +final class DDDAttributesTest extends TestCase { public function testValueObjectAttribute(): void { - $reflector = new ReflectionClass(IBAN::class); - $attributes = $reflector->getAttributes(); + $reflectionClass = new ReflectionClass(IBAN::class); + $attributes = $reflectionClass->getAttributes(); $this->assertCount(1, $attributes); - $this->assertEquals("PHPMolecules\DDD\Attribute\ValueObject", $attributes[0]->getName()); + $this->assertEquals(\PHPMolecules\DDD\Attribute\ValueObject::class, $attributes[0]->getName()); } public function testEntityAttributes(): void { - $reflector = new ReflectionClass(BankAccount::class); - $attributes = $reflector->getAttributes(); + $reflectionClass = new ReflectionClass(BankAccount::class); + $attributes = $reflectionClass->getAttributes(); $this->assertCount(1, $attributes); - $this->assertEquals("PHPMolecules\DDD\Attribute\Entity", $attributes[0]->getName()); + $this->assertEquals(\PHPMolecules\DDD\Attribute\Entity::class, $attributes[0]->getName()); } } + // phpcs:enable