From 77d3d93e7ebe952b01cd7744ade5cb754d491779 Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Wed, 1 May 2024 19:33:25 +0200 Subject: [PATCH 1/6] Added selected method to tab field --- README.md | 1 + src/Fields/Tab.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 87877b67..335a0f42 100644 --- a/README.md +++ b/README.md @@ -510,6 +510,7 @@ Tab::make('Tab 1'), Tab::make('Tab 2'), Tab::make('Tab 3') ->placement('top') // top, left + ->selected() // specify which tab should be selected by default ->endpoint(), // This will make a break in the tabs and create a new group of tabs ``` diff --git a/src/Fields/Tab.php b/src/Fields/Tab.php index 7b9a3573..b11c15e1 100644 --- a/src/Fields/Tab.php +++ b/src/Fields/Tab.php @@ -38,4 +38,11 @@ public function placement(string $placement): static return $this; } + + public function selected(): static + { + $this->settings['selected'] = true; + + return $this; + } } From 233bb528da478fef6dca3d86dce0d1de9b920607 Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Wed, 1 May 2024 19:40:28 +0200 Subject: [PATCH 2/6] Test selected method --- tests/Fields/TabTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/Fields/TabTest.php b/tests/Fields/TabTest.php index 23210e7a..126dca87 100644 --- a/tests/Fields/TabTest.php +++ b/tests/Fields/TabTest.php @@ -36,4 +36,10 @@ public function testPlacement() Tab::make('Invalid Placement')->placement('test')->get(); } + + public function testSelected() + { + $field = Tab::make('Selected')->selected()->get(); + $this->assertTrue($field['selected']); + } } From 9ed376a657467f6efb30fb04f9004d7c489850bc Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Wed, 1 May 2024 19:40:34 +0200 Subject: [PATCH 3/6] Fix syntax issues --- src/Fields/Field.php | 6 +++--- src/Fields/Settings/Choices.php | 2 +- src/helpers.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Fields/Field.php b/src/Fields/Field.php index 56de4d32..b018b5a5 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -110,21 +110,21 @@ public function get(string|null $parentKey = null): array if (isset($this->settings['conditional_logic'])) { $this->settings['conditional_logic'] = array_map( - fn($rules) => $rules->get($parentKey), + fn ($rules) => $rules->get($parentKey), $this->settings['conditional_logic'] ); } if (isset($this->settings['layouts'])) { $this->settings['layouts'] = array_map( - fn($layout) => $layout->get($key), + fn ($layout) => $layout->get($key), $this->settings['layouts'] ); } if (isset($this->settings['sub_fields'])) { $this->settings['sub_fields'] = array_map( - fn($field) => $field->get($key), + fn ($field) => $field->get($key), $this->settings['sub_fields'] ); } diff --git a/src/Fields/Settings/Choices.php b/src/Fields/Settings/Choices.php index 80fa1605..a9719668 100644 --- a/src/Fields/Settings/Choices.php +++ b/src/Fields/Settings/Choices.php @@ -23,7 +23,7 @@ trait Choices public function choices(array $choices): static { if (array_is_list($choices)) { - $choices = array_combine(array_map(fn($key) => Key::sanitize($key), $choices), $choices); + $choices = array_combine(array_map(fn ($key) => Key::sanitize($key), $choices), $choices); } $this->settings['choices'] = $choices; diff --git a/src/helpers.php b/src/helpers.php index 9e4696c1..4fe36f6c 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -33,9 +33,9 @@ function register_extended_field_group(array $settings): array $settings['style'] ??= 'seamless'; - $settings['fields'] = array_map(fn($field) => $field->get($key), $settings['fields']); + $settings['fields'] = array_map(fn ($field) => $field->get($key), $settings['fields']); - $settings['location'] = array_map(fn($location) => $location->get(), $settings['location']); + $settings['location'] = array_map(fn ($location) => $location->get(), $settings['location']); $settings['key'] = Key::generate($key, 'group'); From b37b5b77524c7ecb3a32d58ad2b42431438e0363 Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Wed, 1 May 2024 19:42:12 +0200 Subject: [PATCH 4/6] Fix syntax issues --- .php-cs-fixer.cache | 1 + src/Fields/Field.php | 14 +++++++------- src/Fields/Settings/Choices.php | 2 +- src/Fields/Settings/ConditionalLogic.php | 2 +- src/Fields/Settings/Wrapper.php | 2 +- src/Fields/WYSIWYGEditor.php | 2 +- src/helpers.php | 4 ++-- tests/ConditionalLogicTest.php | 14 +++++++------- tests/Fields/Settings/ConditionalLogic.php | 4 ++-- 9 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 .php-cs-fixer.cache diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache new file mode 100644 index 00000000..585386e4 --- /dev/null +++ b/.php-cs-fixer.cache @@ -0,0 +1 @@ +{"php":"8.3.6","version":"3.54.0:v3.54.0#2aecbc8640d7906c38777b3dcab6f4ca79004d08","indent":" ","lineEnding":"\n","rules":{"array_indentation":true,"cast_spaces":true,"concat_space":{"spacing":"one"},"function_declaration":{"closure_fn_spacing":"none"},"method_argument_space":true,"single_line_empty_body":true,"trailing_comma_in_multiline":{"after_heredoc":true,"elements":["arguments","arrays","match","parameters"]},"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true},"hashes":{"src\/Key.php":"305bbe036f637963ef5355562b46621c","src\/ConditionalLogic.php":"bc67c05367e5d4f5361774b12698b6ff","src\/Location.php":"397c7ea396044ac5a2e5f70b95628088","src\/Fields\/Email.php":"b6561781b7414bc8d8b249c45b997a4b","src\/Fields\/WYSIWYGEditor.php":"5e4239971fd414d84a18bc6d4632b506","src\/Fields\/Taxonomy.php":"3e4b6da90b22d647f1b391165e60dbf2","src\/Fields\/Settings\/DateTimeFormat.php":"c003864f2c8fa84c95fa808b00ff93aa","src\/Fields\/Settings\/PreviewSize.php":"88cd5a1f4dba719f2feca123a2f56ccd","src\/Fields\/Settings\/Fields.php":"14fd6ff8e7c762de2cbfb89d998bf932","src\/Fields\/Settings\/Nullable.php":"a6e45657d318f797aa739fb42b0dc447","src\/Fields\/Settings\/DirectionLayout.php":"dadc2ecb794aeffe247ca0f5aea8a4f8","src\/Fields\/Settings\/ButtonLabel.php":"098857d27afcb6942ee9391349eeb650","src\/Fields\/Settings\/Dimensions.php":"76ce45690d01dbc385fee462c45ac4a0","src\/Fields\/Settings\/HelperText.php":"65cebc7d03ad39da5b0037551ce4e9b7","src\/Fields\/Settings\/Step.php":"f20c1bc09752a600beeb65c64c8a40c1","src\/Fields\/Settings\/Library.php":"ef8a4ccbda558fbde14a282239a8e8d9","src\/Fields\/Settings\/MaxLength.php":"b388c4d8758a8be293b146a363c05e62","src\/Fields\/Settings\/NewLines.php":"da1d1573a3be93a368235d3523179900","src\/Fields\/Settings\/Layout.php":"835095553773cec6954af01f0a11f778","src\/Fields\/Settings\/Disabled.php":"0e84e3d0fa9d7936dac5c36271602027","src\/Fields\/Settings\/Placeholder.php":"0715d2cab93f8cd507dd952c73924bcd","src\/Fields\/Settings\/ConditionalLogic.php":"b51c2dc4fe347ba39af338dc6c41adb5","src\/Fields\/Settings\/FileTypes.php":"3db92d7aa12d7637216c9847a09c49c2","src\/Fields\/Settings\/Multiple.php":"4ff450b5a2f396b92c93c041e54e6b7a","src\/Fields\/Settings\/Choices.php":"9dd578e1e9c354206f4b6b5d1eff05e4","src\/Fields\/Settings\/Height.php":"8d02ab56695abf340dc948dfd685b6ac","src\/Fields\/Settings\/Endpoint.php":"44a1048e46bb5fa4ca4938ba4b09d1ad","src\/Fields\/Settings\/Wrapper.php":"1f3a3ba722496ff712d2d33a49cba8be","src\/Fields\/Settings\/WeekDay.php":"79782ca6cf4deb6f004172b9dd390ef7","src\/Fields\/Settings\/Required.php":"a197e6619ba97d1c0dd293e947861a36","src\/Fields\/Settings\/MinMax.php":"8255cf7ff4ff796d6012303626a4153f","src\/Fields\/Settings\/Immutable.php":"074aa97d876947e595bf5a7188366b7e","src\/Fields\/Settings\/FilterBy.php":"b9c3e2f4d6dd70ea1cd8fba21a213fef","src\/Fields\/Settings\/Affixable.php":"90524c567021f5bcb5f909554886aa8b","src\/Fields\/Settings\/DefaultValue.php":"5c2ff92af3f0ff2e56cfb8fd29258261","src\/Fields\/Settings\/FileSize.php":"24162b9ab7bb7a2f4061eb837362bbbf","src\/Fields\/DatePicker.php":"4502521d9415ff5ecd9bc547ea55b853","src\/Fields\/Gallery.php":"3daf1513f1d207678c73995dadc008c8","src\/Fields\/ButtonGroup.php":"35997dd1b0837851ad01b60af6c85c0b","src\/Fields\/Number.php":"683fa8d95c5ff70b6aabac3b35eee7bc","src\/Fields\/Group.php":"b4476c9141086df56fbcc104bd8d083d","src\/Fields\/PageLink.php":"172dc4846e6ba3f7ab8875e3ee71faf8","src\/Fields\/Link.php":"db8139c1fd3b1a1e2814c0bc652438fc","src\/Fields\/Accordion.php":"e131f74509577f4dec1abc0d1e026925","src\/Fields\/DateTimePicker.php":"70a848253e37c203888e0b18b3d16f09","src\/Fields\/File.php":"510753add756244891664390affa9d71","src\/Fields\/PostObject.php":"15e18d72d8d8052e0bc08abf311ff497","src\/Fields\/TimePicker.php":"e5204ad2b8fb74ce1851e6ca336b23fe","src\/Fields\/User.php":"e878667498aca45a496b5e647be3f2dc","src\/Fields\/Tab.php":"55d6c8a7ed88a480378a4c4b4eb22a5d","src\/Fields\/TrueFalse.php":"73221d2eec518e1c754fe5cf0cb2f4c5","src\/Fields\/Repeater.php":"4a15a897297b6112cbe3be19c7e0be27","src\/Fields\/Field.php":"7ddf4b628fc93e468e05d02e25f4c6dd","src\/Fields\/FlexibleContent.php":"1088ee2b4585262dba6d58987d5585ed","src\/Fields\/GoogleMap.php":"5b92cd09586bd7ecb17a28299629d12a","src\/Fields\/URL.php":"9e047204e96ab33a39fb9a4805e91d61","src\/Fields\/Layout.php":"dba7038a49c03c6d74502d61515bd1a2","src\/Fields\/Password.php":"0471e3681750324f03f3c772bfaea0d1","src\/Fields\/Relationship.php":"87c969fe493849fa964b238b572728d9","src\/Fields\/RadioButton.php":"8040bf21b57110fdf8a2d7baadd26f60","src\/Fields\/ColorPicker.php":"66af46113f176bd8ee3d7a3169b8467c","src\/Fields\/Textarea.php":"c2893fa40eb577215f876a118dbf61e7","src\/Fields\/Select.php":"8340079d386c37091b0fd9084baceac6","src\/Fields\/Checkbox.php":"8d40fa8bcc39a6e283036dbd228e3ec4","src\/Fields\/Range.php":"848718e61d2e0e220c554ab4f29dc3d3","src\/Fields\/Oembed.php":"3c055582dafeeefc14b60250841ee2a3","src\/Fields\/Message.php":"8aaa21587c7fbf60b25abb9ce1363d38","src\/Fields\/Text.php":"28b83ea0acbdd2097202eb576c5aa406","src\/Fields\/Image.php":"d57ae5c7b3b1afaa3526db5254ee3ecd","src\/helpers.php":"debc625e7ebb235c5568c964f3ad0616","tests\/KeyTest.php":"fc4000ab8404dae731fb7311bc4625b9","tests\/LocationTest.php":"7217eb356f2d740fc58b023e1f3a9ef0","tests\/HelpersTest.php":"9d26a5a260e18e7d27c1495bd3fc26e3","tests\/ConditionalLogicTest.php":"dceff42299f44b39a689821da23fac5d","tests\/Fields\/Settings\/DateTimeFormat.php":"53852af32172a70f400d0ee8ac510594","tests\/Fields\/Settings\/PreviewSize.php":"4705ccd3334e6ef18d841ab2ba94e0cc","tests\/Fields\/Settings\/Fields.php":"c58da20995bea6ac0f94b8a70abda62a","tests\/Fields\/Settings\/Nullable.php":"0f01c95bf80228181a354cf3cae1524c","tests\/Fields\/Settings\/DirectionLayout.php":"cbaeb4164b8ced54973e5711466705a5","tests\/Fields\/Settings\/ButtonLabel.php":"1e807c520144355b6eb5a2f214cedec9","tests\/Fields\/Settings\/Dimensions.php":"6984779f659d238a4e6b8e934e7cdde3","tests\/Fields\/Settings\/HelperText.php":"45228b1d8fb574e24df4f298edef9939","tests\/Fields\/Settings\/Step.php":"0347c666a925f2b150943c7e2132e7d0","tests\/Fields\/Settings\/Library.php":"869fef43d7022f8f3a88c3dd2ef57cb5","tests\/Fields\/Settings\/MaxLength.php":"138fc1961092a807984334be0e8a0a1e","tests\/Fields\/Settings\/NewLines.php":"37a1a5ae1837f81cdd8e6f5574b7566f","tests\/Fields\/Settings\/Layout.php":"87910da9753fd2e2ef14f29b26eb4c16","tests\/Fields\/Settings\/Disabled.php":"427c77c4a446fa3f078e4bebc6cea968","tests\/Fields\/Settings\/Placeholder.php":"e432d561c5e22723312e0a9f4af2e6b8","tests\/Fields\/Settings\/ConditionalLogic.php":"d2703c670931ed084a06030d8be68c5c","tests\/Fields\/Settings\/FileTypes.php":"8a95df6d85bb2684a730c271ade54805","tests\/Fields\/Settings\/Multiple.php":"043f8909712852cff15ff7e7f365eaf2","tests\/Fields\/Settings\/Choices.php":"e09274644b73ad8a2bfa5edceb3be367","tests\/Fields\/Settings\/Height.php":"93f1826215e5ea209dfe201cd586f749","tests\/Fields\/Settings\/Endpoint.php":"7a404cd65ed4df15d2c4e7f257ced37d","tests\/Fields\/Settings\/Wrapper.php":"17dfb0eb85fdbdfc381909df0d12af91","tests\/Fields\/Settings\/WeekDay.php":"f7be6653284d44038fe04dfb8d2f726e","tests\/Fields\/Settings\/Required.php":"b8f03b9619cc9e8e562e4c254a15b8f3","tests\/Fields\/Settings\/MinMax.php":"c33ab2ad7a485466b373591ee2c7dd40","tests\/Fields\/Settings\/Immutable.php":"b07739907171631bf2718c6b72d8a8cd","tests\/Fields\/Settings\/FilterBy.php":"d3f8d2d3312b6268b4f4d38c7eaacdf8","tests\/Fields\/Settings\/Affixable.php":"26f6a03bbfbf76f2f6b5e8ede4905f6f","tests\/Fields\/Settings\/DefaultValue.php":"0d8ca20ab0db0e9bf6f5eea6a2eaa294","tests\/Fields\/Settings\/FileSize.php":"952019e26c4b3c7c3ddd318ed8ef6312","tests\/Fields\/UserTest.php":"67a562ed14f152b259cae76c46be8568","tests\/Fields\/LinkTest.php":"36e2de08b5d66230b860a576e5e5abd1","tests\/Fields\/TimePickerTest.php":"62ff738d3d0c4fbecd082e88e9e30209","tests\/Fields\/SelectTest.php":"d86fb7dd4c288f29fd94ec0063535a72","tests\/Fields\/RelationshipTest.php":"fb296c7fe532647db9bdfdb670799bee","tests\/Fields\/RangeTest.php":"22664b14e0f0f2380f0474453c52bc23","tests\/Fields\/FieldTestCase.php":"e8f2e55d30f136704c92395ff97993d6","tests\/Fields\/AccordionTest.php":"f51d03a3129306f8cc37ecadebea9f33","tests\/Fields\/FileTest.php":"9868ce244ee92f63d5927b6f2ea0ba7d","tests\/Fields\/TabTest.php":"c1d20f7b8a0c9764d8551e8ba5f01f78","tests\/Fields\/TextTest.php":"86365c3dbdc5bac39f4f35fb34809ef0","tests\/Fields\/MessageTest.php":"cd7f9e8a4b84388aea78cab280d5bbb9","tests\/Fields\/GroupTest.php":"60f8ec00809e923c81c8483fa26f46e3","tests\/Fields\/RadioButtonTest.php":"0c9f177c887d6f8592f62c19d5492c72","tests\/Fields\/CheckboxTest.php":"abe978dccb3000d561a4ac4b25c1792f","tests\/Fields\/EmailTest.php":"985123f2d4486586ffed35626fb0d165","tests\/Fields\/RepeaterTest.php":"d86fa36cb61e53aa80dd9a8d69fe4997","tests\/Fields\/TrueFalseTest.php":"3ca5fb383d6eeaf23d126878a24eefb4","tests\/Fields\/GoogleMapTest.php":"d78b7c3615838fa846fdba1d5f7e4dcc","tests\/Fields\/ImageTest.php":"11701682b8cc560b1aa982db1546b09b","tests\/Fields\/NumberTest.php":"39592ccc9c535f37b1d602c0cc23846e","tests\/Fields\/LayoutTest.php":"d41155a755534b00b3353dded35414dd","tests\/Fields\/DatePickerTest.php":"e4a5512f75dfc0faa33949d33508261d","tests\/Fields\/PageLinkTest.php":"ed4a6670157ea1bb4ba69740fc29da1c","tests\/Fields\/ButtonGroupTest.php":"289578af893c850008d154d32662515a","tests\/Fields\/OembedTest.php":"a50d1f96a52c9c60b36e560249e1dc84","tests\/Fields\/TextareaTest.php":"1f1d32dfd3c5c062bfd1bd878824e4c3","tests\/Fields\/WYSIWYGEditorTest.php":"06e186a7d67bf7ee05a0e0b5955b191b","tests\/Fields\/FlexibleContentTest.php":"b7404407d20ad5048769a85c1a48dd2c","tests\/Fields\/DateTimePickerTest.php":"4661d0d853f902eb77231f2ab96b2168","tests\/Fields\/PostObjectTest.php":"63c9eb876a5e1c5fc735606093c066dc","tests\/Fields\/GalleryTest.php":"8eb1b7ac457e67641f485934102c07ee","tests\/Fields\/URLTest.php":"03a4ea4d6deb51a74a026fa3639aca70","tests\/Fields\/FieldTest.php":"96220e1fa4fabf912658ce9d984a61b0","tests\/Fields\/ColorPickerTest.php":"e4136bba60e3cf9529ce39f70f8f81cd","tests\/Fields\/PasswordTest.php":"5495a4616ab66c6d199c5709ef821e76","tests\/Fields\/TaxonomyTest.php":"61b6b191b17355eadd034318a2f178ae","tests\/helpers.php":"f7ace07629956ac395357252ae3edbff"}} \ No newline at end of file diff --git a/src/Fields/Field.php b/src/Fields/Field.php index b018b5a5..6de20e5f 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -82,7 +82,7 @@ public function key(string $key): static { if (!str_starts_with($key, $this->keyPrefix . '_')) { throw new InvalidArgumentException( - sprintf('The key should have the prefix [%s_].', $this->keyPrefix) + sprintf('The key should have the prefix [%s_].', $this->keyPrefix), ); } @@ -110,22 +110,22 @@ public function get(string|null $parentKey = null): array if (isset($this->settings['conditional_logic'])) { $this->settings['conditional_logic'] = array_map( - fn ($rules) => $rules->get($parentKey), - $this->settings['conditional_logic'] + fn($rules) => $rules->get($parentKey), + $this->settings['conditional_logic'], ); } if (isset($this->settings['layouts'])) { $this->settings['layouts'] = array_map( - fn ($layout) => $layout->get($key), - $this->settings['layouts'] + fn($layout) => $layout->get($key), + $this->settings['layouts'], ); } if (isset($this->settings['sub_fields'])) { $this->settings['sub_fields'] = array_map( - fn ($field) => $field->get($key), - $this->settings['sub_fields'] + fn($field) => $field->get($key), + $this->settings['sub_fields'], ); } diff --git a/src/Fields/Settings/Choices.php b/src/Fields/Settings/Choices.php index a9719668..80fa1605 100644 --- a/src/Fields/Settings/Choices.php +++ b/src/Fields/Settings/Choices.php @@ -23,7 +23,7 @@ trait Choices public function choices(array $choices): static { if (array_is_list($choices)) { - $choices = array_combine(array_map(fn ($key) => Key::sanitize($key), $choices), $choices); + $choices = array_combine(array_map(fn($key) => Key::sanitize($key), $choices), $choices); } $this->settings['choices'] = $choices; diff --git a/src/Fields/Settings/ConditionalLogic.php b/src/Fields/Settings/ConditionalLogic.php index dfe1c748..4312f12a 100644 --- a/src/Fields/Settings/ConditionalLogic.php +++ b/src/Fields/Settings/ConditionalLogic.php @@ -19,7 +19,7 @@ public function conditionalLogic(array $rules): static { $this->settings['conditional_logic'] = array_merge( $this->settings['conditional_logic'] ?? [], - $rules + $rules, ); return $this; diff --git a/src/Fields/Settings/Wrapper.php b/src/Fields/Settings/Wrapper.php index f5c3e602..4d125c3e 100644 --- a/src/Fields/Settings/Wrapper.php +++ b/src/Fields/Settings/Wrapper.php @@ -19,7 +19,7 @@ public function wrapper(array $wrapper): static { $this->settings['wrapper'] = array_merge( $this->settings['wrapper'] ?? [], - $wrapper + $wrapper, ); return $this; diff --git a/src/Fields/WYSIWYGEditor.php b/src/Fields/WYSIWYGEditor.php index e3e59f23..33326da3 100644 --- a/src/Fields/WYSIWYGEditor.php +++ b/src/Fields/WYSIWYGEditor.php @@ -73,7 +73,7 @@ public function toolbar(string|array $toolbar): static $this->settings['toolbar'] = implode('_', $toolbar); add_filter('acf/fields/wysiwyg/toolbars', function ( - array $toolbars + array $toolbars, ) use ($toolbar) { $toolbars[$this->settings['toolbar']] = [ 1 => $toolbar, diff --git a/src/helpers.php b/src/helpers.php index 4fe36f6c..9e4696c1 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -33,9 +33,9 @@ function register_extended_field_group(array $settings): array $settings['style'] ??= 'seamless'; - $settings['fields'] = array_map(fn ($field) => $field->get($key), $settings['fields']); + $settings['fields'] = array_map(fn($field) => $field->get($key), $settings['fields']); - $settings['location'] = array_map(fn ($location) => $location->get(), $settings['location']); + $settings['location'] = array_map(fn($location) => $location->get(), $settings['location']); $settings['key'] = Key::generate($key, 'group'); diff --git a/tests/ConditionalLogicTest.php b/tests/ConditionalLogicTest.php index d9f12a28..fd2701d6 100644 --- a/tests/ConditionalLogicTest.php +++ b/tests/ConditionalLogicTest.php @@ -29,7 +29,7 @@ public function testConditionalLogic() 'field' => 'field_f5456193', 'operator' => '==', 'value' => 10, - ] + ], ]; $this->assertSame($conditionalLogic, ConditionalLogic::where('age', '==', 10)->get('field')); @@ -59,14 +59,14 @@ public function testResolvedParentKey() ->conditionalLogic([ ConditionalLogic::where('select', '==', 'red'), ]), - ]) + ]), ], - 'location' => [] + 'location' => [], ]); $this->assertSame( $settings['fields'][0]['key'], - $settings['fields'][1]['sub_fields'][0]['conditional_logic'][0][0]['field'] + $settings['fields'][1]['sub_fields'][0]['conditional_logic'][0][0]['field'], ); } @@ -84,16 +84,16 @@ public function testFieldKey() name: 'select', operator: '==', value: 'red', - key: 'field_123abc' + key: 'field_123abc', ), ]), ], - 'location' => [] + 'location' => [], ]); $this->assertSame( 'field_123abc', - $settings['fields'][1]['conditional_logic'][0][0]['field'] + $settings['fields'][1]['conditional_logic'][0][0]['field'], ); } } diff --git a/tests/Fields/Settings/ConditionalLogic.php b/tests/Fields/Settings/ConditionalLogic.php index 0f50e43e..76572608 100644 --- a/tests/Fields/Settings/ConditionalLogic.php +++ b/tests/Fields/Settings/ConditionalLogic.php @@ -23,7 +23,7 @@ public function testConditionalLogicExternalGroup() group: 'external', name: 'type', operator: '==empty', - ) + ), ])->get('group'); $this->assertSame('field_21649737', $field['conditional_logic'][0][0]['field']); } @@ -32,7 +32,7 @@ public function testConditionalLogicAnd() { $field = $this->make('Conditional Logic And') ->conditionalLogic([ - \Extended\ACF\ConditionalLogic::where('type', '==', 'video')->and('highlight', '!=', 'true') + \Extended\ACF\ConditionalLogic::where('type', '==', 'video')->and('highlight', '!=', 'true'), ])->get('group'); $this->assertSame('==', $field['conditional_logic'][0][0]['operator']); From 5d3f861bada1a8eb7c277bdfebc9011d8dfb26c9 Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Wed, 1 May 2024 19:42:42 +0200 Subject: [PATCH 5/6] Delete .php-cs-fixer.cache --- .php-cs-fixer.cache | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .php-cs-fixer.cache diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache deleted file mode 100644 index 585386e4..00000000 --- a/.php-cs-fixer.cache +++ /dev/null @@ -1 +0,0 @@ -{"php":"8.3.6","version":"3.54.0:v3.54.0#2aecbc8640d7906c38777b3dcab6f4ca79004d08","indent":" ","lineEnding":"\n","rules":{"array_indentation":true,"cast_spaces":true,"concat_space":{"spacing":"one"},"function_declaration":{"closure_fn_spacing":"none"},"method_argument_space":true,"single_line_empty_body":true,"trailing_comma_in_multiline":{"after_heredoc":true,"elements":["arguments","arrays","match","parameters"]},"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true},"hashes":{"src\/Key.php":"305bbe036f637963ef5355562b46621c","src\/ConditionalLogic.php":"bc67c05367e5d4f5361774b12698b6ff","src\/Location.php":"397c7ea396044ac5a2e5f70b95628088","src\/Fields\/Email.php":"b6561781b7414bc8d8b249c45b997a4b","src\/Fields\/WYSIWYGEditor.php":"5e4239971fd414d84a18bc6d4632b506","src\/Fields\/Taxonomy.php":"3e4b6da90b22d647f1b391165e60dbf2","src\/Fields\/Settings\/DateTimeFormat.php":"c003864f2c8fa84c95fa808b00ff93aa","src\/Fields\/Settings\/PreviewSize.php":"88cd5a1f4dba719f2feca123a2f56ccd","src\/Fields\/Settings\/Fields.php":"14fd6ff8e7c762de2cbfb89d998bf932","src\/Fields\/Settings\/Nullable.php":"a6e45657d318f797aa739fb42b0dc447","src\/Fields\/Settings\/DirectionLayout.php":"dadc2ecb794aeffe247ca0f5aea8a4f8","src\/Fields\/Settings\/ButtonLabel.php":"098857d27afcb6942ee9391349eeb650","src\/Fields\/Settings\/Dimensions.php":"76ce45690d01dbc385fee462c45ac4a0","src\/Fields\/Settings\/HelperText.php":"65cebc7d03ad39da5b0037551ce4e9b7","src\/Fields\/Settings\/Step.php":"f20c1bc09752a600beeb65c64c8a40c1","src\/Fields\/Settings\/Library.php":"ef8a4ccbda558fbde14a282239a8e8d9","src\/Fields\/Settings\/MaxLength.php":"b388c4d8758a8be293b146a363c05e62","src\/Fields\/Settings\/NewLines.php":"da1d1573a3be93a368235d3523179900","src\/Fields\/Settings\/Layout.php":"835095553773cec6954af01f0a11f778","src\/Fields\/Settings\/Disabled.php":"0e84e3d0fa9d7936dac5c36271602027","src\/Fields\/Settings\/Placeholder.php":"0715d2cab93f8cd507dd952c73924bcd","src\/Fields\/Settings\/ConditionalLogic.php":"b51c2dc4fe347ba39af338dc6c41adb5","src\/Fields\/Settings\/FileTypes.php":"3db92d7aa12d7637216c9847a09c49c2","src\/Fields\/Settings\/Multiple.php":"4ff450b5a2f396b92c93c041e54e6b7a","src\/Fields\/Settings\/Choices.php":"9dd578e1e9c354206f4b6b5d1eff05e4","src\/Fields\/Settings\/Height.php":"8d02ab56695abf340dc948dfd685b6ac","src\/Fields\/Settings\/Endpoint.php":"44a1048e46bb5fa4ca4938ba4b09d1ad","src\/Fields\/Settings\/Wrapper.php":"1f3a3ba722496ff712d2d33a49cba8be","src\/Fields\/Settings\/WeekDay.php":"79782ca6cf4deb6f004172b9dd390ef7","src\/Fields\/Settings\/Required.php":"a197e6619ba97d1c0dd293e947861a36","src\/Fields\/Settings\/MinMax.php":"8255cf7ff4ff796d6012303626a4153f","src\/Fields\/Settings\/Immutable.php":"074aa97d876947e595bf5a7188366b7e","src\/Fields\/Settings\/FilterBy.php":"b9c3e2f4d6dd70ea1cd8fba21a213fef","src\/Fields\/Settings\/Affixable.php":"90524c567021f5bcb5f909554886aa8b","src\/Fields\/Settings\/DefaultValue.php":"5c2ff92af3f0ff2e56cfb8fd29258261","src\/Fields\/Settings\/FileSize.php":"24162b9ab7bb7a2f4061eb837362bbbf","src\/Fields\/DatePicker.php":"4502521d9415ff5ecd9bc547ea55b853","src\/Fields\/Gallery.php":"3daf1513f1d207678c73995dadc008c8","src\/Fields\/ButtonGroup.php":"35997dd1b0837851ad01b60af6c85c0b","src\/Fields\/Number.php":"683fa8d95c5ff70b6aabac3b35eee7bc","src\/Fields\/Group.php":"b4476c9141086df56fbcc104bd8d083d","src\/Fields\/PageLink.php":"172dc4846e6ba3f7ab8875e3ee71faf8","src\/Fields\/Link.php":"db8139c1fd3b1a1e2814c0bc652438fc","src\/Fields\/Accordion.php":"e131f74509577f4dec1abc0d1e026925","src\/Fields\/DateTimePicker.php":"70a848253e37c203888e0b18b3d16f09","src\/Fields\/File.php":"510753add756244891664390affa9d71","src\/Fields\/PostObject.php":"15e18d72d8d8052e0bc08abf311ff497","src\/Fields\/TimePicker.php":"e5204ad2b8fb74ce1851e6ca336b23fe","src\/Fields\/User.php":"e878667498aca45a496b5e647be3f2dc","src\/Fields\/Tab.php":"55d6c8a7ed88a480378a4c4b4eb22a5d","src\/Fields\/TrueFalse.php":"73221d2eec518e1c754fe5cf0cb2f4c5","src\/Fields\/Repeater.php":"4a15a897297b6112cbe3be19c7e0be27","src\/Fields\/Field.php":"7ddf4b628fc93e468e05d02e25f4c6dd","src\/Fields\/FlexibleContent.php":"1088ee2b4585262dba6d58987d5585ed","src\/Fields\/GoogleMap.php":"5b92cd09586bd7ecb17a28299629d12a","src\/Fields\/URL.php":"9e047204e96ab33a39fb9a4805e91d61","src\/Fields\/Layout.php":"dba7038a49c03c6d74502d61515bd1a2","src\/Fields\/Password.php":"0471e3681750324f03f3c772bfaea0d1","src\/Fields\/Relationship.php":"87c969fe493849fa964b238b572728d9","src\/Fields\/RadioButton.php":"8040bf21b57110fdf8a2d7baadd26f60","src\/Fields\/ColorPicker.php":"66af46113f176bd8ee3d7a3169b8467c","src\/Fields\/Textarea.php":"c2893fa40eb577215f876a118dbf61e7","src\/Fields\/Select.php":"8340079d386c37091b0fd9084baceac6","src\/Fields\/Checkbox.php":"8d40fa8bcc39a6e283036dbd228e3ec4","src\/Fields\/Range.php":"848718e61d2e0e220c554ab4f29dc3d3","src\/Fields\/Oembed.php":"3c055582dafeeefc14b60250841ee2a3","src\/Fields\/Message.php":"8aaa21587c7fbf60b25abb9ce1363d38","src\/Fields\/Text.php":"28b83ea0acbdd2097202eb576c5aa406","src\/Fields\/Image.php":"d57ae5c7b3b1afaa3526db5254ee3ecd","src\/helpers.php":"debc625e7ebb235c5568c964f3ad0616","tests\/KeyTest.php":"fc4000ab8404dae731fb7311bc4625b9","tests\/LocationTest.php":"7217eb356f2d740fc58b023e1f3a9ef0","tests\/HelpersTest.php":"9d26a5a260e18e7d27c1495bd3fc26e3","tests\/ConditionalLogicTest.php":"dceff42299f44b39a689821da23fac5d","tests\/Fields\/Settings\/DateTimeFormat.php":"53852af32172a70f400d0ee8ac510594","tests\/Fields\/Settings\/PreviewSize.php":"4705ccd3334e6ef18d841ab2ba94e0cc","tests\/Fields\/Settings\/Fields.php":"c58da20995bea6ac0f94b8a70abda62a","tests\/Fields\/Settings\/Nullable.php":"0f01c95bf80228181a354cf3cae1524c","tests\/Fields\/Settings\/DirectionLayout.php":"cbaeb4164b8ced54973e5711466705a5","tests\/Fields\/Settings\/ButtonLabel.php":"1e807c520144355b6eb5a2f214cedec9","tests\/Fields\/Settings\/Dimensions.php":"6984779f659d238a4e6b8e934e7cdde3","tests\/Fields\/Settings\/HelperText.php":"45228b1d8fb574e24df4f298edef9939","tests\/Fields\/Settings\/Step.php":"0347c666a925f2b150943c7e2132e7d0","tests\/Fields\/Settings\/Library.php":"869fef43d7022f8f3a88c3dd2ef57cb5","tests\/Fields\/Settings\/MaxLength.php":"138fc1961092a807984334be0e8a0a1e","tests\/Fields\/Settings\/NewLines.php":"37a1a5ae1837f81cdd8e6f5574b7566f","tests\/Fields\/Settings\/Layout.php":"87910da9753fd2e2ef14f29b26eb4c16","tests\/Fields\/Settings\/Disabled.php":"427c77c4a446fa3f078e4bebc6cea968","tests\/Fields\/Settings\/Placeholder.php":"e432d561c5e22723312e0a9f4af2e6b8","tests\/Fields\/Settings\/ConditionalLogic.php":"d2703c670931ed084a06030d8be68c5c","tests\/Fields\/Settings\/FileTypes.php":"8a95df6d85bb2684a730c271ade54805","tests\/Fields\/Settings\/Multiple.php":"043f8909712852cff15ff7e7f365eaf2","tests\/Fields\/Settings\/Choices.php":"e09274644b73ad8a2bfa5edceb3be367","tests\/Fields\/Settings\/Height.php":"93f1826215e5ea209dfe201cd586f749","tests\/Fields\/Settings\/Endpoint.php":"7a404cd65ed4df15d2c4e7f257ced37d","tests\/Fields\/Settings\/Wrapper.php":"17dfb0eb85fdbdfc381909df0d12af91","tests\/Fields\/Settings\/WeekDay.php":"f7be6653284d44038fe04dfb8d2f726e","tests\/Fields\/Settings\/Required.php":"b8f03b9619cc9e8e562e4c254a15b8f3","tests\/Fields\/Settings\/MinMax.php":"c33ab2ad7a485466b373591ee2c7dd40","tests\/Fields\/Settings\/Immutable.php":"b07739907171631bf2718c6b72d8a8cd","tests\/Fields\/Settings\/FilterBy.php":"d3f8d2d3312b6268b4f4d38c7eaacdf8","tests\/Fields\/Settings\/Affixable.php":"26f6a03bbfbf76f2f6b5e8ede4905f6f","tests\/Fields\/Settings\/DefaultValue.php":"0d8ca20ab0db0e9bf6f5eea6a2eaa294","tests\/Fields\/Settings\/FileSize.php":"952019e26c4b3c7c3ddd318ed8ef6312","tests\/Fields\/UserTest.php":"67a562ed14f152b259cae76c46be8568","tests\/Fields\/LinkTest.php":"36e2de08b5d66230b860a576e5e5abd1","tests\/Fields\/TimePickerTest.php":"62ff738d3d0c4fbecd082e88e9e30209","tests\/Fields\/SelectTest.php":"d86fb7dd4c288f29fd94ec0063535a72","tests\/Fields\/RelationshipTest.php":"fb296c7fe532647db9bdfdb670799bee","tests\/Fields\/RangeTest.php":"22664b14e0f0f2380f0474453c52bc23","tests\/Fields\/FieldTestCase.php":"e8f2e55d30f136704c92395ff97993d6","tests\/Fields\/AccordionTest.php":"f51d03a3129306f8cc37ecadebea9f33","tests\/Fields\/FileTest.php":"9868ce244ee92f63d5927b6f2ea0ba7d","tests\/Fields\/TabTest.php":"c1d20f7b8a0c9764d8551e8ba5f01f78","tests\/Fields\/TextTest.php":"86365c3dbdc5bac39f4f35fb34809ef0","tests\/Fields\/MessageTest.php":"cd7f9e8a4b84388aea78cab280d5bbb9","tests\/Fields\/GroupTest.php":"60f8ec00809e923c81c8483fa26f46e3","tests\/Fields\/RadioButtonTest.php":"0c9f177c887d6f8592f62c19d5492c72","tests\/Fields\/CheckboxTest.php":"abe978dccb3000d561a4ac4b25c1792f","tests\/Fields\/EmailTest.php":"985123f2d4486586ffed35626fb0d165","tests\/Fields\/RepeaterTest.php":"d86fa36cb61e53aa80dd9a8d69fe4997","tests\/Fields\/TrueFalseTest.php":"3ca5fb383d6eeaf23d126878a24eefb4","tests\/Fields\/GoogleMapTest.php":"d78b7c3615838fa846fdba1d5f7e4dcc","tests\/Fields\/ImageTest.php":"11701682b8cc560b1aa982db1546b09b","tests\/Fields\/NumberTest.php":"39592ccc9c535f37b1d602c0cc23846e","tests\/Fields\/LayoutTest.php":"d41155a755534b00b3353dded35414dd","tests\/Fields\/DatePickerTest.php":"e4a5512f75dfc0faa33949d33508261d","tests\/Fields\/PageLinkTest.php":"ed4a6670157ea1bb4ba69740fc29da1c","tests\/Fields\/ButtonGroupTest.php":"289578af893c850008d154d32662515a","tests\/Fields\/OembedTest.php":"a50d1f96a52c9c60b36e560249e1dc84","tests\/Fields\/TextareaTest.php":"1f1d32dfd3c5c062bfd1bd878824e4c3","tests\/Fields\/WYSIWYGEditorTest.php":"06e186a7d67bf7ee05a0e0b5955b191b","tests\/Fields\/FlexibleContentTest.php":"b7404407d20ad5048769a85c1a48dd2c","tests\/Fields\/DateTimePickerTest.php":"4661d0d853f902eb77231f2ab96b2168","tests\/Fields\/PostObjectTest.php":"63c9eb876a5e1c5fc735606093c066dc","tests\/Fields\/GalleryTest.php":"8eb1b7ac457e67641f485934102c07ee","tests\/Fields\/URLTest.php":"03a4ea4d6deb51a74a026fa3639aca70","tests\/Fields\/FieldTest.php":"96220e1fa4fabf912658ce9d984a61b0","tests\/Fields\/ColorPickerTest.php":"e4136bba60e3cf9529ce39f70f8f81cd","tests\/Fields\/PasswordTest.php":"5495a4616ab66c6d199c5709ef821e76","tests\/Fields\/TaxonomyTest.php":"61b6b191b17355eadd034318a2f178ae","tests\/helpers.php":"f7ace07629956ac395357252ae3edbff"}} \ No newline at end of file From cf60423948ac115a14f80fbb8a97e08f4bfe4c17 Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Thu, 2 May 2024 07:38:19 +0200 Subject: [PATCH 6/6] Update gutenberg-block.php --- examples/gutenberg-block.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gutenberg-block.php b/examples/gutenberg-block.php index cf2c182d..0d5b997c 100644 --- a/examples/gutenberg-block.php +++ b/examples/gutenberg-block.php @@ -14,9 +14,9 @@ 'fields' => [ PostObject::make('Employee') ->postTypes(['employee']) - ->format('object') + ->format('object'), ], 'location' => [ - Location::where('block', 'acf/employee') + Location::where('block', 'acf/employee'), ], ]);