Skip to content

Commit d7068b9

Browse files
chore: fix phpstan level 0 issues
1 parent 662af53 commit d7068b9

6 files changed

Lines changed: 17 additions & 51 deletions

File tree

.github/workflows/php-run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Check PHP syntax
1+
name: Lint, analyse and test on highest supported PHP version
22

33
on: [ push, pull_request ]
44

boxzilla.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ function () {
5757
require __DIR__ . '/src/default-filters.php';
5858
require __DIR__ . '/src/default-actions.php';
5959

60-
if (defined('DOING_AJAX') && DOING_AJAX) {
60+
if (wp_doing_ajax()) {
6161
$boxzilla['filter.autocomplete']->init();
6262
$boxzilla['admin.menu']->init();
63-
} elseif (defined('DOING_CRON') && DOING_CRON) {
63+
} elseif (wp_doing_cron()) {
6464
$boxzilla['license_poller']->init();
6565
} elseif (is_admin()) {
6666
$boxzilla['admin']->init();
@@ -75,7 +75,7 @@ function () use ($boxzilla) {
7575
}
7676

7777
// license manager
78-
if (is_admin() || ( defined('DOING_CRON') && DOING_CRON ) || ( defined('WP_CLI') && WP_CLI )) {
78+
if (is_admin() || wp_doing_cron() || ( defined('WP_CLI') && WP_CLI )) {
7979
$boxzilla['license_manager']->init();
8080

8181
if (count($boxzilla->plugins) > 0) {

src/admin/class-admin.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ public function notices()
145145

146146
/**
147147
* Checks current version against stored version & runs necessary update routines.
148-
*
149-
* @return bool
150148
*/
151149
protected function run_migrations()
152150
{
@@ -156,7 +154,7 @@ protected function run_migrations()
156154
$current_version = $this->plugin->version();
157155

158156
if (version_compare($current_version, $previous_version, '<=')) {
159-
return false;
157+
return;
160158
}
161159

162160
$upgrade_routines = new Migrations($previous_version, $current_version, __DIR__ . '/migrations');
@@ -381,13 +379,11 @@ public function load_assets()
381379
* Register meta boxes
382380
*
383381
* @param string $post_type
384-
*
385-
* @return bool
386382
*/
387383
public function add_meta_boxes($post_type)
388384
{
389385
if ($post_type !== 'boxzilla-box') {
390-
return false;
386+
return;
391387
}
392388

393389
add_meta_box(
@@ -423,8 +419,6 @@ public function add_meta_boxes($post_type)
423419
'boxzilla-box',
424420
'side'
425421
);
426-
427-
return true;
428422
}
429423

430424
/**
@@ -489,30 +483,28 @@ public function metabox_support(\WP_Post $post, $metabox)
489483
* Saves box options and rules
490484
*
491485
* @param int $box_id
492-
*
493-
* @return bool
486+
* @param \WP_Post $post
494487
*/
495488
public function save_box_options($box_id, $post)
496489
{
497-
498490
// Only act on our own post type
499491
if ($post->post_type !== 'boxzilla-box') {
500-
return false;
492+
return;
501493
}
502494

503495
// is this a revision save?
504496
if (wp_is_post_revision($box_id) || ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )) {
505-
return false;
497+
return;
506498
}
507499

508500
// can user edit this post?
509501
if (! current_user_can('edit_post', $box_id)) {
510-
return false;
502+
return;
511503
}
512504

513505
// make sure options array is set
514506
if (! isset($_POST['boxzilla_box']) || ! is_array($_POST['boxzilla_box'])) {
515-
return false;
507+
return;
516508
}
517509

518510
// get new options from $_POST
@@ -535,8 +527,6 @@ public function save_box_options($box_id, $post)
535527
}
536528

537529
$this->flush_rules($box_id);
538-
539-
return true;
540530
}
541531

542532
/**

src/admin/class-review-notice.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,33 @@ public function dismiss()
3434
update_user_meta($user->ID, $this->meta_key_dismissed, 1);
3535
}
3636

37-
/**
38-
* @return bool
39-
*/
4037
public function show()
4138
{
4239
$screen = get_current_screen();
4340
if (! $screen instanceof WP_Screen) {
44-
return false;
41+
return;
4542
}
4643

4744
// on some boxzilla screen?
4845
if ($screen->post_type !== 'boxzilla-box') {
49-
return false;
46+
return;
5047
}
5148

5249
// authorized?
5350
if (! current_user_can('edit_posts')) {
54-
return false;
51+
return;
5552
}
5653

5754
// only show if 2 weeks have passed since first use.
5855
$two_weeks_in_seconds = ( 60 * 60 * 24 * 14 );
5956
if ($this->time_since_first_use() <= $two_weeks_in_seconds) {
60-
return false;
57+
return;
6158
}
6259

6360
// only show if user did not dismiss before
6461
$user = wp_get_current_user();
6562
if (get_user_meta($user->ID, $this->meta_key_dismissed, true)) {
66-
return false;
63+
return;
6764
}
6865

6966
echo '<div class="notice notice-info boxzilla-is-dismissible">';
@@ -74,7 +71,6 @@ public function show()
7471
echo '</p>';
7572
echo '<form method="POST"><button type="submit" class="notice-dismiss"><span class="screen-reader-text">', esc_html__('Dismiss this notice.', 'boxzilla'), '</span></button><input type="hidden" name="_boxzilla_admin_action" value="dismiss_review_notice"/></form>';
7673
echo '</div>';
77-
return true;
7874
}
7975

8076
/**

src/di/class-container.php

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
// phpcs:ignoreFile
33
/*
4-
* This file is part of Pimple.
4+
* This is a modified version of Pimple, a dependency injection container for PHP originally developed by Fabien Potencier.
55
*
66
* Copyright (c) 2009 Fabien Potencier
77
*
@@ -253,22 +253,4 @@ public function extend( $id, $callable ) {
253253
public function keys() {
254254
return array_keys( $this->values );
255255
}
256-
257-
/**
258-
* Registers a service provider.
259-
*
260-
* @param ServiceProviderInterface $provider A ServiceProviderInterface instance
261-
* @param array $values An array of values that customizes the provider
262-
*
263-
* @return static
264-
*/
265-
public function register( ServiceProviderInterface $provider, array $values = array() ) {
266-
$provider->register( $this );
267-
268-
foreach ( $values as $key => $value ) {
269-
$this[ $key ] = $value;
270-
}
271-
272-
return $this;
273-
}
274256
}

src/licensing/class-license.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ public function reload()
109109

110110
/**
111111
* Save the license in the database
112-
*
113-
* @return License
114112
*/
115113
public function save()
116114
{

0 commit comments

Comments
 (0)