chore: lint code

This commit is contained in:
Ben Goldsworthy 2021-05-02 20:12:47 +01:00
parent c25bd7d8a2
commit 8bb41c7a7a
9 changed files with 49 additions and 50 deletions

View file

@ -42,21 +42,21 @@ class Admin {
* @since 2.8.0 * @since 2.8.0
*/ */
public function __construct( /** public function __construct( /**
* The ID of this plugin. * The ID of this plugin.
* *
* @access private * @access private
* @since 2.8.0 * @since 2.8.0
* @see Includes\Footnotes::$plugin_name * @see Includes\Footnotes::$plugin_name
* @var string $plugin_name The ID of this plugin. * @var string $plugin_name The ID of this plugin.
*/ */
private string $plugin_name, /** private string $plugin_name, /**
* The version of this plugin. * The version of this plugin.
* *
* @access private * @access private
* @since 2.8.0 * @since 2.8.0
* @see Includes\Footnotes::$version * @see Includes\Footnotes::$version
* @var string $version The current version of this plugin. * @var string $version The current version of this plugin.
*/ */
private string $version ) { private string $version ) {
$this->load_dependencies(); $this->load_dependencies();

View file

@ -328,7 +328,7 @@ abstract class Engine {
* @todo Review nonce verification. * @todo Review nonce verification.
*/ */
private function save_settings(): bool { private function save_settings(): bool {
$l_arr_new_settings = array(); $l_arr_new_settings = array();
$l_str_active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->a_arr_sections ); $l_str_active_section_id = isset( $_GET['t'] ) ? wp_unslash( $_GET['t'] ) : array_key_first( $this->a_arr_sections );
$l_arr_active_section = $this->a_arr_sections[ $l_str_active_section_id ]; $l_arr_active_section = $this->a_arr_sections[ $l_str_active_section_id ];
@ -574,13 +574,13 @@ abstract class Engine {
); );
} }
return sprintf( return sprintf(
'<input type="number" name="%s" id="%s" value="%d" min="%d" max="%d"/>', '<input type="number" name="%s" id="%s" value="%d" min="%d" max="%d"/>',
$l_arr_data['name'], $l_arr_data['name'],
$l_arr_data['id'], $l_arr_data['id'],
$l_arr_data['value'], $l_arr_data['value'],
$p_in_min, $p_in_min,
$p_int_max $p_int_max
); );
} }
} }

View file

@ -48,19 +48,20 @@ class Init {
/** /**
* Initializes all WordPress hooks for the Plugin Settings. * Initializes all WordPress hooks for the Plugin Settings.
* *
*
* @since 1.5.0 * @since 1.5.0
* @since 2.8.0 Added `$plugin_name` parameter. * @since 2.8.0 Added `$plugin_name` parameter.
*/ */
public function __construct( /** public function __construct(
* The ID of this plugin. /**
* * The ID of this plugin.
* @access private *
* @var string $plugin_name The ID of this plugin. * @access private
* * @var string $plugin_name The ID of this plugin.
* @since 2.8.0 *
*/ * @since 2.8.0
private string $plugin_name ) { */
private string $plugin_name
) {
$this->load_dependencies(); $this->load_dependencies();
$this->settings_page = new Settings( $this->plugin_name ); $this->settings_page = new Settings( $this->plugin_name );

View file

@ -185,10 +185,10 @@ class Convert {
$p_int_index = (int) $p_int_index; $p_int_index = (int) $p_int_index;
} }
// Return the whole arrow array. // Return the whole arrow array.
if ($p_int_index < 0) { if ( $p_int_index < 0 ) {
return $l_arr_arrows; return $l_arr_arrows;
} }
if ($p_int_index > count( $l_arr_arrows )) { if ( $p_int_index > count( $l_arr_arrows ) ) {
return $l_arr_arrows; return $l_arr_arrows;
} }
// Return a single arrow. // Return a single arrow.

View file

@ -54,7 +54,7 @@ class Core {
* *
* @var Loader $loader Maintains and registers all hooks for the plugin. * @var Loader $loader Maintains and registers all hooks for the plugin.
*/ */
protected ?\footnotes\includes\Loader $loader = null; protected \footnotes\includes\Loader $loader;
/** /**
* The unique identifier of this plugin * The unique identifier of this plugin

View file

@ -40,7 +40,7 @@ class i18n {
load_plugin_textdomain( load_plugin_textdomain(
'footnotes', 'footnotes',
false, false,
dirname(plugin_basename( __FILE__ ), 2) . '/languages/' dirname( plugin_basename( __FILE__ ), 2 ) . '/languages/'
); );
} }

View file

@ -1109,7 +1109,6 @@ class Settings {
/** /**
* Stores a singleton reference of this class. * Stores a singleton reference of this class.
* *
*
* @since 1.5.0 * @since 1.5.0
*/ */
private static ?\footnotes\includes\Settings $a_obj_instance = null; private static ?\footnotes\includes\Settings $a_obj_instance = null;
@ -1344,7 +1343,6 @@ class Settings {
/** /**
* Returns a singleton of this class. * Returns a singleton of this class.
* *
*
* @since 1.5.0 * @since 1.5.0
* @todo Remove? * @todo Remove?
*/ */

View file

@ -81,10 +81,10 @@ class Template {
*/ */
public function __construct( string $p_str_file_type, string $p_str_file_name, string $p_str_extension = 'html' ) { public function __construct( string $p_str_file_type, string $p_str_file_name, string $p_str_extension = 'html' ) {
// No template file type and/or file name set. // No template file type and/or file name set.
if (empty( $p_str_file_type )) { if ( empty( $p_str_file_type ) ) {
return; return;
} }
if (empty( $p_str_file_name )) { if ( empty( $p_str_file_name ) ) {
return; return;
} }
$this->plugin_directory = plugin_dir_path( __DIR__ ); $this->plugin_directory = plugin_dir_path( __DIR__ );

View file

@ -302,7 +302,7 @@ class Parser {
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_EXPERT_LOOKUP_THE_TITLE ) ) ) { if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_EXPERT_LOOKUP_THE_TITLE ) ) ) {
add_filter( add_filter(
'the_title', 'the_title',
fn(string $p_str_content): string => $this->footnotes_in_title( $p_str_content ), fn( string $p_str_content): string => $this->footnotes_in_title( $p_str_content ),
$l_int_the_title_priority $l_int_the_title_priority
); );
} }
@ -311,7 +311,7 @@ class Parser {
if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_EXPERT_LOOKUP_THE_CONTENT ) ) ) { if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_EXPERT_LOOKUP_THE_CONTENT ) ) ) {
add_filter( add_filter(
'the_content', 'the_content',
fn(string $p_str_content): string => $this->footnotes_in_content( $p_str_content ), fn( string $p_str_content): string => $this->footnotes_in_content( $p_str_content ),
$l_int_the_content_priority $l_int_the_content_priority
); );
@ -329,7 +329,7 @@ class Parser {
*/ */
add_filter( add_filter(
'term_description', 'term_description',
fn(string $p_str_content): string => $this->footnotes_in_content( $p_str_content ), fn( string $p_str_content): string => $this->footnotes_in_content( $p_str_content ),
$l_int_the_content_priority $l_int_the_content_priority
); );
@ -345,7 +345,7 @@ class Parser {
*/ */
add_filter( add_filter(
'pum_popup_content', 'pum_popup_content',
fn(string $p_str_content): string => $this->footnotes_in_content( $p_str_content ), fn( string $p_str_content): string => $this->footnotes_in_content( $p_str_content ),
$l_int_the_content_priority $l_int_the_content_priority
); );
} }
@ -361,7 +361,7 @@ class Parser {
*/ */
add_filter( add_filter(
'the_excerpt', 'the_excerpt',
fn(string $p_str_excerpt): string => $this->footnotes_in_excerpt( $p_str_excerpt ), fn( string $p_str_excerpt): string => $this->footnotes_in_excerpt( $p_str_excerpt ),
$l_int_the_excerpt_priority $l_int_the_excerpt_priority
); );
} }
@ -372,7 +372,7 @@ class Parser {
*/ */
add_filter( add_filter(
'widget_title', 'widget_title',
fn(string $p_str_content): string => $this->footnotes_in_widget_title( $p_str_content ), fn( string $p_str_content): string => $this->footnotes_in_widget_title( $p_str_content ),
$l_int_widget_title_priority $l_int_widget_title_priority
); );
} }
@ -383,7 +383,7 @@ class Parser {
*/ */
add_filter( add_filter(
'widget_text', 'widget_text',
fn(string $p_str_content): string => $this->footnotes_in_widget_text( $p_str_content ), fn( string $p_str_content): string => $this->footnotes_in_widget_text( $p_str_content ),
$l_int_widget_text_priority $l_int_widget_text_priority
); );
} }
@ -792,7 +792,7 @@ class Parser {
$l_str_footnote_section_shortcode = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_FOOTNOTE_SECTION_SHORTCODE ); $l_str_footnote_section_shortcode = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_FOOTNOTE_SECTION_SHORTCODE );
$l_int_footnote_section_shortcode_length = strlen( $l_str_footnote_section_shortcode ); $l_int_footnote_section_shortcode_length = strlen( $l_str_footnote_section_shortcode );
if ( !str_contains( $p_str_content, (string) $l_str_footnote_section_shortcode ) ) { if ( ! str_contains( $p_str_content, (string) $l_str_footnote_section_shortcode ) ) {
// phpcs:disable WordPress.PHP.YodaConditions.NotYoda // phpcs:disable WordPress.PHP.YodaConditions.NotYoda
// Appends the reference container if set to "post_end". // Appends the reference container if set to "post_end".
@ -1717,7 +1717,7 @@ class Parser {
// If it is not, check which option is on. // If it is not, check which option is on.
$l_str_separator_option = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_SEPARATOR_OPTION ); $l_str_separator_option = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_SEPARATOR_OPTION );
$l_str_separator = match ($l_str_separator_option) { $l_str_separator = match ($l_str_separator_option) {
'comma' => ',', 'comma' => ',',
'semicolon' => ';', 'semicolon' => ';',
'en_dash' => '&nbsp;&#x2013;', 'en_dash' => '&nbsp;&#x2013;',
@ -1740,7 +1740,7 @@ class Parser {
// If it is not, check which option is on. // If it is not, check which option is on.
$l_str_terminator_option = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_TERMINATOR_OPTION ); $l_str_terminator_option = Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_BACKLINKS_TERMINATOR_OPTION );
$l_str_terminator = match ($l_str_terminator_option) { $l_str_terminator = match ($l_str_terminator_option) {
'period' => '.', 'period' => '.',
'parenthesis' => ')', 'parenthesis' => ')',
'colon' => ':', 'colon' => ':',