You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Post retrieval limited to 5 posts made its way into production briefly.
Describe the solution you'd like
AbstractFunctionRestrictionSniff to make a call to [ static::class, 'defaulted_callback' ] in the case of that function being defined in sub-classes, making it simple to construct sniffs which warn of certain default arguments - such as 'numberposts' in PostsPerPageSniff.
[?] I intend to create a pull request to implement this feature.
The text was updated successfully, but these errors were encountered:
@claimableperch Thanks for opening this issue, but it is completely unclear to me what you are suggesting. On the one hand you talk about "your" code (post retrieval ... made it to production), on the other hand you talk about an abstract sniff, without it being clear what you expect to happen. And the "subject" of the issue mentioning some code pattern without any context, also doesn't help.
Let's take a step back:
What is the code pattern in the "code under scan" (=your code) which you would hope WPCS to detect ? i.e. please add one or more code samples of code which should be flagged.
Once that pattern is clear, let's talk about whether this is possible and if so, how.
e.g. When ! isset( $args[ 'numberposts' ] ) Then get_posts( $args ) will get you five posts.
I guess I was just wishing that wp_parse_args( $args, $defaults ) rang around and dragged me out of hyperspace by itself.
It's really more an IDE-completion sort of thing. But unless you filter them all, it also isn't. Real question is why I posted it to this repository. So I guess it's all too real.
Is your feature request related to a problem?
Post retrieval limited to 5 posts made its way into production briefly.
Describe the solution you'd like
AbstractFunctionRestrictionSniff to make a call to [ static::class, 'defaulted_callback' ] in the case of that function being defined in sub-classes, making it simple to construct sniffs which warn of certain default arguments - such as 'numberposts' in PostsPerPageSniff.
The text was updated successfully, but these errors were encountered: