Adjust logic targeting inaccessible nodes
Changes
- Loosen parent check from
Class_toClassLiketo includeTraits,Interfaces, andEnums. - 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
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
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?