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

Add WP discouraged functions rule #724

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions phpcs-rulesets/plugin-review.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@
<severity>7</severity>
</rule>

<!-- Check for discouraged WordPress functions. -->
<rule ref="WordPress.WP.DiscouragedFunctions">
<severity>6</severity>
</rule>

<!-- Check for usage of deprecated parameter values in WP functions and provide alternative based on the parameter passed. -->
<rule ref="WordPress.WP.DeprecatedParameterValues">
<severity>7</severity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@

var_dump( $custom_var );
error_log( 'Error occurred.');

query_posts( 'cat=3' );
wp_reset_query();
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public function test_run_with_errors() {

// Check for WordPress.PHP.DevelopmentFunctions.error_log_error_log warning on Line no 23 and column no at 1.
$this->assertSame( 'WordPress.PHP.DevelopmentFunctions.error_log_error_log', $warnings['load.php'][23][1][0]['code'] );

// Check for WordPress.WP.DiscouragedFunctions.query_posts_query_posts warning on Line no 25 and column no at 1.
$this->assertSame( 'WordPress.WP.DiscouragedFunctions.query_posts_query_posts', $warnings['load.php'][25][1][0]['code'] );

// Check for WordPress.WP.DiscouragedFunctions.wp_reset_query_wp_reset_query warning on Line no 26 and column no at 1.
$this->assertSame( 'WordPress.WP.DiscouragedFunctions.wp_reset_query_wp_reset_query', $warnings['load.php'][26][1][0]['code'] );
}

public function test_run_without_errors() {
Expand Down