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);
- Exclude checks
Rename "$year" which has the same name as the field declared at line 17. Open
$year = $this->year;
- Read upRead up
- Exclude checks
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
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Instantiation of abstract class \Cmixin\BusinessDay\Calendar\AlternativeCalendar
Open
static::$singletons[$name] = new static();
- Exclude checks
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,
- Exclude checks
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());
- Exclude checks
Expression may not be PHP 7 compatible Open
if (!$region || !isset($mixin->$list[$region])) {
- Exclude checks
Argument 2 (str)
is array<int></int>
but \explode()
takes string
Open
$holiday = explode(" $variable ", $holiday, 2);
- Exclude checks
Expression may not be PHP 7 compatible Open
if (!isset($this->$list[$region])) {
- Exclude checks
Rename "$outputClass" which has the same name as the field declared at line 24. Open
$outputClass = $this->outputClass;
- Read upRead up
- Exclude checks
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
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
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);
- Exclude checks
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);
- Exclude checks
Rename "$workdayGetter" which has the same name as the field declared at line 34. Open
$workdayGetter = MixinConfigPropagator::getExtraWorkdayGetter($mixin, $self);
- Read upRead up
- Exclude checks
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
- CERT, DCL51-J. - Do not shadow or obscure identifiers in subscopes
Refactor this function to reduce its Cognitive Complexity from 18 to the 15 allowed. Open
public function setHolidaysRegion()
- Read upRead up
- Exclude checks
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);
- Exclude checks
Expression may not be PHP 7 compatible Open
: ($mixin->$list[$region][] = $day);
- Exclude checks
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());
- Exclude checks
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));
- Exclude checks
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()) {
- Exclude checks
Possibly zero references to use statement for classlike/namespace BusinessDay
(\Cmixin\BusinessDay)
Open
use Cmixin\BusinessDay;
- Exclude checks
Define a constant instead of duplicating this literal "holidays" 4 times. Open
if (!in_array($list, ['holidays', 'workdays'])) {
- Read upRead up
- Exclude checks
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.