Skip to content

Commit

Permalink
🚨 Fix type hinting to support PHP 7.4 again
Browse files Browse the repository at this point in the history
  • Loading branch information
MatzeKitt committed Dec 21, 2024
1 parent 68e1cfa commit 1bb9744
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion inc/block-data/class-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public function set( int $post_id, WP_Post $post ): WP_Post {
* @param mixed $new_value The new option value
* @return mixed The new option value
*/
public function set_for_widget( mixed $old_value, mixed $new_value ): mixed {
public function set_for_widget( mixed $old_value, mixed $new_value ) { // phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint
if ( ! \is_array( $new_value ) ) {
return $new_value;
}
Expand Down
2 changes: 1 addition & 1 deletion inc/class-form-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public function reset_block_name_attributes(): void {
* @param string $context The context
* @return array[]|string The updated allowed tags
*/
public function set_allow_tags( array|string $tags, string $context ): array|string {
public function set_allow_tags( array|string $tags, string $context ) { // phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint
if ( $context !== 'post' ) {
return $tags;
}
Expand Down
6 changes: 3 additions & 3 deletions inc/form-data/class-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private static function format_output( mixed $value, string $label, int $level =
* @param array $values List of values
* @return array|string Merged values without numeric keys
*/
private static function get_list_values( array $values ): array|string {
private static function get_list_values( array $values ) { // phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint
$new_value = [];
$string_value = '';

Expand Down Expand Up @@ -200,7 +200,7 @@ private static function get_list_values( array $values ): array|string {
* @param string[] $structure Target structure in a flat version
* @return array|string Matching value
*/
private static function get_matching_value( array|string $value, array $structure ): array|string {
private static function get_matching_value( array|string $value, array $structure ) { // phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint
if ( empty( $structure ) ) {
return $value;
}
Expand Down Expand Up @@ -234,7 +234,7 @@ private static function get_matching_value( array|string $value, array $structur
* @param mixed[] $field Field data
* @return mixed The value if the field exists, or false otherwise
*/
private static function get_matching_post_field_values( array $post_fields, array $field ): mixed {
private static function get_matching_post_field_values( array $post_fields, array $field ) { // phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint
$current = $post_fields;
$keys = self::parse_field_name( $field['name'] );
$structure = [];
Expand Down
2 changes: 1 addition & 1 deletion inc/modules/class-custom-date.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public static function set_markup( string $block_content, array $block ): string
* @param array $form_fields Form fields
* @return mixed Output in proper format
*/
public static function set_output_format( mixed $value, string $name, array $form_fields ): mixed {
public static function set_output_format( mixed $value, string $name, array $form_fields ) { // phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint
$field = Field::get_by_name( $name, $form_fields );

if ( ! isset( $field['type'] ) || ! \in_array( $field['type'], self::$field_types, true ) ) {
Expand Down
2 changes: 1 addition & 1 deletion inc/util/class-array-operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function filter_recursive( array $input ): array {
* @param array $array Array to get value from
* @return mixed Most nested value
*/
public static function get_most_nested_value( array $array ): mixed {
public static function get_most_nested_value( array $array ) { // phpcs:ignore SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint
$end = \end( $array );

if ( \is_array( $end ) ) {
Expand Down

0 comments on commit 1bb9744

Please sign in to comment.