-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v6] Add additional types & Phpstan (#910)
* init phpstan and larastan * Fix: Unsafe access to private property ... through static:: * fixes and baseline * add phpstan action * init rector * apply code changes by rector * undo Filter contract changes * fixed a bunch of phpstan issues * Fix styling * fix typo --------- Co-authored-by: Nielsvanpach <[email protected]> Co-authored-by: Alex Vanderbist <[email protected]>
- Loading branch information
1 parent
47d9561
commit 880e2b1
Showing
30 changed files
with
226 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: PHPStan | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.php' | ||
- 'phpstan.neon.dist' | ||
|
||
jobs: | ||
phpstan: | ||
name: phpstan | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.2' | ||
coverage: none | ||
|
||
- name: Install composer dependencies | ||
uses: ramsey/composer-install@v2 | ||
|
||
- name: Run PHPStan | ||
run: ./vendor/bin/phpstan --error-format=github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
parameters: | ||
ignoreErrors: | ||
- | ||
message: "#^Parameter \\#1 \\$keys of method Illuminate\\\\Support\\\\Collection\\<int,string\\>\\:\\:except\\(\\) expects array\\<int\\>\\|Illuminate\\\\Support\\\\Enumerable\\<\\(int\\|string\\), int\\>\\|string, int\\<\\-1, max\\> given\\.$#" | ||
count: 1 | ||
path: src/Filters/FiltersExact.php | ||
|
||
- | ||
message: "#^Call to an undefined method ReflectionType\\:\\:getName\\(\\)\\.$#" | ||
count: 2 | ||
path: src/Filters/FiltersScope.php | ||
|
||
- | ||
message: "#^Call to an undefined method ReflectionType\\:\\:isBuiltin\\(\\)\\.$#" | ||
count: 1 | ||
path: src/Filters/FiltersScope.php | ||
|
||
- | ||
message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Builder\\<TModelClass of Illuminate\\\\Database\\\\Eloquent\\\\Model\\>\\:\\:onlyTrashed\\(\\)\\.$#" | ||
count: 1 | ||
path: src/Filters/FiltersTrashed.php | ||
|
||
- | ||
message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Builder\\<TModelClass of Illuminate\\\\Database\\\\Eloquent\\\\Model\\>\\:\\:withTrashed\\(\\)\\.$#" | ||
count: 1 | ||
path: src/Filters/FiltersTrashed.php | ||
|
||
- | ||
message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Builder\\<TModelClass of Illuminate\\\\Database\\\\Eloquent\\\\Model\\>\\:\\:withoutTrashed\\(\\)\\.$#" | ||
count: 1 | ||
path: src/Filters/FiltersTrashed.php | ||
|
||
- | ||
message: "#^PHPDoc tag @return with type Spatie\\\\QueryBuilder\\\\QueryBuilder is not subtype of native type static\\(Spatie\\\\QueryBuilder\\\\QueryBuilder\\)\\.$#" | ||
count: 2 | ||
path: src/QueryBuilder.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
includes: | ||
- ./vendor/nunomaduro/larastan/extension.neon | ||
- phpstan-baseline.neon | ||
|
||
parameters: | ||
|
||
paths: | ||
- src/ | ||
- config/ | ||
- database/ | ||
|
||
# Level 9 is the highest level | ||
level: 5 | ||
|
||
checkModelProperties: true | ||
checkOctaneCompatibility: true | ||
checkMissingIterableValueType: false | ||
reportUnmatchedIgnoredErrors: false | ||
noUnnecessaryCollectionCall: true | ||
checkNullables: true | ||
checkGenericClassInNonGenericObjectType: false | ||
treatPhpDocTypesAsCertain: false | ||
|
||
ignoreErrors: | ||
- '#Unsafe usage of new static#' | ||
- '#PHPDoc tag @var#' | ||
|
||
# excludePaths: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; | ||
use Rector\Config\RectorConfig; | ||
use Rector\Php74\Rector\Assign\NullCoalescingOperatorRector; | ||
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; | ||
use Rector\Set\ValueObject\LevelSetList; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->paths([ | ||
__DIR__ . '/config', | ||
__DIR__ . '/src', | ||
__DIR__ . '/tests', | ||
]); | ||
|
||
// register a single rule | ||
//$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); | ||
|
||
// define sets of rules | ||
$rectorConfig->sets([ | ||
LevelSetList::UP_TO_PHP_80 | ||
]); | ||
|
||
$rectorConfig->skip([ | ||
ClosureToArrowFunctionRector::class, | ||
NullCoalescingOperatorRector::class, | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.