kylekatarnls/business-day

View on GitHub

Showing 117 of 118 total issues

Argument 4 (mon) is float but \mktime() takes int
Open

        $easter = mktime(0, 0, 0, $month, $day + 13, $year);

Rename "$year" which has the same name as the field declared at line 17.
Open

        $year = $this->year;

Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

Noncompliant Code Example

class Foo {
  public $myField;

  public function doSomething() {
    $myField = 0;
    ...
  }
}

See

Instantiation of abstract class \Cmixin\BusinessDay\Calendar\AlternativeCalendar
Open

            static::$singletons[$name] = new static();

Argument 1 (mixin) is \Cmixin\BusinessDay\Holiday|\Cmixin\BusinessDay\HolidayData|\Cmixin\BusinessDay\HolidaysList|\Cmixin\BusinessDay\MixinBase|\Cmixin\BusinessDay\YearCrawler but \Cmixin\BusinessDay\Calculator\MixinConfigPropagator::setHolidayGetter() takes \Cmixin\BusinessDay\BusinessCalendar defined at /code/src/Cmixin/BusinessDay/Calculator/MixinConfigPropagator.php:56
Open

                $mixin,
Severity: Minor
Found in src/Cmixin/BusinessDay/Holiday.php by phan

Cannot access internal method \Cmixin\BusinessDay\BusinessMonth::getStart() of namespace \Cmixin\BusinessDay defined at /code/src/Cmixin/BusinessDay/BusinessMonth.php:39 from namespace \Cmixin
Open

            return $month->getStart()->diffInBusinessDays($month->getEnd());
Severity: Minor
Found in src/Cmixin/BusinessDay.php by phan

Expression may not be PHP 7 compatible
Open

            if (!$region || !isset($mixin->$list[$region])) {

Argument 2 (str) is array<int></int> but \explode() takes string
Open

            $holiday = explode(" $variable ", $holiday, 2);

Expression may not be PHP 7 compatible
Open

                if (!isset($this->$list[$region])) {

Rename "$outputClass" which has the same name as the field declared at line 24.
Open

        $outputClass = $this->outputClass;

Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

Noncompliant Code Example

class Foo {
  public $myField;

  public function doSomething() {
    $myField = 0;
    ...
  }
}

See

Argument 1 (mixin) is \Cmixin\BusinessDay\Holiday|\Cmixin\BusinessDay\HolidayData|\Cmixin\BusinessDay\HolidaysList|\Cmixin\BusinessDay\MixinBase|\Cmixin\BusinessDay\YearCrawler but \Cmixin\BusinessDay\Calculator\MixinConfigPropagator::getExtraWorkdayGetter() takes \Cmixin\BusinessDay\BusinessCalendar defined at /code/src/Cmixin/BusinessDay/Calculator/MixinConfigPropagator.php:71
Open

            $workdayGetter = MixinConfigPropagator::getExtraWorkdayGetter($mixin, $self);
Severity: Minor
Found in src/Cmixin/BusinessDay/Holiday.php by phan

Cannot access internal method \Cmixin\BusinessDay\Calculator\HolidayCalculator::setOutputClass() of namespace \Cmixin\BusinessDay\Calculator defined at /code/src/Cmixin/BusinessDay/Calculator/HolidayCalculator.php:56 from namespace \Cmixin\BusinessDay
Open

            $calculator->setOutputClass($outputClass);
Severity: Minor
Found in src/Cmixin/BusinessDay/YearCrawler.php by phan

Rename "$workdayGetter" which has the same name as the field declared at line 34.
Open

            $workdayGetter = MixinConfigPropagator::getExtraWorkdayGetter($mixin, $self);

Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

Noncompliant Code Example

class Foo {
  public $myField;

  public function doSomething() {
    $myField = 0;
    ...
  }
}

See

Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed.
Open

    public function setHolidaysRegion()

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Invalid value of type \Closure in an array destructuring assignment, expected array|ArrayAccess
Open

            [$days, $date] = static::swapDateTimeParam($days, $date, null);
Severity: Minor
Found in src/Cmixin/BusinessDay.php by phan

Expression may not be PHP 7 compatible
Open

                : ($mixin->$list[$region][] = $day);

Cannot access internal method \Cmixin\BusinessDay\BusinessMonth::getEnd() of namespace \Cmixin\BusinessDay defined at /code/src/Cmixin/BusinessDay/BusinessMonth.php:47 from namespace \Cmixin
Open

            return $month->getStart()->diffInBusinessDays($month->getEnd());
Severity: Minor
Found in src/Cmixin/BusinessDay.php by phan

Cannot access internal method \Cmixin\BusinessDay\BusinessMonth::__construct() of namespace \Cmixin\BusinessDay defined at /code/src/Cmixin/BusinessDay/BusinessMonth.php:24 from namespace \Cmixin
Open

            $month = new BusinessMonth($date ?? $self, get_class($self));
Severity: Minor
Found in src/Cmixin/BusinessDay.php by phan

Cannot access internal method \Cmixin\BusinessDay\BusinessMonth::getEnd() of namespace \Cmixin\BusinessDay defined at /code/src/Cmixin/BusinessDay/BusinessMonth.php:47 from namespace \Cmixin
Open

            while ($date < $month->getEnd()) {
Severity: Minor
Found in src/Cmixin/BusinessDay.php by phan

Possibly zero references to use statement for classlike/namespace BusinessDay (\Cmixin\BusinessDay)
Open

use Cmixin\BusinessDay;
Severity: Minor
Found in src/Cmixin/BusinessDay/HolidayData.php by phan

Define a constant instead of duplicating this literal "holidays" 4 times.
Open

            if (!in_array($list, ['holidays', 'workdays'])) {

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Severity
Category
Status
Source
Language