Skip to content

Commit

Permalink
refactor: phpstan code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Jan 19, 2025
1 parent 5744bf7 commit af9522b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
30 changes: 15 additions & 15 deletions src/fields/Units.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,33 @@ class Units extends Field implements PreviewableFieldInterface
// Public Properties
// =========================================================================
/**
* @var float The default value of the unit of measure
* @var ?float The default value of the unit of measure
*/
public float $defaultValue;
public ?float $defaultValue = null;
/**
* @var string The default units that the unit of measure is in
* @var ?string The default units that the unit of measure is in
*/
public string $defaultUnits;
public ?string $defaultUnits = null;
/**
* @var bool Whether the units the field can be changed
* @var ?bool Whether the units the field can be changed
*/
public bool $changeableUnits;
public ?bool $changeableUnits = null;
/**
* @var int|float The minimum allowed number
* @var int|float|null The minimum allowed number
*/
public int|float $min;
public int|float|null $min = null;
/**
* @var int|float|null The maximum allowed number
*/
public int|null|float $max;
public int|float|null $max = null;
/**
* @var int The number of digits allowed after the decimal point
* @var ?int The number of digits allowed after the decimal point
*/
public int $decimals;
public ?int $decimals = null;
/**
* @var int|null The size of the field
* @var ?int The size of the field
*/
public ?int $size;
public ?int $size = null;

/**
* @inheritdoc
Expand All @@ -93,10 +93,10 @@ public static function displayName(): string
public function init(): void
{
parent::init();
/** @var Settings $settings */
if (UnitsPlugin::$plugin !== null) {
/** @var Settings $settings */
$settings = UnitsPlugin::$plugin->getSettings();
if (!empty($settings)) {
if ($settings !== null) {
$this->defaultUnitsClass = $this->defaultUnitsClass ?? $settings->defaultUnitsClass;
$this->defaultValue = $this->defaultValue ?? $settings->defaultValue;
$this->defaultUnits = $this->defaultUnits ?? $settings->defaultUnits;
Expand Down
13 changes: 6 additions & 7 deletions src/models/UnitsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ class UnitsData extends Model implements PhysicalQuantityInterface
// =========================================================================

/**
* @var string The fully qualified class name of the unit of measure
* @var ?string The fully qualified class name of the unit of measure
*/
public string $unitsClass;
public ?string $unitsClass = null;

/**
* @var float The value of the unit of measure
* @var ?float The value of the unit of measure
*/
public float $value;
public ?float $value = null;

/**
* @var string The units that the unit of measure is in
* @var ?string The units that the unit of measure is in
*/
public string $units;
public ?string $units = null;

/**
* @var AbstractPhysicalQuantity
Expand Down Expand Up @@ -187,7 +187,6 @@ public function isEquivalentQuantity(PhysicalQuantityInterface $testQuantity)
public function availableUnits(bool $includeAliases = true)
{
$availableUnits = [];
/** @var AbstractPhysicalQuantity $unitsClass */
$units = $this->unitsInstance::getUnitDefinitions();
/** @var UnitOfMeasure $unit */
foreach ($units as $unit) {
Expand Down
8 changes: 4 additions & 4 deletions src/validators/EmbeddedUnitsDataValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ class EmbeddedUnitsDataValidator extends Validator
*/
public $integerOnly = false;
/**
* @var int|float upper limit of the number. Defaults to null, meaning no
* @var int|float|null upper limit of the number. Defaults to null, meaning no
* upper limit.
* @see tooBig for the customized message used when the number is too big.
*/
public $max;
public $max = null;
/**
* @var int|float lower limit of the number. Defaults to null, meaning no
* @var int|float|null lower limit of the number. Defaults to null, meaning no
* lower limit.
* @see tooSmall for the customized message used when the number is too
* small.
*/
public $min;
public $min = null;

// Public Methods
// =========================================================================
Expand Down

0 comments on commit af9522b

Please sign in to comment.