From 2f9f3ed896d4155e242091864e001449c2d35462 Mon Sep 17 00:00:00 2001 From: Rami Yushuvaev <92088692+rami-elementor@users.noreply.github.com> Date: Sun, 1 Dec 2024 05:50:14 -0800 Subject: [PATCH] Add return types (#290) --- src/addons/addon-example.md | 14 ++++----- src/addons/compatibility.md | 9 +++--- src/addons/initialization.md | 14 ++++----- src/addons/main-class.md | 8 ++--- src/controls/complex-example.md | 24 +++++++-------- src/controls/control-enqueue.md | 2 +- src/controls/control-settings.md | 2 +- src/controls/control-structure.md | 14 ++++----- src/controls/control-template.md | 2 +- src/controls/control-values.md | 8 ++--- src/controls/simple-example.md | 26 ++++++++-------- src/deprecations/deprecated-action-hook.md | 6 ++-- src/deprecations/deprecated-argument.md | 6 ++-- src/deprecations/deprecated-filter-hook.md | 6 ++-- src/deprecations/deprecated-function.md | 12 ++++---- src/deprecations/simple-example.md | 20 ++++++------- src/dynamic-tags/advanced-example.md | 12 ++++---- src/dynamic-tags/complex-example.md | 12 ++++---- src/dynamic-tags/dynamic-tags-categories.md | 10 +++---- src/dynamic-tags/dynamic-tags-controls.md | 2 +- src/dynamic-tags/dynamic-tags-data.md | 8 ++--- src/dynamic-tags/dynamic-tags-groups.md | 2 +- src/dynamic-tags/dynamic-tags-rendering.md | 4 +-- src/dynamic-tags/dynamic-tags-structure.md | 12 ++++---- src/dynamic-tags/simple-example.md | 10 +++---- src/editor-controls/control-alert.md | 2 +- src/editor-controls/control-animation.md | 6 ++-- src/editor-controls/control-box-shadow.md | 2 +- src/editor-controls/control-button.md | 2 +- src/editor-controls/control-choose.md | 6 ++-- src/editor-controls/control-code.md | 6 ++-- src/editor-controls/control-color.md | 6 ++-- src/editor-controls/control-date-time.md | 6 ++-- .../control-deprecated-notice.md | 4 +-- src/editor-controls/control-dimensions.md | 6 ++-- src/editor-controls/control-divider.md | 2 +- src/editor-controls/control-exit-animation.md | 6 ++-- src/editor-controls/control-font.md | 6 ++-- src/editor-controls/control-gallery.md | 6 ++-- src/editor-controls/control-heading.md | 2 +- src/editor-controls/control-hidden.md | 6 ++-- .../control-hover-animation.md | 6 ++-- src/editor-controls/control-icon.md | 6 ++-- src/editor-controls/control-icons.md | 10 +++---- .../control-image-dimensions.md | 2 +- src/editor-controls/control-media.md | 18 +++++------ src/editor-controls/control-notice.md | 2 +- src/editor-controls/control-number.md | 6 ++-- src/editor-controls/control-popover-toggle.md | 2 +- src/editor-controls/control-popovers.md | 2 +- src/editor-controls/control-raw-html.md | 2 +- src/editor-controls/control-repeater.md | 12 ++++---- src/editor-controls/control-section.md | 6 ++-- src/editor-controls/control-select.md | 6 ++-- src/editor-controls/control-select2.md | 6 ++-- src/editor-controls/control-slider.md | 6 ++-- src/editor-controls/control-switcher.md | 6 ++-- src/editor-controls/control-tabs.md | 2 +- src/editor-controls/control-text-shadow.md | 2 +- src/editor-controls/control-text.md | 6 ++-- src/editor-controls/control-textarea.md | 6 ++-- src/editor-controls/control-url.md | 6 ++-- src/editor-controls/control-wysiwyg.md | 6 ++-- src/editor-controls/frontend-available.md | 12 ++++---- .../group-control-background.md | 6 ++-- src/editor-controls/group-control-border.md | 6 ++-- .../group-control-box-shadow.md | 6 ++-- .../group-control-css-filter.md | 6 ++-- .../group-control-image-size.md | 6 ++-- .../group-control-text-shadow.md | 6 ++-- .../group-control-text-stroke.md | 6 ++-- .../group-control-typography.md | 6 ++-- src/editor-controls/group-control.md | 4 +-- src/editor-controls/regular-control.md | 14 ++++----- src/editor-controls/responsive-control.md | 6 ++-- src/editor-controls/using-controls.md | 2 +- src/finder/add-new-finder-items.md | 6 ++-- src/finder/advanced-example.md | 6 ++-- src/finder/finder-structure.md | 8 ++--- src/finder/simple-example.md | 6 ++-- src/form-actions/action-controls.md | 4 +-- src/form-actions/action-data.md | 4 +-- src/form-actions/action-on-export.md | 6 ++-- src/form-actions/action-run.md | 8 ++--- src/form-actions/action-structure.md | 10 +++---- src/form-actions/advanced-example.md | 10 +++---- src/form-actions/simple-example.md | 10 +++---- src/form-fields/advanced-example.md | 14 ++++----- src/form-fields/field-content-template.md | 4 +-- src/form-fields/field-controls.md | 4 +-- src/form-fields/field-data.md | 4 +-- src/form-fields/field-dependencies.md | 4 +-- src/form-fields/field-render.md | 6 ++-- src/form-fields/field-structure.md | 10 +++---- src/form-fields/field-validation.md | 4 +-- src/form-fields/simple-example.md | 12 ++++---- src/getting-started/first-addon.md | 30 +++++++++---------- src/hooks/widget-categories.md | 2 +- src/scripts-styles/control-scripts.md | 2 +- src/scripts-styles/control-styles.md | 2 +- src/scripts-styles/widget-scripts.md | 2 +- src/scripts-styles/widget-styles.md | 2 +- src/theme-conditions/advanced-example.md | 20 ++++++------- src/theme-conditions/condition-check.md | 12 ++++---- src/theme-conditions/condition-data.md | 4 +-- src/theme-conditions/condition-group-type.md | 4 +-- src/theme-conditions/condition-structure.md | 16 +++++----- src/theme-conditions/simple-example.md | 8 ++--- src/theme-conditions/sub-conditions.md | 4 +-- src/widgets/advanced-example.md | 20 ++++++------- src/widgets/rendering-html-attribute.md | 4 +-- src/widgets/rendering-inline-editing.md | 10 +++---- src/widgets/rendering-media.md | 12 ++++---- src/widgets/rendering-repeaters.md | 6 ++-- src/widgets/rendering-style.md | 6 ++-- src/widgets/rendering-text.md | 6 ++-- src/widgets/simple-example.md | 16 +++++----- src/widgets/widget-categories.md | 2 +- src/widgets/widget-controls.md | 4 +-- src/widgets/widget-data.md | 14 ++++----- src/widgets/widget-dependencies.md | 14 ++++----- src/widgets/widget-information.md | 6 ++-- src/widgets/widget-output-caching.md | 12 ++++---- src/widgets/widget-promotions.md | 4 +-- src/widgets/widget-rendering.md | 4 +-- src/widgets/widget-settings.md | 6 ++-- src/widgets/widget-structure.md | 26 ++++++++-------- 127 files changed, 476 insertions(+), 475 deletions(-) diff --git a/src/addons/addon-example.md b/src/addons/addon-example.md index 162f05c2..e4fd959a 100644 --- a/src/addons/addon-example.md +++ b/src/addons/addon-example.md @@ -160,7 +160,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function is_compatible() { + public function is_compatible(): void { // Check if Elementor installed and activated if ( ! did_action( 'elementor/loaded' ) ) { @@ -192,7 +192,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function admin_notice_missing_main_plugin() { + public function admin_notice_missing_main_plugin(): void { if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); @@ -215,7 +215,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function admin_notice_minimum_elementor_version() { + public function admin_notice_minimum_elementor_version(): void { if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); @@ -239,7 +239,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function admin_notice_minimum_php_version() { + public function admin_notice_minimum_php_version(): void { if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); @@ -265,7 +265,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function init() { + public function init(): void { add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] ); add_action( 'elementor/controls/register', [ $this, 'register_controls' ] ); @@ -281,7 +281,7 @@ final class Plugin { * * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager. */ - public function register_widgets( $widgets_manager ) { + public function register_widgets( $widgets_manager ): void { require_once( __DIR__ . '/includes/widgets/widget-1.php' ); require_once( __DIR__ . '/includes/widgets/widget-2.php' ); @@ -300,7 +300,7 @@ final class Plugin { * * @param \Elementor\Controls_Manager $controls_manager Elementor controls manager. */ - public function register_controls( $controls_manager ) { + public function register_controls( $controls_manager ): void { require_once( __DIR__ . '/includes/controls/control-1.php' ); require_once( __DIR__ . '/includes/controls/control-2.php' ); diff --git a/src/addons/compatibility.md b/src/addons/compatibility.md index e596a35a..66ea4ab1 100644 --- a/src/addons/compatibility.md +++ b/src/addons/compatibility.md @@ -53,8 +53,9 @@ final class Plugin { * * @since 1.0.0 * @access public + * @return bool */ - public function is_compatible() { + public function is_compatible(): bool { // Check if Elementor is installed and activated if ( ! did_action( 'elementor/loaded' ) ) { @@ -86,7 +87,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function admin_notice_missing_main_plugin() { + public function admin_notice_missing_main_plugin(): void { if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); @@ -109,7 +110,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function admin_notice_minimum_elementor_version() { + public function admin_notice_minimum_elementor_version(): void { if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); @@ -133,7 +134,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function admin_notice_minimum_php_version() { + public function admin_notice_minimum_php_version(): void { if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); diff --git a/src/addons/initialization.md b/src/addons/initialization.md index b340be47..1a0236d4 100644 --- a/src/addons/initialization.md +++ b/src/addons/initialization.md @@ -21,14 +21,14 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function init() { + public function init(): void { add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'frontend_styles' ] ); add_action( 'elementor/frontend/after_register_scripts', [ $this, 'frontend_scripts' ] ); } - public function frontend_styles() { + public function frontend_styles(): void { wp_register_style( 'frontend-style-1', plugins_url( 'assets/css/frontend-style-1.css', __FILE__ ) ); wp_register_style( 'frontend-style-2', plugins_url( 'assets/css/frontend-style-2.css', __FILE__ ), [ 'external-framework' ] ); @@ -39,7 +39,7 @@ final class Plugin { } - public function frontend_scripts() { + public function frontend_scripts(): void { wp_register_script( 'frontend-script-1', plugins_url( 'assets/js/frontend-script-1.js', __FILE__ ) ); wp_register_script( 'frontend-script-2', plugins_url( 'assets/js/frontend-script-2.js', __FILE__ ), [ 'external-library' ] ); @@ -70,7 +70,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function init() { + public function init(): void { add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] ); @@ -85,7 +85,7 @@ final class Plugin { * * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager. */ - public function register_widgets( $widgets_manager ) { + public function register_widgets( $widgets_manager ): void { require_once( __DIR__ . '/includes/widgets/widget-1.php' ); require_once( __DIR__ . '/includes/widgets/widget-2.php' ); @@ -115,7 +115,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function init() { + public function init(): void { add_action( 'elementor/controls/register', [ $this, 'register_controls' ] ); @@ -130,7 +130,7 @@ final class Plugin { * * @param \Elementor\Controls_Manager $controls_manager Elementor controls manager. */ - public function register_controls( $controls_manager ) { + public function register_controls( $controls_manager ): void { require_once( __DIR__ . '/includes/controls/control-1.php' ); require_once( __DIR__ . '/includes/controls/control-2.php' ); diff --git a/src/addons/main-class.md b/src/addons/main-class.md index a842ba15..7dd7fa44 100644 --- a/src/addons/main-class.md +++ b/src/addons/main-class.md @@ -15,8 +15,8 @@ final class Plugin { public static function instance() {} public function __construct() {} - public function is_compatible() {} - public function init() {} + public function is_compatible(): bool {} + public function init(): void {} } ``` @@ -94,7 +94,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function is_compatible() { + public function is_compatible(): bool { // Compatibility checks here... @@ -110,7 +110,7 @@ final class Plugin { * @since 1.0.0 * @access public */ - public function init() { + public function init(): void { // Addon functionality here... diff --git a/src/controls/complex-example.md b/src/controls/complex-example.md index bd985fd0..73c5cffc 100644 --- a/src/controls/complex-example.md +++ b/src/controls/complex-example.md @@ -106,7 +106,7 @@ class Elementor_EmojiOneArea_Control extends \Elementor\Base_Data_Control { * @access public * @return string Control type. */ - public function get_type() { + public function get_type(): string { return 'emojionearea'; } @@ -119,7 +119,7 @@ class Elementor_EmojiOneArea_Control extends \Elementor\Base_Data_Control { * @since 1.0.0 * @access public */ - public function enqueue() { + public function enqueue(): void { // Styles wp_register_style( 'emojionearea', 'https://cdnjs.cloudflare.com/ajax/libs/emojionearea/3.4.2/emojionearea.css', [], '3.4.2' ); wp_enqueue_style( 'emojionearea' ); @@ -140,7 +140,7 @@ class Elementor_EmojiOneArea_Control extends \Elementor\Base_Data_Control { * @access protected * @return array Control default settings. */ - protected function get_default_settings() { + protected function get_default_settings(): array { return [ 'label_block' => true, 'rows' => 3, @@ -158,7 +158,7 @@ class Elementor_EmojiOneArea_Control extends \Elementor\Base_Data_Control { * @since 1.0.0 * @access public */ - public function content_template() { + public function content_template(): void { $control_uid = $this->get_control_uid(); ?>