Skip to content

Commit a1fba3d

Browse files
authored
Merge pull request #29 from ray-di/rename-to-webform-module
Introduce WebFormModule and keep AuraInputModule as alias
2 parents 70b8ad5 + c813d8d commit a1fba3d

9 files changed

Lines changed: 149 additions & 48 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.1] - 2026-05-18
9+
10+
### Added
11+
12+
- `Ray\WebFormModule\WebFormModule` — module class whose name matches the
13+
package and namespace. Use this in new code.
14+
15+
### Deprecated
16+
17+
- `Ray\WebFormModule\AuraInputModule` is now a thin subclass of
18+
`WebFormModule` kept for backwards compatibility. Existing applications
19+
that install `new AuraInputModule()` continue to work without changes,
20+
but should migrate to `new WebFormModule()`.
21+
822
## [1.0.0] - 2026-05-17
923

1024
### Changed
@@ -75,5 +89,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7589

7690
See git history for changes prior to 1.0.0.
7791

92+
[1.0.1]: https://github.com/ray-di/Ray.WebFormModule/compare/1.0.0...1.0.1
7893
[1.0.0]: https://github.com/ray-di/Ray.WebFormModule/compare/0.6.0...1.0.0
7994
[0.6.0]: https://github.com/ray-di/Ray.WebFormModule/releases/tag/0.6.0

README.JA.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ Ray.WebFormModuleはアスペクト指向でフォームのバリデーション
1818

1919
```php
2020
use Ray\Di\AbstractModule;
21-
use Ray\WebFormModule\AuraInputModule;
21+
use Ray\WebFormModule\WebFormModule;
2222

2323
class AppModule extends AbstractModule
2424
{
2525
protected function configure()
2626
{
27-
$this->install(new AuraInputModule);
27+
$this->install(new WebFormModule());
2828
}
2929
}
3030
```
31+
32+
> 互換性のため `Ray\WebFormModule\AuraInputModule` クラスも `WebFormModule` の薄い
33+
> サブクラスとして残されています。新規コードでは `WebFormModule` を使ってください。
3134
## Usage
3235

3336
### Form
@@ -201,8 +204,8 @@ class FakeVndErrorModule extends AbstractModule
201204
{
202205
protected function configure()
203206
{
204-
$this->install(new AuraInputModule);
205-
$this->override(new FormVndErrorModule);
207+
$this->install(new WebFormModule());
208+
$this->override(new FormVndErrorModule());
206209
}
207210
```
208211

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@ An aspect oriented web form module powered by [Aura.Input](https://github.com/au
1818

1919
```php
2020
use Ray\Di\AbstractModule;
21-
use Ray\WebFormModule\AuraInputModule;
21+
use Ray\WebFormModule\WebFormModule;
2222

2323
class AppModule extends AbstractModule
2424
{
2525
protected function configure()
2626
{
27-
$this->install(new AuraInputModule);
27+
$this->install(new WebFormModule());
2828
}
2929
}
3030
```
31+
32+
> The legacy `Ray\WebFormModule\AuraInputModule` class is still available as a thin
33+
> subclass of `WebFormModule` for backwards compatibility. New code should prefer
34+
> `WebFormModule`.
3135
## Usage
3236

3337
### Form class
@@ -202,8 +206,8 @@ class FakeVndErrorModule extends AbstractModule
202206
{
203207
protected function configure()
204208
{
205-
$this->install(new AuraInputModule);
206-
$this->override(new FormVndErrorModule);
209+
$this->install(new WebFormModule());
210+
$this->override(new FormVndErrorModule());
207211
}
208212
```
209213
A `Ray\WebFormModule\Exception\ValidationException` will be thrown.

docs/demo/1.csrf/MyModule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class MyModule extends AbstractModule
77
{
88
protected function configure()
99
{
10-
$this->install(new AuraInputModule);
10+
$this->install(new WebFormModule());
1111
$this->bind(FormInterface::class)->annotatedWith('contact_form')->to(ContactForm::class);
1212
}
1313
}

psalm.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,21 @@
2727
<file name="src/AntiCsrf.php" />
2828
</errorLevel>
2929
</MoreSpecificImplementedParamType>
30+
<!--
31+
Psalm misresolves Ray\Di\Bind and Ray\Aop\Pointcut signatures inside
32+
Ray\Di\AbstractModule::bindInterceptor() when AbstractModule is reached
33+
through a two-level inheritance chain (AuraInputModule -> WebFormModule
34+
-> AbstractModule). The vendor code itself is correct.
35+
-->
36+
<InvalidArgument>
37+
<errorLevel type="suppress">
38+
<referencedFunction name="Ray\Aop\Pointcut::__construct" />
39+
</errorLevel>
40+
</InvalidArgument>
41+
<TooManyArguments>
42+
<errorLevel type="suppress">
43+
<referencedFunction name="Ray\Di\Bind::__construct" />
44+
</errorLevel>
45+
</TooManyArguments>
3046
</issueHandlers>
3147
</psalm>

src/AuraInputModule.php

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,13 @@
44

55
namespace Ray\WebFormModule;
66

7-
use Aura\Filter\FilterFactory;
8-
use Aura\Html\HelperLocatorFactory;
9-
use Aura\Input\AntiCsrfInterface;
10-
use Aura\Input\Builder;
11-
use Aura\Input\BuilderInterface;
12-
use Aura\Input\Filter;
13-
use Aura\Input\FilterInterface;
14-
use Ray\AuraSessionModule\AuraSessionModule;
15-
use Ray\Di\AbstractModule;
16-
use Ray\Di\Scope;
17-
use Ray\WebFormModule\Annotation\FormValidation;
18-
use Ray\WebFormModule\Annotation\InputValidation;
19-
20-
/** @SuppressWarnings(PHPMD.CouplingBetweenObjects) */
21-
class AuraInputModule extends AbstractModule
7+
/**
8+
* Backwards-compatible alias for {@see WebFormModule}.
9+
*
10+
* Use {@see WebFormModule} in new code. This class is kept so existing
11+
* applications that install `new AuraInputModule()` continue to work
12+
* without changes.
13+
*/
14+
class AuraInputModule extends WebFormModule
2215
{
23-
/** {@inheritDoc} */
24-
protected function configure()
25-
{
26-
$this->install(new AuraSessionModule());
27-
$this->bind(BuilderInterface::class)->to(Builder::class);
28-
$this->bind(FilterInterface::class)->to(Filter::class);
29-
$this->bind(AntiCsrfInterface::class)->to(AntiCsrf::class)->in(Scope::SINGLETON);
30-
$this->bind(FailureHandlerInterface::class)->to(OnFailureMethodHandler::class);
31-
$this->bind(FailureHandlerInterface::class)
32-
->annotatedWith('vnd_error')->to(VndErrorHandler::class)->in(Scope::SINGLETON);
33-
$this->bind(HelperLocatorFactory::class);
34-
$this->bind(FilterFactory::class);
35-
$this->bindInterceptor(
36-
$this->matcher->any(),
37-
$this->matcher->annotatedWith(InputValidation::class),
38-
[InputValidationInterceptor::class],
39-
);
40-
$this->bindInterceptor(
41-
$this->matcher->any(),
42-
$this->matcher->annotatedWith(FormValidation::class),
43-
[AuraInputInterceptor::class],
44-
);
45-
}
4616
}

src/WebFormModule.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Ray\WebFormModule;
6+
7+
use Aura\Filter\FilterFactory;
8+
use Aura\Html\HelperLocatorFactory;
9+
use Aura\Input\AntiCsrfInterface;
10+
use Aura\Input\Builder;
11+
use Aura\Input\BuilderInterface;
12+
use Aura\Input\Filter;
13+
use Aura\Input\FilterInterface;
14+
use Ray\AuraSessionModule\AuraSessionModule;
15+
use Ray\Di\AbstractModule;
16+
use Ray\Di\Scope;
17+
use Ray\WebFormModule\Annotation\FormValidation;
18+
use Ray\WebFormModule\Annotation\InputValidation;
19+
20+
/** @SuppressWarnings(PHPMD.CouplingBetweenObjects) */
21+
class WebFormModule extends AbstractModule
22+
{
23+
/** {@inheritDoc} */
24+
protected function configure()
25+
{
26+
$this->install(new AuraSessionModule());
27+
$this->bind(BuilderInterface::class)->to(Builder::class);
28+
$this->bind(FilterInterface::class)->to(Filter::class);
29+
$this->bind(AntiCsrfInterface::class)->to(AntiCsrf::class)->in(Scope::SINGLETON);
30+
$this->bind(FailureHandlerInterface::class)->to(OnFailureMethodHandler::class);
31+
$this->bind(FailureHandlerInterface::class)
32+
->annotatedWith('vnd_error')->to(VndErrorHandler::class)->in(Scope::SINGLETON);
33+
$this->bind(HelperLocatorFactory::class);
34+
$this->bind(FilterFactory::class);
35+
$this->bindInterceptor(
36+
$this->matcher->any(),
37+
$this->matcher->annotatedWith(InputValidation::class),
38+
[InputValidationInterceptor::class],
39+
);
40+
$this->bindInterceptor(
41+
$this->matcher->any(),
42+
$this->matcher->annotatedWith(FormValidation::class),
43+
[AuraInputInterceptor::class],
44+
);
45+
}
46+
}

tests/Fake/FakeModule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class FakeModule extends AbstractModule
1010
protected function configure()
1111
{
1212
$this->bind(Phpfunc::class)->to(FakePhpFunc::class);
13-
$this->install(new AuraInputModule);
13+
$this->install(new WebFormModule());
1414
$this->bind(FormInterface::class)->annotatedWith('contact_form')->to(FakeForm::class);
1515
}
1616
}

tests/WebFormModuleTest.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Ray\WebFormModule;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Ray\Aop\WeavedInterface;
9+
use Ray\Di\AbstractModule;
10+
use Ray\Di\Injector;
11+
use Ray\WebFormModule\Exception\ValidationException;
12+
13+
class WebFormModuleTest extends TestCase
14+
{
15+
public function testWebFormModule()
16+
{
17+
$injector = new Injector(new class () extends AbstractModule {
18+
protected function configure()
19+
{
20+
$this->install(new WebFormModule());
21+
$this->bind(FormInterface::class)->annotatedWith('contact_form')->to(FakeForm::class);
22+
}
23+
}, __DIR__ . '/tmp');
24+
$controller = $injector->getInstance(FakeController::class);
25+
$this->assertInstanceOf(WeavedInterface::class, $controller);
26+
}
27+
28+
public function testAuraInputModuleIsAliasOfWebFormModule()
29+
{
30+
$this->assertInstanceOf(WebFormModule::class, new AuraInputModule());
31+
}
32+
33+
public function testExceptionOnFailure()
34+
{
35+
$this->expectException(ValidationException::class);
36+
$injector = new Injector(new class () extends AbstractModule {
37+
protected function configure()
38+
{
39+
$this->install(new WebFormModule());
40+
$this->bind(FormInterface::class)->annotatedWith('contact_form')->to(FakeForm::class);
41+
}
42+
}, __DIR__ . '/tmp');
43+
/** @var FakeInputValidationController $controller */
44+
$controller = $injector->getInstance(FakeInputValidationController::class);
45+
$controller->createAction('');
46+
}
47+
}

0 commit comments

Comments
 (0)