diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index f221f07b..ee05762f 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -55,7 +55,10 @@ jobs: spaze/phpstan-disallowed-calls - if: matrix.php-version == '8.0' - run: composer remove --dev --no-update rector/rector + run: > + composer remove --dev --no-update + rector/rector + spaze/phpstan-disallowed-calls - if: matrix.php-version == '7.4' || matrix.php-version == '8.0' run: rm -rf src/Enum tests/Enum src/FluidXPlate/Scalars src/Microplate/Scalars tests/FluidXPlate/Scalars tests/Microplate/Scalars @@ -102,7 +105,10 @@ jobs: spaze/phpstan-disallowed-calls - if: matrix.php-version == '8.0' - run: composer remove --dev --no-update rector/rector + run: > + composer remove --dev --no-update + rector/rector + spaze/phpstan-disallowed-calls - if: matrix.php-version == '7.4' || matrix.php-version == '8.0' run: rm -rf src/Enum tests/Enum src/FluidXPlate/Scalars src/Microplate/Scalars tests/FluidXPlate/Scalars tests/Microplate/Scalars diff --git a/composer.json b/composer.json index 9f3cb7cb..aa6cfec6 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "phpstan/phpstan-strict-rules": "^1 || ^2.0.3", "phpunit/phpunit": "^9.6.22 || ^10.5.45 || ^11.5.10 || ^12.0.5", "rector/rector": "^1.2.10 || ^2.0.9", - "spaze/phpstan-disallowed-calls": "^2 || ^4.4", + "spaze/phpstan-disallowed-calls": "^4.4", "thecodingmachine/phpstan-safe-rule": "^1.2.0" }, "suggest": { diff --git a/phpstan/include-by-php-version.php b/phpstan/include-by-php-version.php index 6038baf5..c4cddb98 100644 --- a/phpstan/include-by-php-version.php +++ b/phpstan/include-by-php-version.php @@ -2,9 +2,7 @@ $includes = []; -// PHP 8.0+ can use rules.neon (requires spaze/phpstan-disallowed-calls) -// PHP 7.4 has this package removed via composer, so skip rules.neon -if (version_compare(PHP_VERSION, '8.0', '>=')) { +if (class_exists(\Spaze\PHPStan\Rules\Disallowed\DisallowedHelper::class)) { $includes[] = __DIR__ . '/../rules.neon'; } diff --git a/rules.neon b/rules.neon index f354ac38..51c95af6 100644 --- a/rules.neon +++ b/rules.neon @@ -14,6 +14,10 @@ parameters: - function: 'clock()' message: 'it is just meant for debugging.' errorTip: 'remove debugging code.' + disallowedClasses: + - class: 'Carbon\CarbonImmutable' + message: 'mixing mutable and immutable Carbon semantics makes code hard to reason about.' + errorTip: 'use Carbon\Carbon instead. See https://gitlab.mll/documentation/coding-guidelines/-/issues/313' disallowedStaticCalls: - method: 'Carbon\Carbon::create()' message: 'it ignores errors.'