generator icon indicating copy to clipboard operation
generator copied to clipboard

Adjust logic targeting inaccessible nodes

Open the-csaba opened this issue 2 years ago • 2 comments

Changes

  • Loosen parent check from Class_ to ClassLike to include Traits, Interfaces, and Enums.
  • Remove protected nodes, regardless if the class is final or not.
  • Adjust test

Reason

Unfortunately, sometimes developers define protected or private methods in interfaces or traits.

I'm looking at you WooCommerce:

Fatal error: Class WC_Cart_Totals contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (WC_Cart_Totals::get_values_for_total) in woocommerce-stubs.php on line 15030

The missing abstract method (get_values_for_total) is defined in a trait: https://github.com/woocommerce/woocommerce/blob/c4a7e9a11b62e9f62fd507f5a0c8ae09740619a0/plugins/woocommerce/includes/traits/trait-wc-item-totals.php#L32

the-csaba avatar Apr 12 '23 05:04 the-csaba

Thank you for your contribution!

I've given up on WC and disabled this feature, thus including inaccessible things.

Could WC stubs be executed with this PR? https://github.com/php-stubs/woocommerce-stubs/blob/8f81c28808986d63aeb627692e17b5b7880913ab/.travis.yml#L39

szepeviktor avatar Apr 12 '23 06:04 szepeviktor

Remove protected nodes, regardless if the class is final or not.

What is someone extends a WC class with protected methods? Will this introduce static analysis errors?

szepeviktor avatar Apr 12 '23 06:04 szepeviktor