Skip to content

Commit

Permalink
Merge pull request #1535 from IanDelMar/yoda
Browse files Browse the repository at this point in the history
Use Yoda condition checks and strict comparisons
  • Loading branch information
takayukister authored Feb 7, 2025
2 parents 065c3a5 + 63707c0 commit d198314
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ function wpcf7_admin_updated_message( $page, $action, $object ) {
add_filter( 'plugin_action_links', 'wpcf7_plugin_action_links', 10, 2 );

function wpcf7_plugin_action_links( $links, $file ) {
if ( $file != WPCF7_PLUGIN_BASENAME ) {
if ( WPCF7_PLUGIN_BASENAME !== $file ) {
return $links;
}

Expand Down
4 changes: 2 additions & 2 deletions includes/config-validator/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function replace_mail_tags( $content, $options = '' ) {
*/
public function replace_mail_tags_with_minimum_input_callback( $matches ) {
// allow [[foo]] syntax for escaping a tag
if ( $matches[1] === '[' and $matches[4] === ']' ) {
if ( '[' === $matches[1] and ']' === $matches[4] ) {
return substr( $matches[0], 1, -1 );
}

Expand Down Expand Up @@ -536,7 +536,7 @@ public function detect_unsafe_email_without_protection( $section, $content ) {
$content = $this->replace_mail_tags( $content, array(
'callback' => function ( $matches ) use ( $example_email ) {
// allow [[foo]] syntax for escaping a tag
if ( $matches[1] === '[' and $matches[4] === ']' ) {
if ( '[' === $matches[1] and ']' === $matches[4] ) {
return substr( $matches[0], 1, -1 );
}

Expand Down
6 changes: 2 additions & 4 deletions includes/form-tags-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ public function normalize( $content ) {
*/
private function normalize_callback( $matches ) {
// allow [[foo]] syntax for escaping a tag
if ( $matches[1] == '['
and $matches[6] == ']' ) {
if ( '[' === $matches[1] and ']' === $matches[6] ) {
return $matches[0];
}

Expand Down Expand Up @@ -466,8 +465,7 @@ private function replace_callback( $matches ) {
*/
private function scan_callback( $matches, $replace = false ) {
// allow [[foo]] syntax for escaping a tag
if ( $matches[1] == '['
and $matches[6] == ']' ) {
if ( '[' === $matches[1] and ']' === $matches[6] ) {
return substr( $matches[0], 1, -1 );
}

Expand Down
3 changes: 1 addition & 2 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,7 @@ function wpcf7_rmdir_p( $dir ) {

if ( $handle = opendir( $dir ) ) {
while ( false !== ( $file = readdir( $handle ) ) ) {
if ( $file == "."
or $file == ".." ) {
if ( '.' === $file or '..' === $file ) {
continue;
}

Expand Down
12 changes: 6 additions & 6 deletions includes/html-formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function pre_format( $chunks ) {
array( "\r\n", "\r" ), "\n", $chunk['content']
);

if ( $chunk['type'] === self::start_tag ) {
if ( self::start_tag === $chunk['type'] ) {
list( $chunk['content'] ) =
self::normalize_start_tag( $chunk['content'] );

Expand Down Expand Up @@ -222,7 +222,7 @@ public function concatenate_texts( $chunks ) {
foreach ( $chunks as $chunk ) {
$chunk['position'] = $position;

if ( $chunk['type'] === self::text ) {
if ( self::text === $chunk['type'] ) {
if ( isset( $text_left ) ) {
$text_left['content'] .= $chunk['content'];
} else {
Expand Down Expand Up @@ -263,19 +263,19 @@ public function format( $chunks ) {

foreach ( $chunks as $chunk ) {

if ( $chunk['type'] === self::text ) {
if ( self::text === $chunk['type'] ) {
$this->append_text( $chunk['content'] );
}

if ( $chunk['type'] === self::start_tag ) {
if ( self::start_tag === $chunk['type'] ) {
$this->start_tag( $chunk['content'] );
}

if ( $chunk['type'] === self::end_tag ) {
if ( self::end_tag === $chunk['type'] ) {
$this->end_tag( $chunk['content'] );
}

if ( $chunk['type'] === self::comment ) {
if ( self::comment === $chunk['type'] ) {
$this->append_comment( $chunk['content'] );
}
}
Expand Down
3 changes: 1 addition & 2 deletions includes/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,7 @@ private function replace_tags_callback_html( $matches ) {
*/
private function replace_tags_callback( $matches, $html = false ) {
// allow [[foo]] syntax for escaping a tag
if ( $matches[1] == '['
and $matches[4] == ']' ) {
if ( '[' === $matches[1] and ']' === $matches[4] ) {
return substr( $matches[0], 1, -1 );
}

Expand Down

0 comments on commit d198314

Please sign in to comment.