Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Feb 16, 2024
1 parent 14c45e5 commit 5b6a902
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 53 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: PHPStan

on:
push:
paths:
- '**.php'
- 'phpstan.neon.dist'
pull_request:
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
33 changes: 0 additions & 33 deletions .github/workflows/psalm.yml

This file was deleted.

10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
],
"require": {
"php": "^8.0",
"nikic/php-parser": "^4.13",
"nikic/php-parser": "^4.13|^5.0",
"phpdocumentor/type-resolver": "^1.6.2",
"symfony/process": "^5.2|^6.0|^7.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.40",
"phpstan/extension-installer": "^1.1",
"larapack/dd": "^1.1",
"myclabs/php-enum": "^1.7",
"pestphp/pest": "^1.22",
"phpunit/phpunit": "^9.0",
"spatie/data-transfer-object": "^2.0",
"spatie/enum": "^3.0",
"spatie/pest-plugin-snapshots": "^1.1",
"spatie/temporary-directory": "^1.2|^2.0",
"vimeo/psalm": "^4.2"
"spatie/temporary-directory": "^1.2|^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -44,6 +44,7 @@
}
},
"scripts": {
"analyse" : "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"psalm": "./vendor/bin/psalm -c psalm.xml",
Expand All @@ -52,7 +53,8 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
"pestphp/pest-plugin": true,
"phpstan/extension-installer": false
}
},
"minimum-stability": "dev",
Expand Down
46 changes: 46 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(PhpParser\\\\Node\\)\\: mixed\\)\\|null, Closure\\(PhpParser\\\\Node\\\\Stmt\\\\Class_\\|PhpParser\\\\Node\\\\Stmt\\\\Enum_\\|PhpParser\\\\Node\\\\Stmt\\\\Interface_\\|PhpParser\\\\Node\\\\Stmt\\\\Trait_\\)\\: \\(string\\|null\\) given\\.$#"
count: 1
path: src/Actions/ResolveClassesInPhpFileAction.php

-
message: "#^Instanceof between phpDocumentor\\\\Reflection\\\\Type and phpDocumentor\\\\Reflection\\\\Types\\\\ClassString will always evaluate to false\\.$#"
count: 1
path: src/Actions/TranspileTypeToTypeScriptAction.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: src/Attributes/TypeScriptType.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: src/Attributes/TypeScriptType.php

-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(ReflectionEnumUnitCase\\)\\: mixed\\)\\|null, Closure\\(ReflectionEnumBackedCase\\)\\: non\\-falsy\\-string given\\.$#"
count: 1
path: src/Transformers/EnumTransformer.php

-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(ReflectionEnumUnitCase\\)\\: mixed\\)\\|null, Closure\\(ReflectionEnumBackedCase\\)\\: string given\\.$#"
count: 1
path: src/Transformers/EnumTransformer.php

-
message: "#^Method Spatie\\\\TypeScriptTransformer\\\\TypeReflectors\\\\TypeReflector\\:\\:new\\(\\) should return static\\(Spatie\\\\TypeScriptTransformer\\\\TypeReflectors\\\\TypeReflector\\) but returns Spatie\\\\TypeScriptTransformer\\\\TypeReflectors\\\\MethodParameterTypeReflector\\.$#"
count: 1
path: src/TypeReflectors/TypeReflector.php

-
message: "#^Method Spatie\\\\TypeScriptTransformer\\\\TypeReflectors\\\\TypeReflector\\:\\:new\\(\\) should return static\\(Spatie\\\\TypeScriptTransformer\\\\TypeReflectors\\\\TypeReflector\\) but returns Spatie\\\\TypeScriptTransformer\\\\TypeReflectors\\\\MethodReturnTypeReflector\\.$#"
count: 1
path: src/TypeReflectors/TypeReflector.php

-
message: "#^Method Spatie\\\\TypeScriptTransformer\\\\TypeReflectors\\\\TypeReflector\\:\\:new\\(\\) should return static\\(Spatie\\\\TypeScriptTransformer\\\\TypeReflectors\\\\TypeReflector\\) but returns Spatie\\\\TypeScriptTransformer\\\\TypeReflectors\\\\PropertyTypeReflector\\.$#"
count: 1
path: src/TypeReflectors/TypeReflector.php
7 changes: 7 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
level: 5
paths:
- src
tmpDir: build/phpstan
reportUnmatchedIgnoredErrors: true
checkMissingIterableValueType: true
15 changes: 0 additions & 15 deletions psalm.xml

This file was deleted.

2 changes: 1 addition & 1 deletion src/Actions/ResolveClassesInPhpFileAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ResolveClassesInPhpFileAction

public function __construct()
{
$this->parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
$this->parser = (new ParserFactory())->createForHostVersion();
}

public function execute(SplFileInfo $file): array
Expand Down

0 comments on commit 5b6a902

Please sign in to comment.