htmlburger / carbon-fields

WordPress Custom Fields Library ✨
https://carbonfields.net/
Other
1.38k stars 245 forks source link

Carbon_Fields\Field\Field missing methods (`->set_value_type()`, `->set_layout()`, `->add_fields()`) #1189

Open npirlot opened 1 year ago

npirlot commented 1 year ago

Version

Expected Behavior

Make all possible methods chained to a Field::make() which yields a Carbon_Fields\Field\Field available in IDE, by applying all possible methods and definitions to themain class.

Actual Behavior

In VSCODE with Intelephense, methods ->set_value_type(), ->set_layout() and ->add_fields() chained to a Field::make( 'image' ... ) or Field::make( 'complex', ...) are not recognised as available methods for Carbon_Fields\Field\Field.

Container definition

Container::make( 'post_meta', __('Home Page') )
->where( 'post_type', '=', 'page' )
->where( 'post_template', '=', 'templates/page-home.php' )
->add_tab(__('Banner'), array(
    Field::make( 'complex', 'banner_elements', 'Banner Elements' )->set_layout('tabbed-horizontal')
    ->add_fields(array(
        Field::make( 'image', 'banner_bg_image', 'Banner Background Image' )->set_value_type( 'url' )->set_width(33),
        Field::make('text', 'banner_heading', 'Banner Heading')->set_width(33),
        Field::make('rich_text', 'banner_sub_heading', 'Banner Sub Heading')->set_width(33),
    ))
    ->set_header_template('
        <% if (banner_heading) { %>
            <%- banner_heading %>
        <% } else { %>
            empty
        <% } %>
    ')
))

Steps to Reproduce the Problem

none, this is an IDE issue

Comments

Preview in VSCODE: image

This issue does not cause failures when running the code, however it would be great that the IDE would not indicate these methods, that are in fact available, as problematic/errors.

pairdesign commented 6 months ago

Hello @npirlot, Have you found a fix for this issue? I went looking for stubs online but could not find any. I believe this issue would not occur if you were using software such as PHPStorm that has much better introspection than VSC.