Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
4193579
refactor: アノテーションを PHP 8 Attributes に移行し依存関係を更新
apple-x-co Dec 27, 2025
d90abb9
docs: README のサンプルコードを PHP 8 Attributes 形式に更新 migrate-attribute
apple-x-co Dec 31, 2025
e192dc4
test: PHPUnit 設定を最新形式に更新しテストコードを PHP 8 対応に改善 migrate-attribute
apple-x-co Jan 6, 2026
d6e5bba
ci: Scrutinizer 設定から `php_mess_detector` を無効化 migrate-attribute
apple-x-co Jan 6, 2026
f4e605a
docs: README の `VndError` 表記を Attributes 形式に更新 migrate-attribute
apple-x-co Jan 6, 2026
7bcb17d
ci: Scrutinizer 設定を簡素化し PHP 8.0 ビルド環境に移行 migrate-attribute
apple-x-co Jan 7, 2026
67df167
test: `AuraInputInterceptorTest` の重複した `expectException` 呼び出しを削除 migr…
apple-x-co Jan 7, 2026
47c4b50
ci: Scrutinizer の PHP バージョンを 8.2 に更新し設定構造を最適化 migrate-attribute
apple-x-co Jan 7, 2026
280117b
test: 未使用の `invalidControllerProvider` メソッドをコメントアウト migrate-attribute
apple-x-co Jan 7, 2026
9f408e2
style: 全ソースファイルに `declare(strict_types=1)` を追加し厳密な型チェックを有効化 migrate-a…
apple-x-co Feb 7, 2026
677d1cb
style: namespace 後に空行追加、use 文を整理し FQCN を削減 migrate-attribute
apple-x-co Feb 14, 2026
46414e8
refactor: プロパティと返り値に型宣言を追加し PHP 8 型システムに対応 migrate-attribute
apple-x-co Feb 14, 2026
dfafacb
refactor: Doctrine Annotations を削除し PHP 8 Attributes に完全移行 migrate-at…
apple-x-co Feb 14, 2026
2e6d8d9
Address PR review feedback
koriym May 15, 2026
a1cfe37
Address Copilot review feedback
claude May 15, 2026
9f48a96
fix: PHP 8.4 deprecation and add property type declarations
koriym May 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ build
vendor/
composer.phar
composer.lock
tests/tmp/*
!tests/tmp/.placefolder
.phpunit.result.cache
27 changes: 10 additions & 17 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
build:
nodes:
analysis:
tests:
override:
- php-scrutinizer-run
environment:
php:
version: 8.2

filter:
paths: ["src/*"]
tools:
external_code_coverage: true
php_code_coverage:
timeout: 1200
php_sim: true
php_mess_detector: true
php_pdepend: true
php_analyzer: true
php_cpd: true
php_mess_detector:
enabled: true
config:
ruleset: ./phpmd.xml
php_code_sniffer:
enabled: true
config:
ruleset: ./phpcs.xml
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

31 changes: 9 additions & 22 deletions README.JA.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function createAction($id, $name, $body)

### Controller

コントローラークラスにフォームをインジェクトします。フォームのバリデーションを行うメソッドを`@FormValidation`で
コントローラークラスにフォームをインジェクトします。フォームのバリデーションを行うメソッドを`#[FormValidation]`で
アノテートします。この時フォームのプロパティ名を`form`で、バリデーションが失敗したときのメソッドを`onFailure`で指定します。

```php
Expand All @@ -95,18 +95,13 @@ class MyController
*/
protected $contactForm;

/**
* @Inject
* @Named("contact_form")
*/
public function setForm(FormInterface $form)
#[Inject]
public function setForm(#[Named("contact_form")] FormInterface $form)
{
$this->contactForm = $form;
}

/**
* @FormValidation(form="contactForm", onFailure="badRequestAction")
*/
#[FormValidation(form: "contactForm", onFailure: "badRequestAction")]
public function createAction()
{
// validation success
Expand Down Expand Up @@ -144,16 +139,14 @@ class MyForm extends AbstractAuraForm

## Validation Exception

`@FormValidation`の代わりに`@InputValidation`とアノテートするとバリデーションが失敗したときに`Ray\WebFormModule\Exception\ValidationException`が投げられるよになります。この場合はHTML表現は使われません。Web APIアプリケーションなどに便利です。
`#[FormValidation]`の代わりに`#[InputValidation]`とアノテートするとバリデーションが失敗したときに`Ray\WebFormModule\Exception\ValidationException`が投げられるよになります。この場合はHTML表現は使われません。Web APIアプリケーションなどに便利です。

```php
use Ray\WebFormModule\Annotation\InputValidation;

class Foo
{
/**
* @InputValidation(form="form1")
*/
#[InputValidation(form: "form1")]
public function createAction($name)
{
// ...
Expand Down Expand Up @@ -190,17 +183,11 @@ echo $e->error;
//}
```

`@VndError`アノテーションで`vnd.error+json`に必要な情報を加えることができます。
`#[VndError]`属性で`vnd.error+json`に必要な情報を加えることができます。

```php
/**
* @FormValidation(form="contactForm")
* @VndError(
* message="foo validation failed",
* logref="a1000", path="/path/to/error",
* href={"_self"="/path/to/error", "help"="/path/to/help"}
* )
*/
#[FormValidation(form: "contactForm")]
#[VndError(message: "foo validation failed", logref: "a1000", path: "/path/to/error", href: ["_self" => "/path/to/error", "help" => "/path/to/help"])]
```

このオプションのモジュールはAPIアプリケーションの時に有用です。
Expand Down
26 changes: 8 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class MyForm extends AbstractForm
```
### Controller

We annotate the methods which web form validation is required with `@FormValidation`. We can specify form object property name with `name` and failiure method name with `@onFailure`.
We annotate the methods which web form validation is required with `#[FormValidation]`. We can specify form object property name with `form` and failure method name with `onFailure`.

```php
use Ray\Di\Di\Inject;
Expand All @@ -103,21 +103,17 @@ class MyController
*/
protected $contactForm;

/**
* @Inject
* @Named("contact_form")
*/
public function setForm(FormInterface $form)
#[Inject]
public function setForm(#[Named("contact_form")] FormInterface $form)
{
$this->contactForm = $form;
}

/**
* @FormValidation(form="contactForm", onFailure="badRequestAction")
*/
#[FormValidation(form: "contactForm", onFailure: "badRequestAction")]
public function createAction()
{
// validation success
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
// More detail for `vnd.error+json` can be added with `#[VndError]`.
}

public function badRequestAction()
Expand Down Expand Up @@ -183,17 +179,11 @@ echo $e->error;
//}
```

More detail for `vnd.error+json`can be add with `@VndError` annotation.
More detail for `vnd.error+json` can be added with the `#[VndError]` attribute.

```php
/**
* @FormValidation(form="contactForm")
* @VndError(
* message="foo validation failed",
* logref="a1000", path="/path/to/error",
* href={"_self"="/path/to/error", "help"="/path/to/help"}
* )
*/
#[FormValidation(form: "contactForm")]
#[VndError(message: "foo validation failed", logref: "a1000", path: "/path/to/error", href: ["_self" => "/path/to/error", "help" => "/path/to/help"])]
```

This optional module is handy for API application.
Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
"Ray.Di module"
],
"require": {
"php": ">=7.0.0",
"ray/di": "^2.7",
"php": ">=8.0.0",
"ray/di": "^2.16",
"ray/aop": "^2.14",
"aura/input": "^1.2",
"aura/filter": "^2.3|3.x-dev",
"aura/html": "^2.5",
"ray/aura-session-module": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^5.7.13"
"phpunit/phpunit": "^9.5"
},
"license": "MIT",
"autoload":{
Expand All @@ -32,5 +33,10 @@
"coverage": ["php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage"],
"cs": ["php-cs-fixer fix -v --dry-run", "phpcs --standard=./phpcs.xml src"],
"cs-fix": ["php-cs-fixer fix -v", "phpcbf src"]
},
"config": {
"allow-plugins": {
"aura/installer-default": true
}
}
}
22 changes: 12 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<phpunit bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite>
<testsuite name="Ray.WebFormModule Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>

<logging>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
<junit outputFile="build/logs/junit.xml"/>
</logging>

<filter>
<whitelist>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
Loading