Skip to content
Snippets Groups Projects
Commit dc8237b4 authored by potreb's avatar potreb
Browse files

fix: devel merge, reformat

parent 3a9fb378
No related branches found
No related tags found
3 merge requests!28release: 3.0.0,!23Feature/strong typing pp,!19Add strong typing for 3.0 version
Pipeline #6434 passed
Showing
with 30 additions and 10 deletions
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace WPDesk\Forms\Field\Traits; namespace WPDesk\Forms\Field\Traits;
use WPDesk\Forms\Field;
use WPDesk\Forms\Form;
/** /**
* Implementation of HTML attributes like id, name, action etc. * Implementation of HTML attributes like id, name, action etc.
* *
...@@ -44,7 +47,7 @@ trait HtmlAttributes { ...@@ -44,7 +47,7 @@ trait HtmlAttributes {
* @param string $name * @param string $name
* @param string[]|string|bool $value * @param string[]|string|bool $value
* *
* @return \WPDesk\Forms\Field|\WPDesk\Forms\Form * @return Field|Form
*/ */
final public function set_attribute( string $name, $value ) { final public function set_attribute( string $name, $value ) {
$this->attributes[ $name ] = $value; $this->attributes[ $name ] = $value;
...@@ -53,7 +56,7 @@ trait HtmlAttributes { ...@@ -53,7 +56,7 @@ trait HtmlAttributes {
} }
/** /**
* @return \WPDesk\Forms\Field|\WPDesk\Forms\Form * @return HtmlAttributes
*/ */
final public function unset_attribute( string $name ) { final public function unset_attribute( string $name ) {
unset( $this->attributes[ $name ] ); unset( $this->attributes[ $name ] );
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace WPDesk\Forms\Field; namespace WPDesk\Forms\Field;
class WooSelect extends SelectField { class WooSelect extends SelectField {
public function __construct() { public function __construct() {
$this->set_multiple(); $this->set_multiple();
$this->add_class( 'wc-enhanced-select' ); $this->add_class( 'wc-enhanced-select' );
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace WPDesk\Forms\Field; namespace WPDesk\Forms\Field;
class WyswigField extends BasicField { class WyswigField extends BasicField {
public function get_template_name(): string { public function get_template_name(): string {
return 'wyswig'; return 'wyswig';
} }
......
...@@ -6,6 +6,7 @@ namespace WPDesk\Forms; ...@@ -6,6 +6,7 @@ namespace WPDesk\Forms;
* FieldProvider is owner of FormFields. These fields can be used to render forms and process values. * FieldProvider is owner of FormFields. These fields can be used to render forms and process values.
*/ */
interface FieldProvider { interface FieldProvider {
/** /**
* Returns owned fields. * Returns owned fields.
* *
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace WPDesk\Forms; namespace WPDesk\Forms;
interface FieldRenderer { interface FieldRenderer {
/** @return string|array String or normalized array */ /** @return string|array String or normalized array */
public function render_fields( FieldProvider $provider, array $fields_data, string $name_prefix = '' ); public function render_fields( FieldProvider $provider, array $fields_data, string $name_prefix = '' );
} }
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace WPDesk\Forms; namespace WPDesk\Forms;
use Psr\Container\ContainerInterface;
/** /**
* Some field owners can receive and process field data. * Some field owners can receive and process field data.
* Probably should be used with FieldProvider interface. * Probably should be used with FieldProvider interface.
...@@ -9,10 +11,11 @@ namespace WPDesk\Forms; ...@@ -9,10 +11,11 @@ namespace WPDesk\Forms;
* @package WPDesk\Forms * @package WPDesk\Forms
*/ */
interface FieldsDataReceiver { interface FieldsDataReceiver {
/** /**
* Set values corresponding to fields. * Set values corresponding to fields.
* *
* @return void * @return void
*/ */
public function update_fields_data( \Psr\Container\ContainerInterface $data ); public function update_fields_data( ContainerInterface $data );
} }
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
namespace WPDesk\Forms; namespace WPDesk\Forms;
use WPDesk\Persistence\PersistentContainer;
use WPDesk\View\Renderer\Renderer; use WPDesk\View\Renderer\Renderer;
/** /**
...@@ -11,6 +10,7 @@ use WPDesk\View\Renderer\Renderer; ...@@ -11,6 +10,7 @@ use WPDesk\View\Renderer\Renderer;
* @package WPDesk\Forms * @package WPDesk\Forms
*/ */
interface Form { interface Form {
/** /**
* For some reason you may want to disable a form. Returns false when disabled. * For some reason you may want to disable a form. Returns false when disabled.
*/ */
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace WPDesk\Forms; namespace WPDesk\Forms;
interface Sanitizer { interface Sanitizer {
/** /**
* @param mixed $value * @param mixed $value
* *
......
...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Sanitizer; ...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Sanitizer;
use WPDesk\Forms\Sanitizer; use WPDesk\Forms\Sanitizer;
class EmailSanitizer implements Sanitizer { class EmailSanitizer implements Sanitizer {
public function sanitize( $value ): string { public function sanitize( $value ): string {
return sanitize_email( $value ); return sanitize_email( $value );
} }
......
...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Sanitizer; ...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Sanitizer;
use WPDesk\Forms\Sanitizer; use WPDesk\Forms\Sanitizer;
class NoSanitize implements Sanitizer { class NoSanitize implements Sanitizer {
public function sanitize( $value ) { public function sanitize( $value ) {
return $value; return $value;
} }
......
...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Sanitizer; ...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Sanitizer;
use WPDesk\Forms\Sanitizer; use WPDesk\Forms\Sanitizer;
class TextFieldSanitizer implements Sanitizer { class TextFieldSanitizer implements Sanitizer {
public function sanitize( $value ): string { public function sanitize( $value ): string {
return sanitize_text_field( $value ); return sanitize_text_field( $value );
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace WPDesk\Forms; namespace WPDesk\Forms;
interface Serializer { interface Serializer {
/** /**
* @param mixed $value * @param mixed $value
*/ */
......
...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Serializer; ...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Serializer;
use WPDesk\Forms\Serializer; use WPDesk\Forms\Serializer;
class JsonSerializer implements Serializer { class JsonSerializer implements Serializer {
public function serialize( $value ): string { public function serialize( $value ): string {
return (string) json_encode( $value ); return (string) json_encode( $value );
} }
......
...@@ -10,6 +10,7 @@ use WPDesk\Forms\Serializer; ...@@ -10,6 +10,7 @@ use WPDesk\Forms\Serializer;
* @package WPDesk\Forms\Serializer * @package WPDesk\Forms\Serializer
*/ */
class ProductSelectSerializer implements Serializer { class ProductSelectSerializer implements Serializer {
public function serialize( $value ): string { public function serialize( $value ): string {
$products_with_names = []; $products_with_names = [];
if ( is_array( $value ) ) { if ( is_array( $value ) ) {
......
...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Serializer; ...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Serializer;
use WPDesk\Forms\Serializer; use WPDesk\Forms\Serializer;
class SerializeSerializer implements Serializer { class SerializeSerializer implements Serializer {
public function serialize( $value ): string { public function serialize( $value ): string {
return serialize( $value ); return serialize( $value );
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace WPDesk\Forms; namespace WPDesk\Forms;
interface Validator { interface Validator {
/** @param mixed $value */ /** @param mixed $value */
public function is_valid( $value ): bool; public function is_valid( $value ): bool;
......
...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Validator; ...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Validator;
use WPDesk\Forms\Validator; use WPDesk\Forms\Validator;
class NoValidateValidator implements Validator { class NoValidateValidator implements Validator {
public function is_valid( $value ): bool { public function is_valid( $value ): bool {
return true; return true;
} }
......
...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Validator; ...@@ -5,6 +5,7 @@ namespace WPDesk\Forms\Validator;
use WPDesk\Forms\Validator; use WPDesk\Forms\Validator;
class RequiredValidator implements Validator { class RequiredValidator implements Validator {
public function is_valid( $value ): bool { public function is_valid( $value ): bool {
return $value !== null; return $value !== null;
} }
......
...@@ -33,3 +33,4 @@ ...@@ -33,3 +33,4 @@
readonly="readonly"<?php endif; ?> readonly="readonly"<?php endif; ?>
><?php echo \esc_html( $field->get_label() ); ?></button> ><?php echo \esc_html( $field->get_label() ); ?></button>
...@@ -11,13 +11,12 @@ ...@@ -11,13 +11,12 @@
<tr valign="top"> <tr valign="top">
<?php if ( $field->has_label() ) : ?> <?php if ( $field->has_label() ) : ?>
<?php echo wp_kses_post( $renderer->render( 'form-label', [ 'field' => $field ] ) ); ?> <?php $renderer->output_render( 'form-label', [ 'field' => $field ] ); ?>
<?php endif; ?> <?php endif; ?>
<td class="forminp"> <td class="forminp">
<?php <?php
echo wp_kses_post( $renderer->output_render(
$renderer->render(
$template_name, $template_name,
[ [
'field' => $field, 'field' => $field,
...@@ -25,7 +24,6 @@ ...@@ -25,7 +24,6 @@
'name_prefix' => $name_prefix, 'name_prefix' => $name_prefix,
'value' => $value, 'value' => $value,
] ]
)
); );
?> ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment