diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index e81eb6f..395f174 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -101,8 +101,8 @@ jobs: - name: Install Infection run: | - wget https://github.com/infection/infection/releases/download/0.32.6/infection.phar - wget https://github.com/infection/infection/releases/download/0.32.6/infection.phar.asc + wget https://github.com/infection/infection/releases/download/0.34.0/infection.phar + wget https://github.com/infection/infection/releases/download/0.34.0/infection.phar.asc chmod +x infection.phar gpg --recv-keys C6D76C329EBADE2FB9C458CFC5095986493B4AA0 gpg --with-fingerprint --verify infection.phar.asc infection.phar diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3f3dd10..fdf59ef 100755 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -6,7 +6,7 @@ processIsolation="false" stopOnFailure="false" stderr="true" - xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.0/phpunit.xsd" cacheDirectory=".phpunit.cache" > diff --git a/src/Aggregate/FormBuilder.php b/src/Aggregate/FormBuilder.php index 863d21a..bfb7e07 100644 --- a/src/Aggregate/FormBuilder.php +++ b/src/Aggregate/FormBuilder.php @@ -293,6 +293,7 @@ public function csrf(string $name = '_token'): ChildBuilderInterface * @psalm-suppress MoreSpecificReturnType * @psalm-suppress LessSpecificReturnStatement */ + #[Override] public function email(string $name): ChildBuilderInterface { return $this->add($name, EmailElement::class); @@ -314,6 +315,7 @@ public function email(string $name): ChildBuilderInterface * @psalm-suppress MoreSpecificReturnType * @psalm-suppress LessSpecificReturnStatement */ + #[Override] public function url(string $name): ChildBuilderInterface { return $this->add($name, UrlElement::class); diff --git a/src/Aggregate/FormBuilderInterface.php b/src/Aggregate/FormBuilderInterface.php index 342984b..c529e5b 100644 --- a/src/Aggregate/FormBuilderInterface.php +++ b/src/Aggregate/FormBuilderInterface.php @@ -15,6 +15,8 @@ use Bdf\Form\Leaf\Date\DateTimeElementBuilder; use Bdf\Form\Leaf\EnumElementBuilder; use Bdf\Form\Leaf\FloatElementBuilder; +use Bdf\Form\Leaf\Helper\EmailElement; +use Bdf\Form\Leaf\Helper\UrlElement; use Bdf\Form\Leaf\IntegerElementBuilder; use Bdf\Form\Leaf\StringElementBuilder; use Bdf\Form\Phone\PhoneChildBuilder; @@ -221,6 +223,48 @@ public function struct(string $name, string $structClass): ChildBuilderInterface */ public function csrf(string $name = '_token'): ChildBuilderInterface; + /** + * Add a new email element + * Note: The email element is a simple string but with the email constraint + * + * + * $builder->email('contact') + * ->message('Invalid contact email') + * ; + * + * + * @param non-empty-string $name The name of the input + * + * @return ChildBuilder|\Bdf\Form\Leaf\Helper\EmailElementBuilder + * @psalm-return ChildBuilderInterface<\Bdf\Form\Leaf\Helper\EmailElementBuilder> + * + * @psalm-suppress MoreSpecificReturnType + * @psalm-suppress LessSpecificReturnStatement + * + * @since 2.0 + */ + public function email(string $name): ChildBuilderInterface; + + /** + * Add a new url element + * Note: The url element is a simple string but with the url constraint + * + * + * $builder->url('home')->protocols('https'); + * + * + * @param non-empty-string $name The name of the input + * + * @return ChildBuilder|\Bdf\Form\Leaf\Helper\UrlElementBuilder + * @psalm-return ChildBuilderInterface<\Bdf\Form\Leaf\Helper\UrlElementBuilder> + * + * @psalm-suppress MoreSpecificReturnType + * @psalm-suppress LessSpecificReturnStatement + * + * @since 2.0 + */ + public function url(string $name): ChildBuilderInterface; + /** * Add an embedded form *