diff --git a/src/ContainerForm.php b/src/ContainerForm.php index 05107067d10d357fa2a4b8b6a73de9a9333de828..1d4cf05dffb3104d8095b267ff62cfc604cd82be 100644 --- a/src/ContainerForm.php +++ b/src/ContainerForm.php @@ -2,7 +2,6 @@ namespace WPDesk\Forms; -use Psr\Container\ContainerInterface; use WPDesk\Persistence\PersistentContainer; /** @@ -11,8 +10,12 @@ use WPDesk\Persistence\PersistentContainer; * @package WPDesk\Forms */ interface ContainerForm { - /** @return void */ - public function set_data( ContainerInterface $data ); + /** + * @param \Psr\Container\ContainerInterface $data + * + * @return void + */ + public function set_data( $data ); /** * Put data from form into a container. diff --git a/src/Field/BasicField.php b/src/Field/BasicField.php index 842241e8fe77a30e1e2855b147f879c62ae2ae0e..69e460dc4e30c4a655980a486dcad8680f181460 100644 --- a/src/Field/BasicField.php +++ b/src/Field/BasicField.php @@ -200,11 +200,13 @@ abstract class BasicField implements Field { return isset( $this->meta['class'][ $name ] ); } - public function get_default_value(): string { + /** @return mixed */ + public function get_default_value() { return $this->default_value; } - public function set_default_value( string $value ): Field { + /** @param mixed $value */ + public function set_default_value( $value ): Field { $this->default_value = $value; return $this; diff --git a/src/Field/Traits/HtmlAttributes.php b/src/Field/Traits/HtmlAttributes.php index afc1e088eb057b70aee75507107783106b35dcae..5ae190a135b9316b03ae664121a697151fd7a095 100644 --- a/src/Field/Traits/HtmlAttributes.php +++ b/src/Field/Traits/HtmlAttributes.php @@ -2,8 +2,6 @@ namespace WPDesk\Forms\Field\Traits; -use WPDesk\Forms\Field; - /** * Implementation of HTML attributes like id, name, action etc. * @@ -54,6 +52,6 @@ trait HtmlAttributes { } public function get_attribute( string $name, string $default = null ): string { - return $this->attributes[ $name ] ?? $default; + return $this->attributes[ $name ] ?? $default ?? ''; } } diff --git a/src/Form.php b/src/Form.php index 8ea2d785b46d16c64032504bbbf7de542707a158..504ebbeafeb3159a8e033b36db00939dc9c3c2a7 100644 --- a/src/Form.php +++ b/src/Form.php @@ -42,7 +42,7 @@ interface Form { * * @return void */ - public function set_data( array $data ); + public function set_data( $data ); /** * Use to render the form to string. @@ -69,6 +69,6 @@ interface Form { /** * Form if you ever need to have more than one form at once. */ - public function get_form_id(): int; + public function get_form_id(): string; } diff --git a/src/Form/FormWithFields.php b/src/Form/FormWithFields.php index 45dc5150049a438e26c04ea181fb24ca683f00c4..ba13928a94370ce5fcd1eda32de5771e17def667 100644 --- a/src/Form/FormWithFields.php +++ b/src/Form/FormWithFields.php @@ -113,7 +113,9 @@ class FormWithFields implements Form, ContainerForm, FieldProvider { /** * Data could be saved in some place. Use this method to transmit them to form. * - * @param array|ContainerInterface $data Data consistent with Form and ContainerForm interface. + * @param array|ContainerInterface $data Data consistent with Form or ContainerForm interface. + * + * @return void */ public function set_data( $data ) { if ( is_array( $data ) ) { @@ -208,7 +210,7 @@ class FormWithFields implements Form, ContainerForm, FieldProvider { return $fields; } - public function get_form_id(): int { + public function get_form_id(): string { return $this->form_id; }