refactor: add strict typing

This commit is contained in:
Ben Goldsworthy 2021-05-02 19:33:29 +01:00
parent c1421d1978
commit 9aae69a693
19 changed files with 83 additions and 49 deletions

View file

@ -10,6 +10,8 @@
* @since 1.5.0
*/
declare(strict_types=1);
namespace footnotes\general\Widget;
use footnotes\includes as Includes;
@ -36,7 +38,7 @@ abstract class Base extends \WP_Widget {
*
* @return string
*/
abstract protected function get_id();
abstract protected function get_id(): string;
/**
* Returns the Public name of child Widget to be displayed in the Configuration page.
@ -46,7 +48,7 @@ abstract class Base extends \WP_Widget {
*
* @return string
*/
abstract protected function get_name();
abstract protected function get_name(): string;
/**
* Returns the Description of the child widget.
@ -56,7 +58,7 @@ abstract class Base extends \WP_Widget {
*
* @return string
*/
abstract protected function get_description();
abstract protected function get_description(): string;
/**
* Returns the width of the Widget. Default width is 250 pixel.
@ -65,7 +67,7 @@ abstract class Base extends \WP_Widget {
*
* @return int
*/
protected function get_widget_width() {
protected function get_widget_width(): int {
return 250;
}

View file

@ -10,6 +10,9 @@
* @since 1.5.0
*/
// TODO: Disabled pending WPWidget AP review.
/* declare(strict_types=1); */
namespace footnotes\general\Widget;
use footnotes\includes as Includes;
@ -34,7 +37,7 @@ class Reference_Container extends Base {
* @see Includes\Footnotes::$plugin_name
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;
private string $plugin_name;
/**
* Initialize the class and set its properties.
@ -43,9 +46,9 @@ class Reference_Container extends Base {
*
* @param string $plugin_name The name of this plugin.
*/
public function __construct( $plugin_name ) {
parent::__construct();
public function __construct( string $plugin_name ) {
$this->plugin_name = $plugin_name;
parent::__construct();
}
/**
@ -56,7 +59,7 @@ class Reference_Container extends Base {
*
* @return string
*/
protected function get_id() {
protected function get_id(): string {
return 'footnotes_widget';
}
@ -68,7 +71,7 @@ class Reference_Container extends Base {
*
* @return string
*/
protected function get_name() {
protected function get_name(): string {
return $this->plugin_name;
}
@ -80,7 +83,7 @@ class Reference_Container extends Base {
*
* @return string
*/
protected function get_description() {
protected function get_description(): string {
return __( 'The widget defines the position of the reference container if set to “widget area”.', 'footnotes' );
}