Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update PHPStan to 1.11 #59

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"composer-plugin-api": "^2.0",
"canvural/larastan-strict-rules": "^2.1.10",
"jetbrains/phpstorm-attributes": "^1.0",
"larastan/larastan": "^2.8.1",
"phpstan/phpstan": "^1.10.57",
"larastan/larastan": "^2.9.7",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-mockery": "^1.1.2",
"rector/rector": "^1.0",
"slevomat/coding-standard": "^8.14.1",
Expand Down
5 changes: 4 additions & 1 deletion larastan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ includes:
- ../../larastan/larastan/extension.neon

parameters:
checkMissingIterableValueType: false
namespaceAndSuffix:
App\Events: Event
App\Listener: Listener
App\Policies: Policy
App\Jobs: Job
ignoreErrors:
-
identifier: missingType.iterableValue
reportUnmatched: false
owenvoke marked this conversation as resolved.
Show resolved Hide resolved
rules:
- Worksome\CodingStyle\PHPStan\Laravel\DisallowPartialRouteResource\DisallowPartialRouteFacadeResourceRule
- Worksome\CodingStyle\PHPStan\Laravel\DisallowPartialRouteResource\DisallowPartialRouteVariableResourceRule
Expand Down
5 changes: 4 additions & 1 deletion src/PHPStan/DeclareStrictTypesRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPStan\Analyser\Scope;
use PHPStan\Node\FileNode;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;

/**
* @implements Rule<FileNode>
Expand Down Expand Up @@ -43,7 +44,9 @@ public function processNode(Node $node, Scope $scope): array
}

return [
'PHP files should declare strict types.',
RuleErrorBuilder::message('PHP files should declare strict types.')
->identifier('worksome.declareStrictTypes')
->build(),
];
}
}
6 changes: 4 additions & 2 deletions src/PHPStan/DisallowPHPUnitRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public function processNode(Node $node, Scope $scope): array

return [
RuleErrorBuilder::message(
"PHPUnit tests are not allowed. Please use Pest PHP instead. If this is a TestCase, make it abstract to pass validation."
)->build()
'PHPUnit tests are not allowed. Please use Pest PHP instead. If this is a TestCase, make it abstract to pass validation.'
)
->identifier('worksome.disallowPhpunit')
->build()
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ private function checkFacade(Node\Name|Node\Expr $var): array

private function error(): RuleError
{
return RuleErrorBuilder
::message('Environment checks are disallowed. Please use the driver pattern instead.')
return RuleErrorBuilder::message('Environment checks are disallowed. Please use the driver pattern instead.')
->identifier('worksome.laravel.disallowEnvironmentCheck')
->build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PhpParser\Node\Expr\MethodCall;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleError;
use Worksome\CodingStyle\Enums\AttributeKey;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ private function errorFor(string $method): RuleError
{
return RuleErrorBuilder::message(
"Usage of [{$method}] method on route resource is disallowed. Please split the resource into multiple routes."
)->build();
)
->identifier('worksome.laravel.disallowPartialRouteResource')
->build();
}
}
5 changes: 4 additions & 1 deletion src/PHPStan/Laravel/EnforceKebabCaseArtisanCommandsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ public function getCommandNameErrors(string $segment, string $className, Propert
if (! preg_match('/^[a-z0-9\-:]+$/', $segment)) {
$errors[] = RuleErrorBuilder::message(
"Command \"{$className}\" is not using kebab-case for the command name in its signature."
)->line($signature->getLine())->build();
)
->line($signature->getLine())
->identifier('worksome.laravel.kebabCaseArtisanCommands')
->build();
}

return $errors;
Expand Down
4 changes: 3 additions & 1 deletion src/PHPStan/NamespaceBasedSuffixRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public function processNode(Node $node, Scope $scope): array
return [
RuleErrorBuilder::message(
"Classes in namespace $nameSpace should always be suffixed with $suffix."
)->build(),
)
->identifier('worksome.namespaceBasedSuffix')
->build(),
];
}

Expand Down
Loading