diff --git a/src/admin/layout/class-engine.php b/src/admin/layout/class-engine.php index 7096018..3c7c0a7 100644 --- a/src/admin/layout/class-engine.php +++ b/src/admin/layout/class-engine.php @@ -49,7 +49,7 @@ abstract class Engine { * * @since 1.5.0 */ - protected ?string $a_str_sub_page_hook; + protected ?string $a_str_sub_page_hook = null; /** * Stores all Sections for the child sub-page. @@ -197,9 +197,7 @@ abstract class Engine { $this->get_sub_page_title(), 'manage_options', Init::C_STR_MAIN_MENU_SLUG . $this->get_sub_page_slug(), - function () { - return $this->display_content(); - } + fn() => $this->display_content() ); } @@ -215,9 +213,7 @@ abstract class Engine { add_settings_section( $l_arr_section['id'], '', - function () { - return $this->description(); - }, + fn() => $this->description(), $l_arr_section['id'] ); $this->register_meta_boxes( $l_arr_section['id'] ); diff --git a/src/admin/layout/class-init.php b/src/admin/layout/class-init.php index 182adab..db4b395 100644 --- a/src/admin/layout/class-init.php +++ b/src/admin/layout/class-init.php @@ -73,28 +73,20 @@ class Init { // Register hooks/actions. add_action( 'admin_menu', - function () { - return $this->register_options_submenu(); - } + fn() => $this->register_options_submenu() ); add_action( 'admin_init', - function () { - return $this->initialize_settings(); - } + fn() => $this->initialize_settings() ); // Register AJAX callbacks for Plugin information. add_action( 'wp_ajax_nopriv_footnotes_get_plugin_info', - function () { - return $this->get_plugin_meta_information(); - } + fn() => $this->get_plugin_meta_information() ); add_action( 'wp_ajax_footnotes_get_plugin_info', - function () { - return $this->get_plugin_meta_information(); - } + fn() => $this->get_plugin_meta_information() ); } @@ -151,9 +143,7 @@ class Init { \footnotes\includes\Config::C_STR_PLUGIN_PUBLIC_NAME, 'manage_options', self::C_STR_MAIN_MENU_SLUG, - function () { - return $this->settings_page->display_content(); - } + fn() => $this->settings_page->display_content() ); $this->settings_page->register_sub_page(); } diff --git a/src/includes/class-core.php b/src/includes/class-core.php index 95f91d1..70a9426 100644 --- a/src/includes/class-core.php +++ b/src/includes/class-core.php @@ -54,7 +54,7 @@ class Core { * * @var Loader $loader Maintains and registers all hooks for the plugin. */ - protected $loader; + protected ?\footnotes\includes\Loader $loader = null; /** * The unique identifier of this plugin @@ -63,7 +63,7 @@ class Core { * * @var string $plugin_name The string used to uniquely identify this plugin. */ - protected $plugin_name; + protected string $plugin_name; /** * The current version of the plugin. @@ -73,7 +73,7 @@ class Core { * * @var string $version The current version of the plugin. */ - protected $version; + protected string $version; /** * Builds the core of the plugin. diff --git a/src/includes/class-loader.php b/src/includes/class-loader.php index fe93898..a0d6bcf 100644 --- a/src/includes/class-loader.php +++ b/src/includes/class-loader.php @@ -31,7 +31,7 @@ class Loader { * * @var (string|int|object)[][] $actions The actions registered with WordPress to fire when the plugin loads. */ - protected $actions; + protected array $actions; /** * The array of filters registered with WordPress. @@ -41,7 +41,7 @@ class Loader { * * @var (string|int|object)[][] $filters The filters registered with WordPress to fire when the plugin loads. */ - protected $filters; + protected array $filters; /** * Initialize the collections used to maintain the actions and filters. diff --git a/src/includes/class-settings.php b/src/includes/class-settings.php index 46fd25e..c6ddcdd 100644 --- a/src/includes/class-settings.php +++ b/src/includes/class-settings.php @@ -1106,15 +1106,13 @@ class Settings { /********************************************************************** * SETTINGS STORAGE. **********************************************************************/ - /** * Stores a singleton reference of this class. * - * @var Settings * * @since 1.5.0 */ - private static $a_obj_instance; + private static ?\footnotes\includes\Settings $a_obj_instance = null; /** * Contains all Settings Container names. diff --git a/src/includes/class-template.php b/src/includes/class-template.php index bcba85c..cbdf2f0 100644 --- a/src/includes/class-template.php +++ b/src/includes/class-template.php @@ -51,28 +51,22 @@ class Template { * Contains the content of the template after initialize. * * @since 1.5.0 - * - * @var string */ - private $a_str_original_content = ''; + private ?string $a_str_original_content = ''; /** * Contains the content of the template after initialize with replaced place holders. * * @since 1.5.0 - * - * @var string */ - private $a_str_replaced_content = ''; + private string $a_str_replaced_content = ''; /** * Plugin Directory * * @since 2.4.0d3 - * - * @var string */ - public $plugin_directory; + public string $plugin_directory; /** * Class Constructor. Reads and loads the template file without replace any placeholder. diff --git a/src/public/class-parser.php b/src/public/class-parser.php index 84ded2e..edadeb6 100644 --- a/src/public/class-parser.php +++ b/src/public/class-parser.php @@ -30,23 +30,21 @@ class Parser { * @since 1.5.0 * @var string[] */ - public static $a_arr_footnotes = array(); + public static array $a_arr_footnotes = array(); /** * Flag if the display of 'LOVE FOOTNOTES' is allowed on the current public page. * * @since 1.5.0 - * @var bool */ - public static $a_bool_allow_love_me = true; + public static bool $a_bool_allow_love_me = true; /** * Prefix for the Footnote html element ID. * * @since 1.5.8 - * @var string */ - public static $a_str_prefix = ''; + public static string $a_str_prefix = ''; /** * Autoload a.k.a. infinite scroll, or archive view. @@ -55,9 +53,8 @@ class Parser { * post ID to make everything unique wrt infinite scroll and archive view. * * @since 2.0.6 - * @var int */ - public static $a_int_post_id = 0; + public static int $a_int_post_id = 0; /** * Multiple reference containers in content and widgets. @@ -69,7 +66,7 @@ class Parser { * @since 2.2.9 * @var int Incremented every time after a reference container is inserted. */ - public static $a_int_reference_container_id = 1; + public static int $a_int_reference_container_id = 1; /** * Hard links for AMP compatibility. @@ -77,9 +74,8 @@ class Parser { * A property because used both in {@see search()} and {@see reference_container()}. * * @since 2.0.0 - * @var bool */ - public static $a_bool_hard_links_enabled = false; + public static bool $a_bool_hard_links_enabled = false; /** * The referrer slug. @@ -124,9 +120,8 @@ class Parser { * Hence it needs to be loaded twice, because priority levels may not match. * * @since 2.1.4 - * @var int */ - public static $a_int_scroll_offset = 34; + public static int $a_int_scroll_offset = 34; /* * Optional link element for footnote referrers and backlinks @@ -146,33 +141,29 @@ class Parser { * Yet styling these elements with the link color is not universally preferred, so that * the very presence of these link elements may need to be avoided. */ - /** * The span element name. * * @since 2.3.0 * @todo Remove. - * @var string */ - public static $a_str_link_span = 'span'; + public static string $a_str_link_span = 'span'; /** * The opening tag. * * @since 2.3.0 * @todo Remove. - * @var string */ - public static $a_str_link_open_tag = ''; + public static string $a_str_link_open_tag = ''; /** * The closing tag. * * @since 2.3.0 * @todo Remove. - * @var string */ - public static $a_str_link_close_tag = ''; + public static string $a_str_link_close_tag = ''; /* * Dedicated tooltip text. @@ -195,53 +186,47 @@ class Parser { * The tooltip delimiter shortcode length. * * @since 2.5.2 - * @var int */ - public static $a_int_tooltip_shortcode_length = 12; + public static int $a_int_tooltip_shortcode_length = 12; /** * Whether to mirror the tooltip text in the reference container. * * @since 2.5.2 - * @var bool */ - public static $a_bool_mirror_tooltip_text = false; + public static bool $a_bool_mirror_tooltip_text = false; /** * Footnote delimiter start short code. * * @since 1.5.0 * @since 2.6.2 Move from constant to class property. - * @var string */ - public static $a_str_start_tag = ''; + public static string|int $a_str_start_tag = ''; /** * Footnote delimiter end short code. * * @since 1.5.0 * @since 2.6.2 Move from constant to class property. - * @var string */ - public static $a_str_end_tag = ''; + public static string|int $a_str_end_tag = ''; /** * Footnote delimiter start short code in RegEx format. * * @since 2.4.0 * @since 2.6.2 Move from global constant to class property. - * @var string */ - public static $a_str_start_tag_regex = ''; + public static ?string $a_str_start_tag_regex = ''; /** * Footnote delimiter end short code in RegEx format. * * @since 2.4.0 * @since 2.6.2 Move from global constant to class property. - * @var string */ - public static $a_str_end_tag_regex = ''; + public static ?string $a_str_end_tag_regex = ''; /** * Footnote delimiter syntax validation enabled. @@ -255,9 +240,8 @@ class Parser { * released in urgency to provide AMP compat before 2021. * * @since 2.4.0 - * @var bool */ - public static $a_bool_syntax_error_flag = true; + public static bool $a_bool_syntax_error_flag = true; /** * Initialize the class and set its properties. @@ -304,27 +288,21 @@ class Parser { // Append custom css to the header. add_filter( 'wp_head', - function () { - return $this->footnotes_output_head(); - }, + fn() => $this->footnotes_output_head(), PHP_INT_MAX ); // Append the love and share me slug to the footer. add_filter( 'wp_footer', - function () { - return $this->footnotes_output_footer(); - }, + fn() => $this->footnotes_output_footer(), PHP_INT_MAX ); if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_EXPERT_LOOKUP_THE_TITLE ) ) ) { add_filter( 'the_title', - function ( string $p_str_content ) : string { - return $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 ); } @@ -333,9 +311,7 @@ class Parser { if ( Includes\Convert::to_bool( Includes\Settings::instance()->get( \footnotes\includes\Settings::C_STR_EXPERT_LOOKUP_THE_CONTENT ) ) ) { add_filter( 'the_content', - function ( string $p_str_content ) : string { - return $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 ); @@ -353,9 +329,7 @@ class Parser { */ add_filter( 'term_description', - function ( string $p_str_content ) : string { - return $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 ); @@ -371,9 +345,7 @@ class Parser { */ add_filter( 'pum_popup_content', - function ( string $p_str_content ) : string { - return $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 ); } @@ -389,9 +361,7 @@ class Parser { */ add_filter( 'the_excerpt', - function ( string $p_str_excerpt ) : string { - return $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 ); } @@ -402,9 +372,7 @@ class Parser { */ add_filter( 'widget_title', - function ( string $p_str_content ) : string { - return $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 ); } @@ -415,9 +383,7 @@ class Parser { */ add_filter( 'widget_text', - function ( string $p_str_content ) : string { - return $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 ); } @@ -968,7 +934,7 @@ class Parser { ); // Prevent the footnotes from altering the excerpt: previously hard-coded '5ED84D6'. - $l_int_placeholder = '@' . wp_rand( 100000000, 2147483647 ) . '@'; + $l_int_placeholder = '@' . wp_rand( 100_000_000, 2_147_483_647 ) . '@'; $p_str_content = preg_replace( '#' . self::$a_str_start_tag_regex . '.+?' . self::$a_str_end_tag_regex . '#', $l_int_placeholder, @@ -1305,7 +1271,7 @@ class Parser { } // Post ID to make everything unique wrt infinite scroll and archive view. - self::$a_int_post_id = get_the_id(); + self::$a_int_post_id = (int) get_the_id(); /* * Empties the footnotes list every time Footnotes is run when the_content hook is called.