Skip to content
Snippets Groups Projects
Unverified Commit ce4ed432 authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

fix: correct type issues

parent 53a227a8
No related branches found
No related tags found
2 merge requests!28release: 3.0.0,!19Add strong typing for 3.0 version
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
namespace WPDesk\Forms; namespace WPDesk\Forms;
use Psr\Container\ContainerInterface;
use WPDesk\Persistence\PersistentContainer; use WPDesk\Persistence\PersistentContainer;
/** /**
...@@ -11,8 +10,12 @@ use WPDesk\Persistence\PersistentContainer; ...@@ -11,8 +10,12 @@ use WPDesk\Persistence\PersistentContainer;
* @package WPDesk\Forms * @package WPDesk\Forms
*/ */
interface ContainerForm { 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. * Put data from form into a container.
......
...@@ -200,11 +200,13 @@ abstract class BasicField implements Field { ...@@ -200,11 +200,13 @@ abstract class BasicField implements Field {
return isset( $this->meta['class'][ $name ] ); return isset( $this->meta['class'][ $name ] );
} }
public function get_default_value(): string { /** @return mixed */
public function get_default_value() {
return $this->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; $this->default_value = $value;
return $this; return $this;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
namespace WPDesk\Forms\Field\Traits; namespace WPDesk\Forms\Field\Traits;
use WPDesk\Forms\Field;
/** /**
* Implementation of HTML attributes like id, name, action etc. * Implementation of HTML attributes like id, name, action etc.
* *
...@@ -54,6 +52,6 @@ trait HtmlAttributes { ...@@ -54,6 +52,6 @@ trait HtmlAttributes {
} }
public function get_attribute( string $name, string $default = null ): string { public function get_attribute( string $name, string $default = null ): string {
return $this->attributes[ $name ] ?? $default; return $this->attributes[ $name ] ?? $default ?? '';
} }
} }
...@@ -42,7 +42,7 @@ interface Form { ...@@ -42,7 +42,7 @@ interface Form {
* *
* @return void * @return void
*/ */
public function set_data( array $data ); public function set_data( $data );
/** /**
* Use to render the form to string. * Use to render the form to string.
...@@ -69,6 +69,6 @@ interface Form { ...@@ -69,6 +69,6 @@ interface Form {
/** /**
* Form if you ever need to have more than one form at once. * 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;
} }
...@@ -113,7 +113,9 @@ class FormWithFields implements Form, ContainerForm, FieldProvider { ...@@ -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. * 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 ) { public function set_data( $data ) {
if ( is_array( $data ) ) { if ( is_array( $data ) ) {
...@@ -208,7 +210,7 @@ class FormWithFields implements Form, ContainerForm, FieldProvider { ...@@ -208,7 +210,7 @@ class FormWithFields implements Form, ContainerForm, FieldProvider {
return $fields; return $fields;
} }
public function get_form_id(): int { public function get_form_id(): string {
return $this->form_id; return $this->form_id;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment