Skip to content

Commit

Permalink
Phpcs fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
thefrosty committed Jun 23, 2023
1 parent 87a7586 commit d4adad8
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Api/LocalizeScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LocalizeScripts

/**
* Localized array to pass from PHP to JS.
* @var array $vars
* @var string[] $vars
*/
protected static array $vars = [];

Expand Down
4 changes: 3 additions & 1 deletion src/Api/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand Down Expand Up @@ -82,6 +83,7 @@ public static function isObfuscated(string $value): bool
}

/**
* Get the Section ID by option key.
* @param string $option_key
* @return string
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Api/PluginSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
7 changes: 5 additions & 2 deletions src/Api/Sanitize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions src/Api/Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -72,7 +72,7 @@ public function getSrc(): string

/**
* Script dependencies array.
* @var array $dependencies
* @var string[] $dependencies
*/
protected array $dependencies = [];

Expand Down
3 changes: 2 additions & 1 deletion src/Api/SettingField.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/**
* Class SettingField
* @package Dwnload\WpSettingsApi\Api
* phpcs:disable SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification
*/
class SettingField extends BaseModel
{
Expand Down Expand Up @@ -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
{
Expand Down
12 changes: 6 additions & 6 deletions src/Api/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -70,7 +70,7 @@ public function getSrc(): string

/**
* Style dependencies array.
* @var array $dependencies
* @var string[] $dependencies
*/
protected array $dependencies = [];

Expand Down

0 comments on commit d4adad8

Please sign in to comment.