From edfb1fcb69936e3b68466063632b7f6ea6854e3e Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 17 Nov 2026 12:42:26 +0900 Subject: [PATCH 1/3] Point the attribute docblocks to the manual --- src/Annotation/AbstractValidation.php | 4 ++++ src/Annotation/CsrfProtection.php | 5 +++++ src/Annotation/FormValidation.php | 10 ++++++++++ src/Annotation/InputValidation.php | 6 ++++++ src/Annotation/VndError.php | 7 ++++++- 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Annotation/AbstractValidation.php b/src/Annotation/AbstractValidation.php index 8669808..5db58b6 100644 --- a/src/Annotation/AbstractValidation.php +++ b/src/Annotation/AbstractValidation.php @@ -4,8 +4,12 @@ namespace Ray\WebFormModule\Annotation; +/** + * Base of the attributes that validate the input with a form before the method runs + */ abstract class AbstractValidation { + /** @param string $form Name of the property that holds the form */ public function __construct(public string $form = 'form') { } diff --git a/src/Annotation/CsrfProtection.php b/src/Annotation/CsrfProtection.php index c40a0a4..49a8de5 100644 --- a/src/Annotation/CsrfProtection.php +++ b/src/Annotation/CsrfProtection.php @@ -6,6 +6,11 @@ use Attribute; +/** + * Makes the validating form check the CSRF token and throw CsrfViolationException on mismatch + * + * @see https://bearsunday.github.io/manuals/1.0/en/form.html#csrf-protections + */ #[Attribute(Attribute::TARGET_METHOD)] final class CsrfProtection { diff --git a/src/Annotation/FormValidation.php b/src/Annotation/FormValidation.php index c852267..e6bd115 100644 --- a/src/Annotation/FormValidation.php +++ b/src/Annotation/FormValidation.php @@ -6,9 +6,19 @@ use Attribute; +/** + * Validates the input with the form before the method runs and hands a failure to the failure handler + * + * @see https://bearsunday.github.io/manuals/1.0/en/form.html#controller + * @see \Ray\WebFormModule\AuraInputInterceptor + */ #[Attribute(Attribute::TARGET_METHOD)] final class FormValidation extends AbstractValidation { + /** + * @param string $form Name of the property that holds the form + * @param string|null $onFailure Method called on failure, `ValidationFailed` when null + */ public function __construct( string $form = 'form', public string|null $onFailure = null, diff --git a/src/Annotation/InputValidation.php b/src/Annotation/InputValidation.php index 77c1407..b2d88b7 100644 --- a/src/Annotation/InputValidation.php +++ b/src/Annotation/InputValidation.php @@ -6,6 +6,12 @@ use Attribute; +/** + * Validates the input with the form before the method runs and throws ValidationException on failure + * + * @see https://bearsunday.github.io/manuals/1.0/en/form.html#validation-exception + * @see \Ray\WebFormModule\InputValidationInterceptor + */ #[Attribute(Attribute::TARGET_METHOD)] final class InputValidation extends AbstractValidation { diff --git a/src/Annotation/VndError.php b/src/Annotation/VndError.php index 34c5a56..4e382c3 100644 --- a/src/Annotation/VndError.php +++ b/src/Annotation/VndError.php @@ -6,11 +6,16 @@ use Attribute; +/** + * Sets the message, path, logref and links of the vnd.error body when validation fails + * + * @see https://bearsunday.github.io/manuals/1.0/en/form.html#validation-exception + */ #[Attribute(Attribute::TARGET_METHOD)] final class VndError { /** - * @param array $href + * @param array $href URIs keyed by link relation, e.g. `help` * * @see http://www.w3.org/TR/html5/links.html#link-type-help * @see http://tools.ietf.org/html/rfc6903#section-2 From b0704c918ca6caf0223f3660f990432f60836740 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 17 Nov 2026 13:36:56 +0900 Subject: [PATCH 2/3] Describe when VndError is read --- src/Annotation/VndError.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Annotation/VndError.php b/src/Annotation/VndError.php index 4e382c3..84fbda0 100644 --- a/src/Annotation/VndError.php +++ b/src/Annotation/VndError.php @@ -8,6 +8,7 @@ /** * Sets the message, path, logref and links of the vnd.error body when validation fails + * Read for #[InputValidation], and for #[FormValidation] when FormVndErrorModule is installed * * @see https://bearsunday.github.io/manuals/1.0/en/form.html#validation-exception */ From 5105516b8687f51e39dcc958cb7d32068c0f96fa Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Tue, 17 Nov 2026 16:08:03 +0900 Subject: [PATCH 3/3] Describe the FormVndErrorModule failure path in the validation docblocks --- src/Annotation/FormValidation.php | 3 ++- src/Annotation/VndError.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Annotation/FormValidation.php b/src/Annotation/FormValidation.php index e6bd115..322679d 100644 --- a/src/Annotation/FormValidation.php +++ b/src/Annotation/FormValidation.php @@ -17,7 +17,8 @@ final class FormValidation extends AbstractValidation { /** * @param string $form Name of the property that holds the form - * @param string|null $onFailure Method called on failure, `ValidationFailed` when null + * @param string|null $onFailure Method called on failure, `ValidationFailed` when null; + * FormVndErrorModule throws ValidationException without calling it */ public function __construct( string $form = 'form', diff --git a/src/Annotation/VndError.php b/src/Annotation/VndError.php index 84fbda0..0f5f9ec 100644 --- a/src/Annotation/VndError.php +++ b/src/Annotation/VndError.php @@ -8,7 +8,7 @@ /** * Sets the message, path, logref and links of the vnd.error body when validation fails - * Read for #[InputValidation], and for #[FormValidation] when FormVndErrorModule is installed + * VndErrorHandler reads it for #[InputValidation], and for #[FormValidation] when FormVndErrorModule is installed * * @see https://bearsunday.github.io/manuals/1.0/en/form.html#validation-exception */