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
1 change: 0 additions & 1 deletion classes/controllers/FrmAddonsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,6 @@ public static function check_update( $transient ) {
}

$transient->checked[ $folder ] = $wp_version;

}//end foreach

return $transient;
Expand Down
1 change: 0 additions & 1 deletion classes/controllers/FrmFormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2556,7 +2556,6 @@ public static function get_form_contents( $form, $title, $description, $atts ) {
}
} elseif ( $errors ) {
self::show_form_after_submit( $pass_args );

} else {
do_action( 'frm_validate_form_creation', $params, $fields, $form, $title, $description );

Expand Down
1 change: 0 additions & 1 deletion classes/helpers/FrmEntriesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,6 @@ public static function maybe_render_captcha_score( $entry_id ) {
echo '<b>' . esc_html( $meta->meta_value['captcha_score'] ) . '</b>';
echo '</div>';
return;

}
}

Expand Down
1 change: 0 additions & 1 deletion classes/models/FrmDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ private static function interpret_array_to_sql( $key, $value, &$where, &$values

$where .= ' %s';
$values[] = $start . self::esc_like( $value ) . $end;

} elseif ( $value === null ) {
$where .= ' IS NULL';
} else {
Expand Down
5 changes: 0 additions & 5 deletions classes/models/FrmEntryFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,16 +417,12 @@ public function get_formatted_entry_values() {

if ( $this->format === 'json' ) {
$content = json_encode( $this->prepare_array() );

} elseif ( $this->format === 'array' ) {
$content = $this->prepare_array();

} elseif ( $this->format === 'table' ) {
$content = $this->prepare_html_table();

} elseif ( $this->format === 'plain_text_block' ) {
$content = $this->prepare_plain_text_block();

} else {
$content = '';
}
Expand Down Expand Up @@ -599,7 +595,6 @@ protected function add_plain_text_row( $label, $display_value, &$content ) {
protected function add_field_value_to_content( $field_value, &$content ) {
if ( $this->is_extra_field( $field_value ) ) {
$this->add_row_for_extra_field( $field_value, $content );

} else {
$this->add_row_for_standard_field( $field_value, $content );
}
Expand Down
1 change: 0 additions & 1 deletion classes/models/FrmPluginSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ public function insert_related_links( $links, $plugin ) {
class="button-secondary"
href="' . esc_url( admin_url( 'admin.php?page=formidable-addons' ) ) . '"
>' . __( 'Install Now', 'formidable' ) . '</a>';

} elseif ( ! empty( $plugin['link'] ) ) {
// Add link pointing to a relevant doc page in formidable.com.
$links[] = '<a
Expand Down
1 change: 0 additions & 1 deletion classes/views/shared/form-nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
</a>
</li>
<?php

}
?>
</ul>
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php
/**
* Formidable_Sniffs_WhiteSpace_NoBlankLineBeforeCloseBraceSniff
*
* Detects and removes blank lines before closing braces.
*
* @package Formidable\Sniffs
*/

namespace Formidable\Sniffs\WhiteSpace;

use PHP_CodeSniffer\Sniffs\Sniff;
use PHP_CodeSniffer\Files\File;

/**
* Detects blank lines before closing braces.
*
* Bad:
* function example() {
* return $value;
*
* }
*
* Good:
* function example() {
* return $value;
* }
*/
class NoBlankLineBeforeCloseBraceSniff implements Sniff {

/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
*/
public function register() {
return array( T_CLOSE_CURLY_BRACKET );
}

/**
* Processes this test, when one of its tokens is encountered.
*
* @param File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
*
* @return void
*/
public function process( File $phpcsFile, $stackPtr ) {
$tokens = $phpcsFile->getTokens();

// Get the line of the closing brace.
$closeBraceLine = $tokens[ $stackPtr ]['line'];

// Find the previous non-whitespace token.
$prevToken = $phpcsFile->findPrevious( T_WHITESPACE, $stackPtr - 1, null, true );

if ( false === $prevToken ) {
return;
}

$prevTokenLine = $tokens[ $prevToken ]['line'];

// Check if there's more than one line between the previous token and the closing brace.
$blankLines = $closeBraceLine - $prevTokenLine - 1;

if ( $blankLines < 1 ) {
return;
}

$fix = $phpcsFile->addFixableError(
'No blank line allowed before closing brace',
$stackPtr,
'Found'
);

if ( true === $fix ) {
$fixer = $phpcsFile->fixer;

$fixer->beginChangeset();

// Remove the blank lines by replacing whitespace tokens.
for ( $i = $prevToken + 1; $i < $stackPtr; $i++ ) {
if ( $tokens[ $i ]['code'] === T_WHITESPACE ) {
// Keep only the necessary whitespace (newline + indentation for the closing brace).
if ( $tokens[ $i ]['line'] === $closeBraceLine - 1 ) {
// This is the line right before the closing brace - keep the newline.
$fixer->replaceToken( $i, $phpcsFile->eolChar );
} elseif ( $tokens[ $i ]['line'] === $closeBraceLine ) {
// This is the indentation on the same line as the closing brace - keep it.
continue;
} else {
// Remove extra blank lines.
$fixer->replaceToken( $i, '' );
}
}
}

$fixer->endChangeset();
}
}
}
1 change: 1 addition & 0 deletions phpcs-sniffs/Formidable/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<rule ref="Formidable.WhiteSpace.NoBlankLineInShortIf" />
<rule ref="Formidable.WhiteSpace.NoBlankLineAfterLoopOpen" />
<rule ref="Formidable.WhiteSpace.NoBlankLineAfterIfOpen" />
<rule ref="Formidable.WhiteSpace.NoBlankLineBeforeCloseBrace" />

<!-- Code Analysis -->
<rule ref="Formidable.CodeAnalysis.SimplifyIfReturn" />
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/misc/test_FrmAddon.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public function test_checked_recently() {

$should_run = $this->run_private_method( array( $this->addon, 'checked_recently' ), array( '1 day' ) );
$this->assertEquals( $time['expected'], $should_run, $time['time'] . 'not properly checking' );

}
}

Expand Down