| @@ -17,14 +17,8 @@ | ||
| 17 | 17 | class Style_Schema { |
| 18 | 18 | public function augment( array $schema ): array { |
| 19 | 19 | foreach ( $schema as $key => $prop_type ) { |
| 20 | 20 | $schema[ $key ] = $this->update( $prop_type ); |
| 21 | - if ( method_exists( $prop_type, 'get_meta' ) && method_exists( $schema[ $key ], 'meta' ) ) { | |
| 22 | - $meta = $schema[ $key ]->get_meta() ?? []; | |
| 23 | - foreach ( $meta as $meta_key => $meta_value ) { | |
| 24 | - $schema[ $key ]->meta( $meta_key, $meta_value ); | |
| 25 | - } | |
| 26 | - } | |
| 27 | 21 | } |
| 28 | 22 | |
| 29 | 23 | if ( isset( $schema['font-family'] ) ) { |
| 30 | 24 | $schema['font-family'] = $this->update_font_family( $schema['font-family'] ); |
| @@ -52,25 +46,16 @@ | ||
| 52 | 46 | |
| 53 | 47 | return $prop_type; |
| 54 | 48 | } |
| 55 | 49 | |
| 56 | - private function update_font_family( $prop_type ): Union_Prop_Type { | |
| 57 | - | |
| 58 | - if ( $prop_type instanceof String_Prop_Type ) { | |
| 59 | - return Union_Prop_Type::create_from( $prop_type ) | |
| 60 | - ->add_prop_type( Font_Variable_Prop_Type::make() ); | |
| 61 | - } | |
| 62 | - | |
| 63 | - if ( $prop_type instanceof Union_Prop_Type ) { | |
| 64 | - $prop_type->add_prop_type( Font_Variable_Prop_Type::make() ); | |
| 65 | - } | |
| 66 | - | |
| 67 | - return $prop_type; | |
| 50 | + private function update_font_family( String_Prop_Type $prop_type ): Union_Prop_Type { | |
| 51 | + return Union_Prop_Type::create_from( $prop_type ) | |
| 52 | + ->add_prop_type( Font_Variable_Prop_Type::make() ); | |
| 68 | 53 | } |
| 69 | 54 | |
| 70 | 55 | private function update_color( Color_Prop_Type $color_prop_type ): Union_Prop_Type { |
| 71 | 56 | return Union_Prop_Type::create_from( $color_prop_type ) |
| 72 | - ->add_prop_type( Color_Variable_Prop_Type::make() ); | |
| 57 | + ->add_prop_type( Color_Variable_Prop_Type::make() ); | |
| 73 | 58 | } |
| 74 | 59 | |
| 75 | 60 | private function update_array( Array_Prop_Type $array_prop_type ): Array_Prop_Type { |
| 76 | 61 | return $array_prop_type->set_item_type( |
| @@ -84,17 +69,23 @@ | ||
| 84 | 69 | ); |
| 85 | 70 | } |
| 86 | 71 | |
| 87 | 72 | private function update_union( Union_Prop_Type $union_prop_type ): Union_Prop_Type { |
| 73 | + $new_union = Union_Prop_Type::make(); | |
| 74 | + | |
| 88 | 75 | foreach ( $union_prop_type->get_prop_types() as $prop_type ) { |
| 89 | 76 | $updated = $this->update( $prop_type ); |
| 90 | 77 | |
| 91 | 78 | if ( $updated instanceof Union_Prop_Type ) { |
| 92 | 79 | foreach ( $updated->get_prop_types() as $updated_prop_type ) { |
| 93 | - $union_prop_type->add_prop_type( $updated_prop_type ); | |
| 80 | + $new_union->add_prop_type( $updated_prop_type ); | |
| 94 | 81 | } |
| 82 | + | |
| 83 | + continue; | |
| 95 | 84 | } |
| 85 | + | |
| 86 | + $new_union->add_prop_type( $updated ); | |
| 96 | 87 | } |
| 97 | 88 | |
| 98 | - return $union_prop_type; | |
| 89 | + return $new_union; | |
| 99 | 90 | } |
| 100 | 91 | } |