Skip to content
Merged
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
2 changes: 1 addition & 1 deletion classes/controllers/FrmAddonsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ public static function get_addon_for_license( $addons, $license ) {
$download_id = $license->download_id;
$plugin = array();

if ( ! $download_id && ! empty( $addons ) ) {
if ( ! $download_id && $addons ) {
foreach ( $addons as $addon ) {
if ( strtolower( $license->plugin_name ) === strtolower( $addon['title'] ) ) {
return $addon;
Expand Down
2 changes: 1 addition & 1 deletion classes/models/FrmDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ public static function check_cache( $cache_key, $group = '', $query = '', $type
$found = null;
$results = wp_cache_get( $cache_key, $group, false, $found );

if ( ( $found === true && $results !== false ) || empty( $query ) ) {
if ( ( $found === true && $results !== false ) || ! $query ) {
return $results;
}

Expand Down
2 changes: 1 addition & 1 deletion classes/models/FrmEntryValidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public static function spam_check( $exclude, $values, &$errors ) {
return;
}

if ( $exclude || empty( $values['item_meta'] ) || ! empty( $errors ) ) {
if ( $exclude || empty( $values['item_meta'] ) || $errors ) {
// only check spam if there are no other errors
return;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/models/FrmForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ public static function is_form_loaded( $form, $this_load, $global_load ) {

$frm_vars['forms_loaded'][] = $small_form;

if ( $this_load && empty( $global_load ) ) {
if ( $this_load && ! $global_load ) {
$global_load = true;
$frm_vars['load_css'] = true;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/models/FrmFormApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function get_addon_for_license( $license_plugin, $addons = array() ) {
$download_id = $license_plugin->download_id;
$plugin = array();

if ( ! $download_id && ! empty( $addons ) ) {
if ( ! $download_id && $addons ) {
foreach ( $addons as $addon ) {
if ( is_array( $addon ) && ! empty( $addon['title'] ) && strtolower( $license_plugin->plugin_name ) === strtolower( $addon['title'] ) ) {
return $addon;
Expand Down
2 changes: 1 addition & 1 deletion classes/models/fields/FrmFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function set_type( $type ) {
if ( empty( $this->type ) ) {
$this->type = $this->get_field_column( 'type' );

if ( empty( $this->type ) && ! empty( $type ) ) {
if ( empty( $this->type ) && $type ) {
$this->type = $type;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,19 +237,25 @@ private function getFunctionParameters( File $phpcsFile, $functionToken ) {
private function isInIfCondition( File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();

// Find the opening parenthesis that contains this empty() call.
// We need to find the parenthesis that belongs to an if/elseif statement.
// Track parenthesis nesting to find the outermost condition parenthesis.
$parenDepth = 0;

for ( $i = $stackPtr - 1; $i >= 0; $i-- ) {
$code = $tokens[ $i ]['code'];

// Skip whitespace and the "!" operator.
if ( $code === T_WHITESPACE || $code === T_BOOLEAN_NOT ) {
// Track parenthesis nesting.
if ( $code === T_CLOSE_PARENTHESIS ) {
++$parenDepth;
continue;
}

// If we hit an open parenthesis, check if it belongs to if/elseif.
if ( $code === T_OPEN_PARENTHESIS ) {
// Check what's before this parenthesis.
if ( $parenDepth > 0 ) {
--$parenDepth;
continue;
}

// This is an unmatched open paren - check if it belongs to if/elseif.
$beforeParen = $phpcsFile->findPrevious( T_WHITESPACE, $i - 1, null, true );

if ( false !== $beforeParen ) {
Expand All @@ -264,10 +270,42 @@ private function isInIfCondition( File $phpcsFile, $stackPtr ) {
return false;
}

// If we hit something else (like another function call), stop.
if ( $code !== T_OPEN_PARENTHESIS ) {
return false;
// Skip tokens that are valid inside an if condition.
if ( $code === T_WHITESPACE
|| $code === T_BOOLEAN_NOT
|| $code === T_BOOLEAN_AND
|| $code === T_BOOLEAN_OR
|| $code === T_LOGICAL_AND
|| $code === T_LOGICAL_OR
|| $code === T_VARIABLE
|| $code === T_STRING
|| $code === T_LNUMBER
|| $code === T_DNUMBER
|| $code === T_CONSTANT_ENCAPSED_STRING
|| $code === T_TRUE
|| $code === T_FALSE
|| $code === T_NULL
|| $code === T_ISSET
|| $code === T_EMPTY
|| $code === T_IS_EQUAL
|| $code === T_IS_NOT_EQUAL
|| $code === T_IS_IDENTICAL
|| $code === T_IS_NOT_IDENTICAL
|| $code === T_GREATER_THAN
|| $code === T_LESS_THAN
|| $code === T_IS_GREATER_OR_EQUAL
|| $code === T_IS_SMALLER_OR_EQUAL
|| $code === T_OBJECT_OPERATOR
|| $code === T_NULLSAFE_OBJECT_OPERATOR
|| $code === T_OPEN_SQUARE_BRACKET
|| $code === T_CLOSE_SQUARE_BRACKET
|| $code === T_DOUBLE_COLON
) {
continue;
}

// Hit something unexpected, stop searching.
return false;
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion stripe/models/FrmStrpLiteAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ private static function update_intent_pricing( $form_id, &$intents ) {

$actions = FrmStrpLiteActionsController::get_actions_before_submit( $form_id );

if ( ! $actions || empty( $intents ) ) {
if ( ! $actions || ! $intents ) {
return;
}

Expand Down