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

fix: correct type issues

parent 279be6ca
Branches
Tags
3 merge requests!28release: 3.0.0,!23Feature/strong typing pp,!19Add strong typing for 3.0 version
Pipeline #6034 passed
......@@ -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.
......
......@@ -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;
......
......@@ -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 ?? '';
}
}
......@@ -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;
}
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment