Skip to content

Commit

Permalink
Update PHPStan level to 6
Browse files Browse the repository at this point in the history
  • Loading branch information
TorbenLundsgaard committed Sep 3, 2024
1 parent 07de56d commit ca06f67
Show file tree
Hide file tree
Showing 30 changed files with 246 additions and 244 deletions.
8 changes: 4 additions & 4 deletions inc/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ function gtmkit_plugin_deactivation(): void {
/**
* Add plugin action links on Plugins page.
*
* @param array $links Existing plugin action links.
* @param array<string, string> $links Existing plugin action links.
*
* @return array
* @return array<string, string>
*/
function gtmkit_add_plugin_action_link( array $links ): array {

Expand All @@ -96,9 +96,9 @@ function gtmkit_add_plugin_action_link( array $links ): array {
/**
* Remove deactivation link.
*
* @param array $links Existing plugin action links.
* @param array<string, string> $links Existing plugin action links.
*
* @return array
* @return array<string, string>
*/
function gtmkit_remove_deactivation_link( array $links ): array {

Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
parameters:
level: 5
level: 6
treatPhpDocTypesAsCertain: false
bootstrapFiles:
- bin/phpstan/constants.php
Expand Down
6 changes: 3 additions & 3 deletions src/Admin/AbstractOptionsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ abstract class AbstractOptionsPage {
*
* @var string
*/
protected $option_name = 'gtmkit';
protected string $option_name = 'gtmkit';

/**
* Plugin options.
*
* @var Options
*/
protected $options;
protected Options $options;

/**
* Utilities
*
* @var Util
*/
protected $util;
protected Util $util;

/**
* Constructor.
Expand Down
8 changes: 4 additions & 4 deletions src/Admin/AdminAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ final class AdminAPI {
*
* @var Options
*/
private $options;
private Options $options;

/**
* An instance of Util.
*
* @var Util
*/
private $util;
private Util $util;

/**
* Constructor
Expand Down Expand Up @@ -192,7 +192,7 @@ public function set_notification_status(): void {
/**
* Validate notification input
*
* @param array|null $input The input.
* @param array<string, string>|null $input The input.
* @return bool
*/
private function validate_notification_input( ?array $input ): bool {
Expand All @@ -203,7 +203,7 @@ private function validate_notification_input( ?array $input ): bool {
/**
* Get JSON input
*
* @return array|null
* @return array<string, string>|null
*/
private function get_json_input(): ?array {
$input_raw = file_get_contents( 'php://input' );
Expand Down
6 changes: 3 additions & 3 deletions src/Admin/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ final class Analytics {
*
* @var Analytics
*/
public static $instance;
public static Analytics $instance;

/**
* Plugin options.
*
* @var Options
*/
protected $options;
protected Options $options;

/**
* Utility
*
* @var Util
*/
private $util;
private Util $util;

/**
* Constructor.
Expand Down
14 changes: 7 additions & 7 deletions src/Admin/GeneralOptionsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ final class GeneralOptionsPage extends AbstractOptionsPage {
*
* @var string
*/
protected $option_group = 'general';
protected string $option_group = 'general';

/**
* The notifications
*
* @var array
* @var array<string, array<string, int|array<string>>|int>
*/
protected $notifications = [];
protected array $notifications = [];

/**
* Adds the admin page to the menu.
Expand Down Expand Up @@ -140,9 +140,9 @@ public function localize_script( string $page_slug, string $script_handle ): voi
}

/**
* Get the templates
* Get the tutorials
*
* @return array
* @return array<string, mixed>
*/
private function get_tutorials(): array {
return $this->util->get_data( '/get-tutorials', 'gtmkit_tutorials' );
Expand All @@ -151,7 +151,7 @@ private function get_tutorials(): array {
/**
* Get user roles
*
* @return array
* @return array<array<string, string>>
*/
private function get_user_roles(): array {

Expand All @@ -171,7 +171,7 @@ private function get_user_roles(): array {
/**
* Get the notifications array
*
* @return array
* @return array<string, array<string, int|array<string>>|int>
*/
private function get_notifications_array(): array {
if ( empty( $this->notifications ) ) {
Expand Down
4 changes: 2 additions & 2 deletions src/Admin/HelpOptionsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class HelpOptionsPage extends AbstractOptionsPage {
*
* @var string
*/
protected $option_group = 'help';
protected string $option_group = 'help';

/**
* Configure the options page.
Expand Down Expand Up @@ -101,7 +101,7 @@ public function localize_script( string $page_slug, string $script_handle ): voi
/**
* Get the templates
*
* @return array
* @return array<string, mixed>
*/
private function get_tutorials(): array {
return $this->util->get_data( '/get-tutorials', 'gtmkit_tutorials' );
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/Integrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class Integrations {
/**
* Get the integrations
*
* @return array
* @return array<string, array<string, string>>
*/
public static function get_integrations(): array {

Expand Down
4 changes: 2 additions & 2 deletions src/Admin/IntegrationsOptionsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class IntegrationsOptionsPage extends AbstractOptionsPage {
*
* @var string
*/
protected $option_group = 'integrations';
protected string $option_group = 'integrations';

/**
* Configure the options page.
Expand Down Expand Up @@ -128,7 +128,7 @@ public function localize_script( string $page_slug, string $script_handle ): voi
/**
* Get the plugins.
*
* @return array
* @return array<string, bool>
*/
private function get_plugins(): array {
$plugins = [
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/MetaBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class MetaBox {
*
* @var Options
*/
protected $options;
protected Options $options;

/**
* Constructor.
Expand Down
26 changes: 13 additions & 13 deletions src/Admin/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ class Notification {
/**
* Options of this Notification.
*
* @var array
* @var array<string, mixed>
*/
private $options;
private array $options;

/**
* The default values for the optional arguments.
*
* @var array
* @var array<string, mixed>
*/
private $defaults = [
private array $defaults = [
'id' => '',
'user_id' => null,
'type' => self::NOTICE,
Expand All @@ -50,21 +50,21 @@ class Notification {
*
* @var string
*/
private $header;
private string $header;

/**
* The message for the notification.
*
* @var string
*/
private $message;
private string $message;

/**
* Notification class constructor.
*
* @param string $message Message string.
* @param string $header The header.
* @param array $options Set of options.
* @param string $message Message string.
* @param string $header The header.
* @param array<string, mixed> $options Set of options.
*/
public function __construct( string $message, string $header = '', array $options = [] ) {
$this->header = $header;
Expand Down Expand Up @@ -142,7 +142,7 @@ private function has_capability( string $capability ): bool {
/**
* Return the object properties as an array.
*
* @return array
* @return array<string, mixed>
*/
public function to_array(): array {
return [
Expand All @@ -164,7 +164,7 @@ public function __toString(): string {
/**
* Renders the notification as an array for use in the settings.
*
* @return array The rendered notification.
* @return array<string, string> The rendered notification.
*/
public function render(): array {
return [
Expand All @@ -177,9 +177,9 @@ public function render(): array {
/**
* Make sure we only have values that we can work with.
*
* @param array $options Options to normalize.
* @param array<string, mixed> $options Options to normalize.
*
* @return array
* @return array<string, mixed>
*/
private function normalize_options( array $options ): array {
$options = wp_parse_args( $options, $this->defaults );
Expand Down
Loading

0 comments on commit ca06f67

Please sign in to comment.