diff --git a/src/Validation/Abstract_Validation_Rule_Builder.php b/src/Validation/Abstract_Validation_Rule_Builder.php index 689ef67..34bc498 100644 --- a/src/Validation/Abstract_Validation_Rule_Builder.php +++ b/src/Validation/Abstract_Validation_Rule_Builder.php @@ -56,7 +56,7 @@ public function __construct( array $initial_rules = array() ) { * * @throws InvalidArgumentException Thrown when a forbidden rule is passed. */ - final public function with_rule( Validation_Rule $rule ): static { + final public function with_rule( Validation_Rule $rule ): Validation_Rule_Builder { if ( ! $this->is_allowed_rule( $rule ) ) { throw new InvalidArgumentException( sprintf( diff --git a/src/Validation/Array_Validation_Rule_Builder.php b/src/Validation/Array_Validation_Rule_Builder.php index 8d10a8f..52d851c 100644 --- a/src/Validation/Array_Validation_Rule_Builder.php +++ b/src/Validation/Array_Validation_Rule_Builder.php @@ -10,6 +10,7 @@ use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Types; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Validation_Rule; +use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Validation_Rule_Builder; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\With_Type_Support; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Rules\Array_Validation_Rule; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Rules\Item_Count_Range_Validation_Rule; @@ -49,7 +50,7 @@ public function __construct( array $initial_rules = array(), bool $strict = fals * * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ - public function with_items( Validation_Rule $item_validation_rule ): static { + public function with_items( Validation_Rule $item_validation_rule ): Validation_Rule_Builder { return $this->with_rule( new Items_Validation_Rule( $item_validation_rule ) ); } @@ -62,7 +63,7 @@ public function with_items( Validation_Rule $item_validation_rule ): static { * @param int $max_count Optional. Maximum count allowed. Default 0 (no limit). * @return static Builder instance for chaining. */ - public function with_item_count_range( int $min_count = 0, int $max_count = 0 ): static { + public function with_item_count_range( int $min_count = 0, int $max_count = 0 ): Validation_Rule_Builder { return $this->with_rule( new Item_Count_Range_Validation_Rule( $min_count, $max_count ) ); } @@ -73,7 +74,7 @@ public function with_item_count_range( int $min_count = 0, int $max_count = 0 ): * * @return static Builder instance for chaining. */ - public function with_unique_items(): static { + public function with_unique_items(): Validation_Rule_Builder { return $this->with_rule( new Unique_Items_Validation_Rule() ); } diff --git a/src/Validation/Contracts/Validation_Rule_Builder.php b/src/Validation/Contracts/Validation_Rule_Builder.php index 7ca93bd..8289d17 100644 --- a/src/Validation/Contracts/Validation_Rule_Builder.php +++ b/src/Validation/Contracts/Validation_Rule_Builder.php @@ -29,7 +29,7 @@ interface Validation_Rule_Builder { * * @throws InvalidArgumentException Thrown when a forbidden rule is passed. */ - public function with_rule( Validation_Rule $rule ): static; + public function with_rule( Validation_Rule $rule ): Validation_Rule_Builder; /** * Gets the combined validation rule consisting of all rules present in the builder. diff --git a/src/Validation/Float_Validation_Rule_Builder.php b/src/Validation/Float_Validation_Rule_Builder.php index c513f60..bcb3102 100644 --- a/src/Validation/Float_Validation_Rule_Builder.php +++ b/src/Validation/Float_Validation_Rule_Builder.php @@ -10,6 +10,7 @@ use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Types; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Validation_Rule; +use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Validation_Rule_Builder; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\With_Type_Support; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Rules\Datetime_Range_Validation_Rule; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Rules\Enum_Validation_Rule; @@ -48,7 +49,7 @@ public function __construct( array $initial_rules = array(), bool $strict = fals * @param string $regexp Regular expression to match. * @return static Builder instance for chaining. */ - public function format_regexp( string $regexp ): static { + public function format_regexp( string $regexp ): Validation_Rule_Builder { return $this->with_rule( new Regexp_Validation_Rule( $regexp ) ); } @@ -61,7 +62,7 @@ public function format_regexp( string $regexp ): static { * @param string $max_datetime Optional. Maximum date-time or date allowed. Default no limit. * @return static Builder instance for chaining. */ - public function with_datetime_range( string $min_datetime, string $max_datetime = null ): static { + public function with_datetime_range( string $min_datetime, string $max_datetime = null ): Validation_Rule_Builder { return $this->with_rule( new Datetime_Range_Validation_Rule( $min_datetime, $max_datetime ) ); } @@ -74,7 +75,7 @@ public function with_datetime_range( string $min_datetime, string $max_datetime * @param int|float $max Optional. Maximum value allowed. Default no limit. * @return static Builder instance for chaining. */ - public function with_numeric_range( $min, $max = null ): static { + public function with_numeric_range( $min, $max = null ): Validation_Rule_Builder { return $this->with_rule( new Numeric_Range_Validation_Rule( $min, $max ) ); } @@ -89,7 +90,7 @@ public function with_numeric_range( $min, $max = null ): static { * * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ - public function with_enum( array $allowed_values, bool $strict = false ): static { + public function with_enum( array $allowed_values, bool $strict = false ): Validation_Rule_Builder { return $this->with_rule( new Enum_Validation_Rule( $allowed_values, $strict ) ); } diff --git a/src/Validation/Integer_Validation_Rule_Builder.php b/src/Validation/Integer_Validation_Rule_Builder.php index e5d452d..7a9897b 100644 --- a/src/Validation/Integer_Validation_Rule_Builder.php +++ b/src/Validation/Integer_Validation_Rule_Builder.php @@ -10,6 +10,7 @@ use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Types; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Validation_Rule; +use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Validation_Rule_Builder; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\With_Type_Support; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Rules\Datetime_Range_Validation_Rule; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Rules\Enum_Validation_Rule; @@ -48,7 +49,7 @@ public function __construct( array $initial_rules = array(), bool $strict = fals * @param string $regexp Regular expression to match. * @return static Builder instance for chaining. */ - public function format_regexp( string $regexp ): static { + public function format_regexp( string $regexp ): Validation_Rule_Builder { return $this->with_rule( new Regexp_Validation_Rule( $regexp ) ); } @@ -61,7 +62,7 @@ public function format_regexp( string $regexp ): static { * @param string $max_datetime Optional. Maximum date-time or date allowed. Default no limit. * @return static Builder instance for chaining. */ - public function with_datetime_range( string $min_datetime, string $max_datetime = null ): static { + public function with_datetime_range( string $min_datetime, string $max_datetime = null ): Validation_Rule_Builder { return $this->with_rule( new Datetime_Range_Validation_Rule( $min_datetime, $max_datetime ) ); } @@ -74,7 +75,7 @@ public function with_datetime_range( string $min_datetime, string $max_datetime * @param int|float $max Optional. Maximum value allowed. Default no limit. * @return static Builder instance for chaining. */ - public function with_numeric_range( $min, $max = null ): static { + public function with_numeric_range( $min, $max = null ): Validation_Rule_Builder { return $this->with_rule( new Numeric_Range_Validation_Rule( $min, $max ) ); } @@ -89,7 +90,7 @@ public function with_numeric_range( $min, $max = null ): static { * * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ - public function with_enum( array $allowed_values, bool $strict = false ): static { + public function with_enum( array $allowed_values, bool $strict = false ): Validation_Rule_Builder { return $this->with_rule( new Enum_Validation_Rule( $allowed_values, $strict ) ); } diff --git a/src/Validation/String_Validation_Rule_Builder.php b/src/Validation/String_Validation_Rule_Builder.php index 13b2139..94479a2 100644 --- a/src/Validation/String_Validation_Rule_Builder.php +++ b/src/Validation/String_Validation_Rule_Builder.php @@ -10,6 +10,7 @@ use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Types; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Validation_Rule; +use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\Validation_Rule_Builder; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Contracts\With_Type_Support; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Rules\Date_Validation_Rule; use Felix_Arntz\WP_OOP_Plugin_Lib\Validation\Rules\Datetime_Range_Validation_Rule; @@ -52,7 +53,7 @@ public function __construct( array $initial_rules = array(), bool $strict = fals * * @return static Builder instance for chaining. */ - public function format_date(): static { + public function format_date(): Validation_Rule_Builder { return $this->with_rule( new Date_Validation_Rule() ); } @@ -63,7 +64,7 @@ public function format_date(): static { * * @return static Builder instance for chaining. */ - public function format_datetime(): static { + public function format_datetime(): Validation_Rule_Builder { return $this->with_rule( new Datetime_Validation_Rule() ); } @@ -74,7 +75,7 @@ public function format_datetime(): static { * * @return static Builder instance for chaining. */ - public function format_email(): static { + public function format_email(): Validation_Rule_Builder { return $this->with_rule( new Email_Validation_Rule() ); } @@ -85,7 +86,7 @@ public function format_email(): static { * * @return static Builder instance for chaining. */ - public function format_version(): static { + public function format_version(): Validation_Rule_Builder { return $this->with_rule( new Version_Validation_Rule() ); } @@ -96,7 +97,7 @@ public function format_version(): static { * * @return static Builder instance for chaining. */ - public function format_hex_color(): static { + public function format_hex_color(): Validation_Rule_Builder { return $this->with_rule( new Hex_Color_Validation_Rule() ); } @@ -108,7 +109,7 @@ public function format_hex_color(): static { * @param string $regexp Regular expression to match. * @return static Builder instance for chaining. */ - public function format_regexp( string $regexp ): static { + public function format_regexp( string $regexp ): Validation_Rule_Builder { return $this->with_rule( new Regexp_Validation_Rule( $regexp ) ); } @@ -119,7 +120,7 @@ public function format_regexp( string $regexp ): static { * * @return static Builder instance for chaining. */ - public function format_url(): static { + public function format_url(): Validation_Rule_Builder { return $this->with_rule( new URL_Validation_Rule() ); } @@ -132,7 +133,7 @@ public function format_url(): static { * @param string $max_datetime Optional. Maximum date-time or date allowed. Default no limit. * @return static Builder instance for chaining. */ - public function with_datetime_range( string $min_datetime, string $max_datetime = null ): static { + public function with_datetime_range( string $min_datetime, string $max_datetime = null ): Validation_Rule_Builder { return $this->with_rule( new Datetime_Range_Validation_Rule( $min_datetime, $max_datetime ) ); } @@ -147,7 +148,7 @@ public function with_datetime_range( string $min_datetime, string $max_datetime * * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ - public function with_enum( array $allowed_values, bool $strict = false ): static { + public function with_enum( array $allowed_values, bool $strict = false ): Validation_Rule_Builder { return $this->with_rule( new Enum_Validation_Rule( $allowed_values, $strict ) ); }