From 3c2446e734a2faf9c9573bd2e8992968e4733543 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 18 May 2026 17:23:38 +0900 Subject: [PATCH 1/2] Introduce WebFormModule and keep AuraInputModule as alias Add Ray\WebFormModule\WebFormModule whose name lines up with the package (ray/web-form-module) and namespace (Ray\WebFormModule), so the public module class no longer leaks the underlying Aura.Input implementation detail. Ray\WebFormModule\AuraInputModule is preserved as a thin subclass of WebFormModule so existing applications that install 'new AuraInputModule()' continue to work unchanged. The interceptor test keeps using AuraInputModule to lock in that compatibility. Update README, README.JA, the CSRF demo, and the fake module used in tests to install the new WebFormModule. Add CHANGELOG entry for 1.0.1. --- CHANGELOG.md | 15 +++++++++++ README.JA.md | 11 +++++--- README.md | 12 ++++++--- docs/demo/1.csrf/MyModule.php | 2 +- src/AuraInputModule.php | 46 ++++++---------------------------- src/WebFormModule.php | 46 ++++++++++++++++++++++++++++++++++ tests/Fake/FakeModule.php | 2 +- tests/WebFormModuleTest.php | 47 +++++++++++++++++++++++++++++++++++ 8 files changed, 133 insertions(+), 48 deletions(-) create mode 100644 src/WebFormModule.php create mode 100644 tests/WebFormModuleTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 36d4c95..e0f7962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.1] - 2026-05-18 + +### Added + +- `Ray\WebFormModule\WebFormModule` — module class whose name matches the + package and namespace. Use this in new code. + +### Deprecated + +- `Ray\WebFormModule\AuraInputModule` is now a thin subclass of + `WebFormModule` kept for backwards compatibility. Existing applications + that install `new AuraInputModule()` continue to work without changes, + but should migrate to `new WebFormModule()`. + ## [1.0.0] - 2026-05-17 ### Changed @@ -75,5 +89,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 See git history for changes prior to 1.0.0. +[1.0.1]: https://github.com/ray-di/Ray.WebFormModule/compare/1.0.0...1.0.1 [1.0.0]: https://github.com/ray-di/Ray.WebFormModule/compare/0.6.0...1.0.0 [0.6.0]: https://github.com/ray-di/Ray.WebFormModule/releases/tag/0.6.0 diff --git a/README.JA.md b/README.JA.md index c8d4bd6..1d5c2f3 100644 --- a/README.JA.md +++ b/README.JA.md @@ -18,16 +18,19 @@ Ray.WebFormModuleはアスペクト指向でフォームのバリデーション ```php use Ray\Di\AbstractModule; -use Ray\WebFormModule\AuraInputModule; +use Ray\WebFormModule\WebFormModule; class AppModule extends AbstractModule { protected function configure() { - $this->install(new AuraInputModule); + $this->install(new WebFormModule()); } } ``` + +> 互換性のため `Ray\WebFormModule\AuraInputModule` クラスも `WebFormModule` の薄い +> サブクラスとして残されています。新規コードでは `WebFormModule` を使ってください。 ## Usage ### Form @@ -201,8 +204,8 @@ class FakeVndErrorModule extends AbstractModule { protected function configure() { - $this->install(new AuraInputModule); - $this->override(new FormVndErrorModule); + $this->install(new WebFormModule()); + $this->override(new FormVndErrorModule()); } ``` diff --git a/README.md b/README.md index b880d99..274dca2 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,20 @@ An aspect oriented web form module powered by [Aura.Input](https://github.com/au ```php use Ray\Di\AbstractModule; -use Ray\WebFormModule\AuraInputModule; +use Ray\WebFormModule\WebFormModule; class AppModule extends AbstractModule { protected function configure() { - $this->install(new AuraInputModule); + $this->install(new WebFormModule()); } } ``` + +> The legacy `Ray\WebFormModule\AuraInputModule` class is still available as a thin +> subclass of `WebFormModule` for backwards compatibility. New code should prefer +> `WebFormModule`. ## Usage ### Form class @@ -202,8 +206,8 @@ class FakeVndErrorModule extends AbstractModule { protected function configure() { - $this->install(new AuraInputModule); - $this->override(new FormVndErrorModule); + $this->install(new WebFormModule()); + $this->override(new FormVndErrorModule()); } ``` A `Ray\WebFormModule\Exception\ValidationException` will be thrown. diff --git a/docs/demo/1.csrf/MyModule.php b/docs/demo/1.csrf/MyModule.php index 4e35dba..4dd9905 100644 --- a/docs/demo/1.csrf/MyModule.php +++ b/docs/demo/1.csrf/MyModule.php @@ -7,7 +7,7 @@ class MyModule extends AbstractModule { protected function configure() { - $this->install(new AuraInputModule); + $this->install(new WebFormModule()); $this->bind(FormInterface::class)->annotatedWith('contact_form')->to(ContactForm::class); } } diff --git a/src/AuraInputModule.php b/src/AuraInputModule.php index dc09b81..11da61d 100644 --- a/src/AuraInputModule.php +++ b/src/AuraInputModule.php @@ -4,43 +4,13 @@ namespace Ray\WebFormModule; -use Aura\Filter\FilterFactory; -use Aura\Html\HelperLocatorFactory; -use Aura\Input\AntiCsrfInterface; -use Aura\Input\Builder; -use Aura\Input\BuilderInterface; -use Aura\Input\Filter; -use Aura\Input\FilterInterface; -use Ray\AuraSessionModule\AuraSessionModule; -use Ray\Di\AbstractModule; -use Ray\Di\Scope; -use Ray\WebFormModule\Annotation\FormValidation; -use Ray\WebFormModule\Annotation\InputValidation; - -/** @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AuraInputModule extends AbstractModule +/** + * Backwards-compatible alias for {@see WebFormModule}. + * + * Use {@see WebFormModule} in new code. This class is kept so existing + * applications that install `new AuraInputModule()` continue to work + * without changes. + */ +class AuraInputModule extends WebFormModule { - /** {@inheritDoc} */ - protected function configure() - { - $this->install(new AuraSessionModule()); - $this->bind(BuilderInterface::class)->to(Builder::class); - $this->bind(FilterInterface::class)->to(Filter::class); - $this->bind(AntiCsrfInterface::class)->to(AntiCsrf::class)->in(Scope::SINGLETON); - $this->bind(FailureHandlerInterface::class)->to(OnFailureMethodHandler::class); - $this->bind(FailureHandlerInterface::class) - ->annotatedWith('vnd_error')->to(VndErrorHandler::class)->in(Scope::SINGLETON); - $this->bind(HelperLocatorFactory::class); - $this->bind(FilterFactory::class); - $this->bindInterceptor( - $this->matcher->any(), - $this->matcher->annotatedWith(InputValidation::class), - [InputValidationInterceptor::class], - ); - $this->bindInterceptor( - $this->matcher->any(), - $this->matcher->annotatedWith(FormValidation::class), - [AuraInputInterceptor::class], - ); - } } diff --git a/src/WebFormModule.php b/src/WebFormModule.php new file mode 100644 index 0000000..d76106f --- /dev/null +++ b/src/WebFormModule.php @@ -0,0 +1,46 @@ +install(new AuraSessionModule()); + $this->bind(BuilderInterface::class)->to(Builder::class); + $this->bind(FilterInterface::class)->to(Filter::class); + $this->bind(AntiCsrfInterface::class)->to(AntiCsrf::class)->in(Scope::SINGLETON); + $this->bind(FailureHandlerInterface::class)->to(OnFailureMethodHandler::class); + $this->bind(FailureHandlerInterface::class) + ->annotatedWith('vnd_error')->to(VndErrorHandler::class)->in(Scope::SINGLETON); + $this->bind(HelperLocatorFactory::class); + $this->bind(FilterFactory::class); + $this->bindInterceptor( + $this->matcher->any(), + $this->matcher->annotatedWith(InputValidation::class), + [InputValidationInterceptor::class], + ); + $this->bindInterceptor( + $this->matcher->any(), + $this->matcher->annotatedWith(FormValidation::class), + [AuraInputInterceptor::class], + ); + } +} diff --git a/tests/Fake/FakeModule.php b/tests/Fake/FakeModule.php index 2e51456..f800aa6 100644 --- a/tests/Fake/FakeModule.php +++ b/tests/Fake/FakeModule.php @@ -10,7 +10,7 @@ class FakeModule extends AbstractModule protected function configure() { $this->bind(Phpfunc::class)->to(FakePhpFunc::class); - $this->install(new AuraInputModule); + $this->install(new WebFormModule()); $this->bind(FormInterface::class)->annotatedWith('contact_form')->to(FakeForm::class); } } diff --git a/tests/WebFormModuleTest.php b/tests/WebFormModuleTest.php new file mode 100644 index 0000000..6254037 --- /dev/null +++ b/tests/WebFormModuleTest.php @@ -0,0 +1,47 @@ +install(new WebFormModule()); + $this->bind(FormInterface::class)->annotatedWith('contact_form')->to(FakeForm::class); + } + }, __DIR__ . '/tmp'); + $controller = $injector->getInstance(FakeController::class); + $this->assertInstanceOf(WeavedInterface::class, $controller); + } + + public function testAuraInputModuleIsAliasOfWebFormModule() + { + $this->assertInstanceOf(WebFormModule::class, new AuraInputModule()); + } + + public function testExceptionOnFailure() + { + $this->expectException(ValidationException::class); + $injector = new Injector(new class () extends AbstractModule { + protected function configure() + { + $this->install(new WebFormModule()); + $this->bind(FormInterface::class)->annotatedWith('contact_form')->to(FakeForm::class); + } + }, __DIR__ . '/tmp'); + /** @var FakeInputValidationController $controller */ + $controller = $injector->getInstance(FakeInputValidationController::class); + $controller->createAction(''); + } +} From c813d8d82d3b231d599375f56ea206212f6fdc8b Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 19 May 2026 00:20:39 +0900 Subject: [PATCH 2/2] ci: suppress Psalm false positives from AbstractModule inheritance chain When AuraInputModule extends WebFormModule extends AbstractModule, Psalm fails to resolve Ray\Di\Bind and Ray\Aop\Pointcut signatures inside the inherited bindInterceptor() body. The vendor code itself is correct and tests pass; this only affects static analysis of the two-level inheritance chain introduced for backwards compatibility. --- psalm.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/psalm.xml b/psalm.xml index 18f8e1d..cd73652 100644 --- a/psalm.xml +++ b/psalm.xml @@ -27,5 +27,21 @@ + + + + + + + + + + +