BinaryMoon / jarvis

A speedy Gutenberg ready theme
https://prothemedesign.com
GNU General Public License v2.0
51 stars 5 forks source link

Static analysis and other notes #59

Closed szepeviktor closed 4 years ago

szepeviktor commented 5 years ago

add_theme_support, apply_filters are known: https://github.com/szepeviktor/phpstan-wordpress/blob/master/example/phpstan.neon.dist#L29

"Function toolbelt_related_posts_get not found." -> you need to add toolbelt stubs, see https://github.com/szepeviktor/phpstan-wordpress/tree/master/stub-generators for examples

"Function is_woocommerce not found." -> WC stubs generator script is available - link above

wp_get_attachment_image_src really does need 3 args: https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/

on phpstan Level 5: wp_enqueue_style, wp_register_style need an array()

All the best to you!

szepeviktor commented 5 years ago

So:

    ignoreErrors:
        # # Uses func_get_args()
        - '#^Function apply_filters invoked with [34567] parameters, 2 required\.$#'
        - '#^Function add_theme_support invoked with 2 parameters, 1 required\.$#'
szepeviktor commented 5 years ago

+1

All 3 tests miss files outside inc/!

*.php parts/ templates/ inc/

$post->post_parent -> wp_get_post_parent_id( 0 ) maybe?

<?php

        }

?>

template files should use if/endif etc. because the above example is very silent about its intentions :)

if ( ! have_comments() && ! comments_open() return; I think you may return from a template file

BinaryMoon commented 4 years ago

Thanks - took me a while to get the stub generator working.

The woocommerce generator you linked needs to also include the ./packages/ directory. Possibly new since version 3.7

It's throwing up an error that WP_CLI_Command is missing. I included the WP_CLI stubs but that doesn't seem to have solved the problem.

I'm tempted to remove all the automated stubs and just include the missing functions manually. There were only 5 or 6 and it'll be a lot easier to maintain.