Skip to content

Commit 2f9f3ed

Browse files
Add return types (#290)
1 parent 7ff399b commit 2f9f3ed

File tree

127 files changed

+476
-475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+476
-475
lines changed

src/addons/addon-example.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ final class Plugin {
160160
* @since 1.0.0
161161
* @access public
162162
*/
163-
public function is_compatible() {
163+
public function is_compatible(): void {
164164

165165
// Check if Elementor installed and activated
166166
if ( ! did_action( 'elementor/loaded' ) ) {
@@ -192,7 +192,7 @@ final class Plugin {
192192
* @since 1.0.0
193193
* @access public
194194
*/
195-
public function admin_notice_missing_main_plugin() {
195+
public function admin_notice_missing_main_plugin(): void {
196196

197197
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
198198

@@ -215,7 +215,7 @@ final class Plugin {
215215
* @since 1.0.0
216216
* @access public
217217
*/
218-
public function admin_notice_minimum_elementor_version() {
218+
public function admin_notice_minimum_elementor_version(): void {
219219

220220
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
221221

@@ -239,7 +239,7 @@ final class Plugin {
239239
* @since 1.0.0
240240
* @access public
241241
*/
242-
public function admin_notice_minimum_php_version() {
242+
public function admin_notice_minimum_php_version(): void {
243243

244244
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
245245

@@ -265,7 +265,7 @@ final class Plugin {
265265
* @since 1.0.0
266266
* @access public
267267
*/
268-
public function init() {
268+
public function init(): void {
269269

270270
add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] );
271271
add_action( 'elementor/controls/register', [ $this, 'register_controls' ] );
@@ -281,7 +281,7 @@ final class Plugin {
281281
*
282282
* @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
283283
*/
284-
public function register_widgets( $widgets_manager ) {
284+
public function register_widgets( $widgets_manager ): void {
285285

286286
require_once( __DIR__ . '/includes/widgets/widget-1.php' );
287287
require_once( __DIR__ . '/includes/widgets/widget-2.php' );
@@ -300,7 +300,7 @@ final class Plugin {
300300
*
301301
* @param \Elementor\Controls_Manager $controls_manager Elementor controls manager.
302302
*/
303-
public function register_controls( $controls_manager ) {
303+
public function register_controls( $controls_manager ): void {
304304

305305
require_once( __DIR__ . '/includes/controls/control-1.php' );
306306
require_once( __DIR__ . '/includes/controls/control-2.php' );

src/addons/compatibility.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ final class Plugin {
5353
*
5454
* @since 1.0.0
5555
* @access public
56+
* @return bool
5657
*/
57-
public function is_compatible() {
58+
public function is_compatible(): bool {
5859

5960
// Check if Elementor is installed and activated
6061
if ( ! did_action( 'elementor/loaded' ) ) {
@@ -86,7 +87,7 @@ final class Plugin {
8687
* @since 1.0.0
8788
* @access public
8889
*/
89-
public function admin_notice_missing_main_plugin() {
90+
public function admin_notice_missing_main_plugin(): void {
9091

9192
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
9293

@@ -109,7 +110,7 @@ final class Plugin {
109110
* @since 1.0.0
110111
* @access public
111112
*/
112-
public function admin_notice_minimum_elementor_version() {
113+
public function admin_notice_minimum_elementor_version(): void {
113114

114115
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
115116

@@ -133,7 +134,7 @@ final class Plugin {
133134
* @since 1.0.0
134135
* @access public
135136
*/
136-
public function admin_notice_minimum_php_version() {
137+
public function admin_notice_minimum_php_version(): void {
137138

138139
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
139140

src/addons/initialization.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ final class Plugin {
2121
* @since 1.0.0
2222
* @access public
2323
*/
24-
public function init() {
24+
public function init(): void {
2525

2626
add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'frontend_styles' ] );
2727
add_action( 'elementor/frontend/after_register_scripts', [ $this, 'frontend_scripts' ] );
2828

2929
}
3030

31-
public function frontend_styles() {
31+
public function frontend_styles(): void {
3232

3333
wp_register_style( 'frontend-style-1', plugins_url( 'assets/css/frontend-style-1.css', __FILE__ ) );
3434
wp_register_style( 'frontend-style-2', plugins_url( 'assets/css/frontend-style-2.css', __FILE__ ), [ 'external-framework' ] );
@@ -39,7 +39,7 @@ final class Plugin {
3939

4040
}
4141

42-
public function frontend_scripts() {
42+
public function frontend_scripts(): void {
4343

4444
wp_register_script( 'frontend-script-1', plugins_url( 'assets/js/frontend-script-1.js', __FILE__ ) );
4545
wp_register_script( 'frontend-script-2', plugins_url( 'assets/js/frontend-script-2.js', __FILE__ ), [ 'external-library' ] );
@@ -70,7 +70,7 @@ final class Plugin {
7070
* @since 1.0.0
7171
* @access public
7272
*/
73-
public function init() {
73+
public function init(): void {
7474

7575
add_action( 'elementor/widgets/register', [ $this, 'register_widgets' ] );
7676

@@ -85,7 +85,7 @@ final class Plugin {
8585
*
8686
* @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
8787
*/
88-
public function register_widgets( $widgets_manager ) {
88+
public function register_widgets( $widgets_manager ): void {
8989

9090
require_once( __DIR__ . '/includes/widgets/widget-1.php' );
9191
require_once( __DIR__ . '/includes/widgets/widget-2.php' );
@@ -115,7 +115,7 @@ final class Plugin {
115115
* @since 1.0.0
116116
* @access public
117117
*/
118-
public function init() {
118+
public function init(): void {
119119

120120
add_action( 'elementor/controls/register', [ $this, 'register_controls' ] );
121121

@@ -130,7 +130,7 @@ final class Plugin {
130130
*
131131
* @param \Elementor\Controls_Manager $controls_manager Elementor controls manager.
132132
*/
133-
public function register_controls( $controls_manager ) {
133+
public function register_controls( $controls_manager ): void {
134134

135135
require_once( __DIR__ . '/includes/controls/control-1.php' );
136136
require_once( __DIR__ . '/includes/controls/control-2.php' );

src/addons/main-class.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ final class Plugin {
1515
public static function instance() {}
1616

1717
public function __construct() {}
18-
public function is_compatible() {}
19-
public function init() {}
18+
public function is_compatible(): bool {}
19+
public function init(): void {}
2020

2121
}
2222
```
@@ -94,7 +94,7 @@ final class Plugin {
9494
* @since 1.0.0
9595
* @access public
9696
*/
97-
public function is_compatible() {
97+
public function is_compatible(): bool {
9898

9999
// Compatibility checks here...
100100

@@ -110,7 +110,7 @@ final class Plugin {
110110
* @since 1.0.0
111111
* @access public
112112
*/
113-
public function init() {
113+
public function init(): void {
114114

115115
// Addon functionality here...
116116

src/controls/complex-example.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Elementor_EmojiOneArea_Control extends \Elementor\Base_Data_Control {
106106
* @access public
107107
* @return string Control type.
108108
*/
109-
public function get_type() {
109+
public function get_type(): string {
110110
return 'emojionearea';
111111
}
112112

@@ -119,7 +119,7 @@ class Elementor_EmojiOneArea_Control extends \Elementor\Base_Data_Control {
119119
* @since 1.0.0
120120
* @access public
121121
*/
122-
public function enqueue() {
122+
public function enqueue(): void {
123123
// Styles
124124
wp_register_style( 'emojionearea', 'https://cdnjs.cloudflare.com/ajax/libs/emojionearea/3.4.2/emojionearea.css', [], '3.4.2' );
125125
wp_enqueue_style( 'emojionearea' );
@@ -140,7 +140,7 @@ class Elementor_EmojiOneArea_Control extends \Elementor\Base_Data_Control {
140140
* @access protected
141141
* @return array Control default settings.
142142
*/
143-
protected function get_default_settings() {
143+
protected function get_default_settings(): array {
144144
return [
145145
'label_block' => true,
146146
'rows' => 3,
@@ -158,7 +158,7 @@ class Elementor_EmojiOneArea_Control extends \Elementor\Base_Data_Control {
158158
* @since 1.0.0
159159
* @access public
160160
*/
161-
public function content_template() {
161+
public function content_template(): void {
162162
$control_uid = $this->get_control_uid();
163163
?>
164164
<div class="elementor-control-field">
@@ -245,7 +245,7 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
245245
* @access public
246246
* @return string Widget name.
247247
*/
248-
public function get_name() {
248+
public function get_name(): string {
249249
return 'test';
250250
}
251251

@@ -258,7 +258,7 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
258258
* @access public
259259
* @return string Widget title.
260260
*/
261-
public function get_title() {
261+
public function get_title(): string {
262262
return esc_html__( 'Test', 'elementor-emojionearea-control' );
263263
}
264264

@@ -271,7 +271,7 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
271271
* @access public
272272
* @return string Widget icon.
273273
*/
274-
public function get_icon() {
274+
public function get_icon(): string {
275275
return 'eicon-code';
276276
}
277277

@@ -284,7 +284,7 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
284284
* @access public
285285
* @return array Widget categories.
286286
*/
287-
public function get_categories() {
287+
public function get_categories(): array {
288288
return [ 'general' ];
289289
}
290290

@@ -297,7 +297,7 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
297297
* @access public
298298
* @return array Widget keywords.
299299
*/
300-
public function get_keywords() {
300+
public function get_keywords(): array {
301301
return [ 'test', 'emoji' ];
302302
}
303303

@@ -310,7 +310,7 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
310310
* @access public
311311
* @return string Widget help URL.
312312
*/
313-
public function get_custom_help_url() {
313+
public function get_custom_help_url(): string {
314314
return 'https://developers.elementor.com/docs/widgets/';
315315
}
316316

@@ -322,7 +322,7 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
322322
* @since 1.0.0
323323
* @access protected
324324
*/
325-
protected function register_controls() {
325+
protected function register_controls(): void {
326326

327327
$this->start_controls_section(
328328
'content_section',
@@ -353,7 +353,7 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
353353
* @since 1.0.0
354354
* @access protected
355355
*/
356-
protected function render() {
356+
protected function render(): void {
357357
$settings = $this->get_settings_for_display();
358358

359359
if ( empty( $settings['content'] ) ) {

src/controls/control-enqueue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ If you need to use an external library or some custom JS/CSS, you can do that by
1111
```php
1212
class Elementor_Test_Control extends \Elementor\Base_Control {
1313

14-
protected function enqueue() {
14+
protected function enqueue(): void {
1515

1616
// Styles
1717
wp_register_style( 'control-style', plugins_url( 'assets/css/control-style.css', __FILE__ ) );

src/controls/control-settings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ If a control uses the default settings, you don't need to add it to your class.
2525
```php
2626
class Elementor_Test_Control extends \Elementor\Base_Control {
2727

28-
protected function get_default_settings() {
28+
protected function get_default_settings(): array {
2929

3030
return [
3131
'label_block' => true,

src/controls/control-structure.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ A simple control only requires two methods, the control type and the template:
3131
```php
3232
class Elementor_Test_Control extends \Elementor\Base_Control {
3333

34-
public function get_type() {}
34+
public function get_type(): string {}
3535

36-
public function content_template() {}
36+
public function content_template(): void {}
3737

3838
}
3939
```
@@ -43,15 +43,15 @@ More advanced controls can use other available methods:
4343
```php
4444
class Elementor_Test_Control extends \Elementor\Base_Control {
4545

46-
public function get_type() {}
46+
public function get_type(): string {}
4747

48-
protected function get_default_settings() {}
48+
protected function get_default_settings(): array {}
4949

50-
public function get_default_value() {}
50+
public function get_default_value(): string {}
5151

52-
public function content_template() {}
52+
public function content_template(): void {}
5353

54-
public function enqueue() {}
54+
public function enqueue(): void {}
5555

5656
}
5757
```

src/controls/control-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ With JS templates we don’t need to retrieve data using a special function, Ele
1313
<?php
1414
class Elementor_Test_Control extends \Elementor\Base_Control {
1515

16-
public function content_template() {
16+
public function content_template(): void {
1717
$control_uid = $this->get_control_uid();
1818
?>
1919

src/controls/control-values.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ The following will set a default value for a [data control](./../editor-controls
1313
```php
1414
class Elementor_Test_Control extends \Elementor\Base_Data_Control {
1515

16-
public function get_type() {
16+
public function get_type(): string {
1717
return 'continents-control';
1818
}
1919

20-
protected function get_default_settings() {
20+
protected function get_default_settings(): array {
2121
return [
2222
'continents' => [ 'Asia', 'Africa', 'Europe', 'North America', 'South America', 'Australia/Oceania', 'Antarctica', ]
2323
];
2424
}
2525

26-
public function get_default_value() {
26+
public function get_default_value(): string {
2727
return 'Europe';
2828
}
2929

@@ -38,7 +38,7 @@ When controls are used in widgets, you can either use the default value set by t
3838
<?php
3939
class Elementor_Test_Widget extends \Elementor\Widget_Base {
4040

41-
protected function register_controls() {
41+
protected function register_controls(): void {
4242

4343
$this->start_controls_section(
4444
'section_content',

0 commit comments

Comments
 (0)