Skip to content
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

Unused function parameter only for after-used functions (not for before used) #57

Closed
kkmuffme opened this issue Dec 21, 2018 · 5 comments

Comments

@kkmuffme
Copy link

let's say I have this: (this is a Wordpress specific example, but can happen anywhere, but since it's so prominently used in WP on every action/filter it helps outline the significance of this)

add_action( 'delete_post_meta', 'check_thumbnail_updated_post_meta', -1000, 3 );
function check_thumbnail_updated_post_meta( $meta_id, $post_id, $meta_key ) {
    echo $post_id;
    echo $meta_key;
}

Eslint has a handling for this (no-unused-vars with after-use, you mention this here: #21 (comment)) which would be exactly what we also would need here in this php check.
So basically if any of the variables is used, then it can discard previous errors for unused vars in this call.

@sirbrillig
Copy link
Owner

Thanks for the report! I think I had meant to do this earlier but forgot. I've started work on this in #58

@kkmuffme
Copy link
Author

Thanks, however I think "true" should be the default value (as it is in eslint), since usually if later args are used that there are external constraints causing us to not use before args.

@sirbrillig
Copy link
Owner

That's a good point. I was thinking that it's better to make something that ignores warnings an opt-in behavior, but I realized that it's probably pretty rare that these particular warnings are useful.

@sirbrillig
Copy link
Owner

#59 should take care of this.

@kkmuffme
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants