Skip to content

Commit

Permalink
feat: Update to PHPStan 2.x
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
odinns committed Nov 29, 2024
1 parent 520259d commit 87bfaaa
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install composer dependencies
uses: ramsey/composer-install@v2
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
env:
PREVENT_OUTPUT: true
strategy:
fail-fast: true
fail-fast: false
matrix:
os: [ubuntu-latest]
php: [8.2, 8.3]
php: [8.3]
laravel: [10.*, 11.*]
stability: [prefer-lowest, prefer-stable]
include:
Expand All @@ -35,6 +35,8 @@ jobs:
with:
php-version: ${{ matrix.php }}
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup problem matchers
run: |
Expand Down
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"php": "^8.2",
"illuminate/contracts": "^10.0 || ^11.0",
"illuminate/http": "^10.0 || ^11.0",
"phpstan/phpstan": "^1.10.57",
"larastan/larastan": "^3.0",
"phpstan/phpstan": "^2.0",
"worksome/coding-style": "dev-feature/phpstan-2.x",
"worksome/request-factories": "^3.2"
},
"require-dev": {
"nunomaduro/collision": "^7.10 || ^8.1",
"larastan/larastan": "^2.6",
"orchestra/testbench": "^8.5.8 || ^9.0",
"pestphp/pest": "^2.33",
"worksome/coding-style": "^2.8"
"pestphp/pest": "^2.33"
},
"autoload": {
"psr-4": {
Expand All @@ -52,6 +52,12 @@
"@test:unit"
]
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/odinns/larastan-strict-rules"
}
],
"config": {
"sort-packages": true,
"allow-plugins": {
Expand Down
7 changes: 5 additions & 2 deletions src/RequireRequestFactoryRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public function getNodeType(): string

/**
* @param Class_ $node
*/
*
* @return array<int, \PHPStan\Rules\RuleError>
*/
public function processNode(Node $node, Scope $scope): array
{
if ($node->namespacedName === null) {
Expand All @@ -57,6 +59,7 @@ public function processNode(Node $node, Scope $scope): array
return $this->checkForCorrespondingFactory($className);
}

/** @return array<int, \PHPStan\Rules\RuleError> */
public function checkForCorrespondingFactory(string $className): array
{
$subName = Str::after($className, "{$this->requestsNamespace}\\");
Expand All @@ -69,7 +72,7 @@ public function checkForCorrespondingFactory(string $className): array
return [
RuleErrorBuilder::message(
"Request \"{$className}\" does not have a corresponding Request Factory at \"{$factoryName}\"."
)->build()
)->build(),
];
}
}

0 comments on commit 87bfaaa

Please sign in to comment.