From d4adad863803f164beda749ed5cd4547a7cd3250 Mon Sep 17 00:00:00 2001 From: Austin Passy <367897+thefrosty@users.noreply.github.com> Date: Fri, 23 Jun 2023 09:24:01 -0700 Subject: [PATCH] Phpcs fixes. --- src/Api/LocalizeScripts.php | 2 +- src/Api/Options.php | 4 +++- src/Api/PluginSettings.php | 2 ++ src/Api/Sanitize.php | 7 +++++-- src/Api/Script.php | 16 ++++++++-------- src/Api/SettingField.php | 3 ++- src/Api/Style.php | 12 ++++++------ 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/Api/LocalizeScripts.php b/src/Api/LocalizeScripts.php index 5e7a1f2..e2969fc 100755 --- a/src/Api/LocalizeScripts.php +++ b/src/Api/LocalizeScripts.php @@ -17,7 +17,7 @@ class LocalizeScripts /** * Localized array to pass from PHP to JS. - * @var array $vars + * @var string[] $vars */ protected static array $vars = []; diff --git a/src/Api/Options.php b/src/Api/Options.php index d947f94..45c3dd1 100755 --- a/src/Api/Options.php +++ b/src/Api/Options.php @@ -28,7 +28,7 @@ class Options * Defaults to an empty string. * @return mixed */ - public static function getOption(string $option_key, string $section_id = null, mixed $default = ''): mixed + public static function getOption(string $option_key, ?string $section_id = null, mixed $default = ''): mixed { if (empty($section_id)) { $section_id = self::getSectionId($option_key); @@ -49,6 +49,7 @@ public static function getOptions(string $section_id): mixed } /** + * Get the obfuscated option value. * @param string $option_key Settings field key name in the section option array. * @param string $section_id The Section object ID the option belongs too. * @param mixed $default (Optional) Default value if option is not found. @@ -82,6 +83,7 @@ public static function isObfuscated(string $value): bool } /** + * Get the Section ID by option key. * @param string $option_key * @return string */ diff --git a/src/Api/PluginSettings.php b/src/Api/PluginSettings.php index bc749ba..423477e 100755 --- a/src/Api/PluginSettings.php +++ b/src/Api/PluginSettings.php @@ -10,6 +10,8 @@ /** * Class PluginInfo * @package Dwnload\WpSettingsApi\Api + * phpcs:disable Generic.Commenting.DocComment.MissingShort + * phpcs:disable Squiz.Commenting.FunctionComment.Missing */ class PluginSettings extends BaseModel { diff --git a/src/Api/Sanitize.php b/src/Api/Sanitize.php index 6426855..d5490ba 100644 --- a/src/Api/Sanitize.php +++ b/src/Api/Sanitize.php @@ -41,9 +41,12 @@ public static function sanitizeObfuscated(mixed $value, array $options, string $ */ private static function getSectionId(string $option_slug): string { - // Iterate over registered fields and see if we can find proper callback + // Iterate over registered fields and see if we can find proper callback. foreach (FieldManager::getFields() as $fields) { - /** @var SettingField $field */ + /** + * Filed object. + * @var SettingField $field + */ foreach ($fields as $field) { if ($field->getName() === $option_slug) { return $field->getSectionId(); diff --git a/src/Api/Script.php b/src/Api/Script.php index 525211f..90f5feb 100755 --- a/src/Api/Script.php +++ b/src/Api/Script.php @@ -14,13 +14,13 @@ class Script extends BaseModel { - const OBJECT_NAME = 'dwnload_wp_settings_api'; - const HANDLE = 'handle'; - const SRC = 'src'; - const DEPENDENCIES = 'dependencies'; - const VERSION = 'version'; - const IN_FOOTER = 'inFooter'; - const INLINE_SCRIPT = 'inline_script'; + public const OBJECT_NAME = 'dwnload_wp_settings_api'; + public const HANDLE = 'handle'; + public const SRC = 'src'; + public const DEPENDENCIES = 'dependencies'; + public const VERSION = 'version'; + public const IN_FOOTER = 'inFooter'; + public const INLINE_SCRIPT = 'inline_script'; /** * Script handle (name). @@ -72,7 +72,7 @@ public function getSrc(): string /** * Script dependencies array. - * @var array $dependencies + * @var string[] $dependencies */ protected array $dependencies = []; diff --git a/src/Api/SettingField.php b/src/Api/SettingField.php index 92b47ac..c19f999 100755 --- a/src/Api/SettingField.php +++ b/src/Api/SettingField.php @@ -10,6 +10,7 @@ /** * Class SettingField * @package Dwnload\WpSettingsApi\Api + * phpcs:disable SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification */ class SettingField extends BaseModel { @@ -94,8 +95,8 @@ public function getDefault(): mixed /** * Sets the Fields label (description). + * @param string $label * @return self - * @var string $label */ public function setLabel(string $label): self { diff --git a/src/Api/Style.php b/src/Api/Style.php index b184e31..c906423 100755 --- a/src/Api/Style.php +++ b/src/Api/Style.php @@ -14,11 +14,11 @@ class Style extends BaseModel { - const HANDLE = 'handle'; - const SRC = 'src'; - const DEPENDENCIES = 'dependencies'; - const VERSION = 'version'; - const MEDIA = 'media'; + public const HANDLE = 'handle'; + public const SRC = 'src'; + public const DEPENDENCIES = 'dependencies'; + public const VERSION = 'version'; + public const MEDIA = 'media'; /** * Style handle (name). @@ -70,7 +70,7 @@ public function getSrc(): string /** * Style dependencies array. - * @var array $dependencies + * @var string[] $dependencies */ protected array $dependencies = [];