-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Review the WordPressVIPMinimum.Classes.DeclarationCompatibility sniff #507
Comments
Noticed the following three things while looking at this sniff for something unrelated: No parameter name checkLooks like the parameter name as declared in a child class is not checked against the parameter name in the parent class, while in the context of PHP 8.0 named parameters and these methods potentially being called via Signature checks are incompleteAlso looks like the signature checks are incomplete. For example: it only checks if a parameter is declared to be passed by reference when the parameter in the parent class is declared to be passed by reference, while, when the parameter in the parent is not passed by reference, we should also make sure that the parameter in the overloaded method in the child class is also not passed by reference (currently it could well be, which is wrong and will not be flagged as-is). VIP-Coding-Standards/WordPressVIPMinimum/Sniffs/Classes/DeclarationCompatibilitySniff.php Lines 270 to 281 in 9749b01
Check for type declarationsIIRC, none of the parameters in the parent classes have type declarations. We should make sure that the methods in child classes also don't have type declarations as that would violate the contravariance rules and potentially cause a fatal error. Return type declarations are fine as those are covariant. |
Also note that this class definitely needs a lot more tests. |
While looking at this sniff for something unrelated, I started wondering if the signature definitions were still in line with WP Core. Turned out they were not. Refs: * https://developer.wordpress.org/reference/classes/wp_widget/wp_widget/ * https://developer.wordpress.org/reference/classes/walker/start_el/ * https://developer.wordpress.org/reference/classes/walker/end_el/ * https://developer.wordpress.org/reference/classes/walker/unset_children/ Also see the [additional notes I've added to the review ticket](#507 (comment)).
While looking at this sniff for something unrelated, I started wondering if the signature definitions were still in line with WP Core. Turned out they were not, though with the current checks being done in the sniff, this wasn't necessarily problematic (though it should have been, but that's for another PR). Also see the [additional notes I've added to the review ticket](#507 (comment)). Refs: * https://developer.wordpress.org/reference/classes/wp_widget/wp_widget/ * https://developer.wordpress.org/reference/classes/walker/start_el/ * https://developer.wordpress.org/reference/classes/walker/end_el/ * https://developer.wordpress.org/reference/classes/walker/unset_children/
While looking at this sniff for something unrelated, I started wondering if the signature definitions were still in line with WP Core. Turned out they were not, though with the current checks being done in the sniff, this wasn't necessarily problematic (though it should have been, but that's for another PR). Also see the [additional notes I've added to the review ticket](#507 (comment)). Refs: * https://developer.wordpress.org/reference/classes/wp_widget/wp_widget/ * https://developer.wordpress.org/reference/classes/walker/start_el/ * https://developer.wordpress.org/reference/classes/walker/end_el/ * https://developer.wordpress.org/reference/classes/walker/unset_children/
Review the
WordPressVIPMinimum.Classes.DeclarationCompatibility
sniff for the following in as far as relevant to that sniff:Typical things to add tests for and verify correct handling of:
list
statementsTypical things to add tests for and verify correct handling of (where applicable):
::class
use function/const
Other:
Sniff basics, but changes need to be lined up for next major release:
public
properties (Audit Public Sniff Properties #234)Once PHPCS/PHPCSUtils supports this:
match
expressionsThe text was updated successfully, but these errors were encountered: