Skip to content

Commit

Permalink
Fixed some PHPStan errors around comparisons and literal positions
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmantank committed Sep 10, 2022
1 parent 7d97005 commit fc75c83
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Cron/DayOfMonthField.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public function isSatisfiedBy(DateTimeInterface $date, $value, bool $invert): bo
}

// Check to see if this is the nearest weekday to a particular value
if (strpos($value, 'W')) {
if ($wPosition = strpos($value, 'W')) {
// Parse the target day
$targetDay = (int) substr($value, 0, strpos($value, 'W'));
$targetDay = (int) substr($value, 0, $wPosition);
// Find out if the current day is the nearest day of the week
$nearest = self::getNearestWeekday(
(int) $date->format('Y'),
Expand Down
4 changes: 2 additions & 2 deletions src/Cron/DayOfWeekField.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public function isSatisfiedBy(DateTimeInterface $date, $value, bool $invert): bo
$lastDayOfMonth = (int) $date->format('t');

// Find out if this is the last specific weekday of the month
if (strpos($value, 'L')) {
$weekday = $this->convertLiterals(substr($value, 0, strpos($value, 'L')));
if ($lPosition = strpos($value, 'L')) {
$weekday = $this->convertLiterals(substr($value, 0, $lPosition));
$weekday %= 7;

$daysInMonth = (int) $date->format('t');
Expand Down
4 changes: 2 additions & 2 deletions src/Cron/HoursField.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class HoursField extends AbstractField
/**
* @var array|null Transitions returned by DateTimeZone::getTransitions()
*/
protected $transitions = null;
protected $transitions = [];

/**
* @var int|null Timestamp of the start of the transitions range
Expand Down Expand Up @@ -92,7 +92,7 @@ public function getPastTransition(DateTimeInterface $date): ?array
$dtLimitStart->getTimestamp(),
$dtLimitEnd->getTimestamp()
);
if ($this->transitions === false) {
if (empty($this->transitions)) {
return null;
}
$this->transitionsStart = $dtLimitStart->getTimestamp();
Expand Down

0 comments on commit fc75c83

Please sign in to comment.