Skip to content

Commit 9467545

Browse files
pfefferleobenland
andauthored
Allow short ternary (Elvis) operator in codebase (#2436)
Co-authored-by: Konstantin Obenland <[email protected]>
1 parent 50e6c62 commit 9467545

File tree

16 files changed

+12
-29
lines changed

16 files changed

+12
-29
lines changed

build/followers/render.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ function ( $follower ) {
6464
return array(
6565
'handle' => '@' . $username,
6666
'icon' => $actor->get_icon(),
67-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
6867
'name' => $actor->get_name() ?: $username,
69-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
7068
'url' => object_to_uri( $actor->get_url() ) ?: $actor->get_id(),
7169
);
7270
},

includes/class-avatars.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function pre_get_avatar_data( $args, $id_or_email ) {
4343
* @param array $allowed_comment_types Array of allowed comment types.
4444
*/
4545
$allowed_comment_types = \apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
46-
if ( ! \in_array( $id_or_email->comment_type ?: 'comment', $allowed_comment_types, true ) ) { // phpcs:ignore Universal.Operators.DisallowShortTernary
46+
if ( ! \in_array( $id_or_email->comment_type ?: 'comment', $allowed_comment_types, true ) ) {
4747
return $args;
4848
}
4949

includes/class-moderation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static function add_user_block( $user_id, $type, $value ) {
116116

117117
case self::TYPE_DOMAIN:
118118
case self::TYPE_KEYWORD:
119-
$blocks = \get_user_meta( $user_id, self::USER_META_KEYS[ $type ], true ) ?: array(); // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
119+
$blocks = \get_user_meta( $user_id, self::USER_META_KEYS[ $type ], true ) ?: array();
120120

121121
if ( ! \in_array( $value, $blocks, true ) ) {
122122
/**
@@ -152,7 +152,7 @@ public static function remove_user_block( $user_id, $type, $value ) {
152152

153153
case self::TYPE_DOMAIN:
154154
case self::TYPE_KEYWORD:
155-
$blocks = \get_user_meta( $user_id, self::USER_META_KEYS[ $type ], true ) ?: array(); // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
155+
$blocks = \get_user_meta( $user_id, self::USER_META_KEYS[ $type ], true ) ?: array();
156156
$key = \array_search( $value, $blocks, true );
157157

158158
if ( false !== $key ) {
@@ -183,8 +183,8 @@ public static function remove_user_block( $user_id, $type, $value ) {
183183
public static function get_user_blocks( $user_id ) {
184184
return array(
185185
'actors' => \wp_list_pluck( Blocked_Actors::get_many( $user_id ), 'guid' ),
186-
'domains' => \get_user_meta( $user_id, self::USER_META_KEYS[ self::TYPE_DOMAIN ], true ) ?: array(), // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
187-
'keywords' => \get_user_meta( $user_id, self::USER_META_KEYS[ self::TYPE_KEYWORD ], true ) ?: array(), // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
186+
'domains' => \get_user_meta( $user_id, self::USER_META_KEYS[ self::TYPE_DOMAIN ], true ) ?: array(),
187+
'keywords' => \get_user_meta( $user_id, self::USER_META_KEYS[ self::TYPE_KEYWORD ], true ) ?: array(),
188188
);
189189
}
190190

includes/class-move.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ public static function internally( $from, $to ) {
172172
* @param string $from The current account URL.
173173
*/
174174
private static function update_user_also_known_as( $user_id, $from ) {
175-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
176175
$also_known_as = \get_user_option( 'activitypub_also_known_as', $user_id ) ?: array();
177176
$also_known_as[] = $from;
178177

includes/collection/class-inbox.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,9 @@ private static function get_object_title( $activity_object ) {
143143
return $post_id ? \get_the_title( $post_id ) : '';
144144
}
145145

146-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
147146
$title = $activity_object->get_name() ?: $activity_object->get_content();
148147

149148
if ( ! $title && $activity_object->get_object() instanceof Base_Object ) {
150-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
151149
$title = $activity_object->get_object()->get_name() ?: $activity_object->get_object()->get_content();
152150
}
153151

includes/collection/class-outbox.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,9 @@ private static function get_object_title( $activity_object ) {
385385
return $post_id ? get_the_title( $post_id ) : '';
386386
}
387387

388-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
389388
$title = $activity_object->get_name() ?: $activity_object->get_content();
390389

391390
if ( ! $title && $activity_object->get_object() instanceof Base_Object ) {
392-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
393391
$title = $activity_object->get_object()->get_name() ?: $activity_object->get_object()->get_content();
394392
}
395393

includes/collection/class-remote-actors.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,6 @@ private static function prepare_custom_post_type( $actor ) {
527527

528528
return array(
529529
'guid' => \esc_url_raw( $actor->get_id() ),
530-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
531530
'post_title' => \wp_strip_all_tags( \wp_slash( $actor->get_name() ?: $actor->get_preferred_username() ) ),
532531
'post_author' => 0,
533532
'post_type' => self::POST_TYPE,

includes/model/class-user.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@ public function get_also_known_as() {
452452
$this->get_alternate_url(),
453453
);
454454

455-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
456455
$also_known_as = array_merge( $also_known_as, \get_user_option( 'activitypub_also_known_as', $this->_id ) ?: array() );
457456

458457
return array_unique( $also_known_as );

includes/transformer/class-post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ protected function get_context() {
891891
*/
892892
protected function get_post_content_template() {
893893
$content = \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT );
894-
$template = $content ?: ACTIVITYPUB_CUSTOM_POST_CONTENT; // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
894+
$template = $content ?: ACTIVITYPUB_CUSTOM_POST_CONTENT;
895895

896896
$post_format_setting = \get_option( 'activitypub_object_type', ACTIVITYPUB_DEFAULT_OBJECT_TYPE );
897897
$type = $this->get_type();

includes/wp-admin/table/class-blocked-actors.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,8 @@ public function prepare_items() {
231231
$this->items[] = array(
232232
'id' => $blocked_actor_post->ID,
233233
'icon' => object_to_uri( $actor->get_icon() ?? ACTIVITYPUB_PLUGIN_URL . 'assets/img/mp.jpg' ),
234-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
235234
'post_title' => $actor->get_name() ?: $actor->get_preferred_username(),
236235
'username' => $actor->get_preferred_username(),
237-
// phpcs:ignore Universal.Operators.DisallowShortTernary.Found
238236
'url' => object_to_uri( $actor->get_url() ?: $actor->get_id() ),
239237
'webfinger' => Remote_Actors::get_acct( $blocked_actor_post->ID ),
240238
'identifier' => $actor->get_id(),

0 commit comments

Comments
 (0)