Skip to content

Commit c263125

Browse files
committed
PHPCS: Update ruleset to exclude calsses from NamingConventions sniff
Fix CS in src/WP_CLI/Fetchers
1 parent 3dcdde1 commit c263125

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

phpcs.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,8 @@
5151
</properties>
5252
</rule>
5353

54+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound">
55+
<exclude-pattern>*/src/WP_CLI/Fetchers/(Comment|Post|Site|User)\.php$</exclude-pattern>
56+
</rule>
57+
5458
</ruleset>

src/WP_CLI/Fetchers/Comment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ class Comment extends Base {
1010
/**
1111
* @var string $msg Error message to use when invalid data is provided
1212
*/
13-
protected $msg = "Could not find the comment with ID %d.";
13+
protected $msg = 'Could not find the comment with ID %d.';
1414

1515
/**
1616
* Get a comment object by ID
17-
*
17+
*
1818
* @param int $arg
1919
* @return object|false
2020
*/
2121
public function get( $arg ) {
2222
$comment_id = (int) $arg;
23-
$comment = get_comment( $comment_id );
23+
$comment = get_comment( $comment_id );
2424

2525
if ( is_null( $comment ) ) {
2626
return false;

src/WP_CLI/Fetchers/Post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ class Post extends Base {
1010
/**
1111
* @var string $msg Error message to use when invalid data is provided
1212
*/
13-
protected $msg = "Could not find the post with ID %d.";
13+
protected $msg = 'Could not find the post with ID %d.';
1414

1515
/**
1616
* Get a post object by ID
17-
*
17+
*
1818
* @param int $arg
1919
* @return WP_Post|false
2020
*/

src/WP_CLI/Fetchers/Site.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,36 @@ class Site extends Base {
1010
/**
1111
* @var string $msg Error message to use when invalid data is provided
1212
*/
13-
protected $msg = "Could not find the site with ID %d.";
13+
protected $msg = 'Could not find the site with ID %d.';
1414

1515
/**
1616
* Get a site object by ID
17-
*
17+
*
1818
* @param int $site_id
1919
* @return object|false
2020
*/
2121
public function get( $site_id ) {
22-
return $this->_get_site( $site_id );
22+
return $this->get_site( $site_id );
2323
}
24-
24+
2525
/**
2626
* Get site (blog) data for a given id.
2727
*
2828
* @param int $site_id
2929
* @return bool|array False if no site found with given id, array otherwise
3030
*/
31-
private function _get_site( $site_id ) {
31+
private function get_site( $site_id ) {
3232
global $wpdb;
3333

3434
// Load site data
35-
$site = $wpdb->get_row( $wpdb->prepare(
36-
"SELECT * FROM $wpdb->blogs WHERE blog_id = %d", $site_id ) );
35+
$site = $wpdb->get_row(
36+
$wpdb->prepare(
37+
"SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d",
38+
$site_id
39+
)
40+
);
3741

38-
if ( !empty( $site ) ) {
42+
if ( ! empty( $site ) ) {
3943
// Only care about domain and path which are set here
4044
return $site;
4145
}

src/WP_CLI/Fetchers/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class User extends Base {
1414

1515
/**
1616
* Get a user object by one of its identifying attributes
17-
*
17+
*
1818
* @param mixed $id_email_or_login
1919
* @return WP_User|false
2020
*/

0 commit comments

Comments
 (0)