Skip to content

Commit 2a9f087

Browse files
committed
:octocat: reintroduce phan because phpstan keeps making trouble
1 parent bf4cda6 commit 2a9f087

File tree

8 files changed

+78
-4
lines changed

8 files changed

+78
-4
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ jobs:
3131
name: "Static Code Analysis"
3232
runs-on: ubuntu-latest
3333

34+
env:
35+
PHAN_ALLOW_XDEBUG: 0
36+
PHAN_DISABLE_XDEBUG_WARN: 1
37+
3438
strategy:
3539
fail-fast: true
3640
matrix:
@@ -48,19 +52,22 @@ jobs:
4852
uses: shivammathur/setup-php@v2
4953
with:
5054
php-version: ${{ matrix.php-version }}
51-
extensions: ${{ env.PHP_EXTENSIONS }}
55+
extensions: ast, ${{ env.PHP_EXTENSIONS }}
5256
ini-values: ${{ env.PHP_INI_VALUES }}
5357
coverage: none
5458

5559
- name: "Install dependencies with composer"
5660
uses: ramsey/composer-install@v3
5761

58-
- name: "Run PHPStan"
59-
run: php vendor/bin/phpstan
60-
6162
- name: "Run PHP_CodeSniffer"
6263
run: php vendor/bin/phpcs
6364

65+
- name: "Run phan"
66+
run: php vendor/bin/phan --target-php-version=${{ matrix.php-version }}
67+
68+
- name: "Run PHPStan"
69+
run: php vendor/bin/phpstan
70+
6471

6572
tests:
6673
name: "Unit Tests"

.phan/config.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* This configuration will be read and overlaid on top of the
4+
* default configuration. Command-line arguments will be applied
5+
* after this file is read.
6+
*/
7+
return [
8+
// If this is set to `null`,
9+
// then Phan assumes the PHP version which is closest to the minor version
10+
// of the php executable used to execute Phan.
11+
//
12+
// Note that the **only** effect of choosing `'5.6'` is to infer
13+
// that functions removed in php 7.0 exist.
14+
// (See `backward_compatibility_checks` for additional options)
15+
'target_php_version' => null,
16+
'minimum_target_php_version' => '8.1',
17+
18+
// A list of directories that should be parsed for class and
19+
// method information. After excluding the directories
20+
// defined in exclude_analysis_directory_list, the remaining
21+
// files will be statically analyzed for errors.
22+
//
23+
// Thus, both first-party and third-party code being used by
24+
// your application should be included in this list.
25+
'directory_list' => [
26+
'examples',
27+
'src',
28+
'tests',
29+
'vendor',
30+
],
31+
32+
// A regex used to match every file name that you want to
33+
// exclude from parsing. Actual value will exclude every
34+
// "test", "tests", "Test" and "Tests" folders found in
35+
// "vendor/" directory.
36+
'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@',
37+
38+
// A directory list that defines files that will be excluded
39+
// from static analysis, but whose class and method
40+
// information should be included.
41+
//
42+
// Generally, you'll want to include the directories for
43+
// third-party code (such as "vendor/") in this list.
44+
//
45+
// n.b.: If you'd like to parse but not analyze 3rd
46+
// party code, directories containing that code
47+
// should be added to both the `directory_list`
48+
// and `exclude_analysis_directory_list` arrays.
49+
'exclude_analysis_directory_list' => [
50+
'vendor',
51+
],
52+
'suppress_issue_types' => [
53+
'PhanUndeclaredGlobalVariable', // happens in get-token examples
54+
],
55+
];

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"chillerlan/phpunit-http": "^1.0",
4848
"guzzlehttp/guzzle": "^7.9",
4949
"monolog/monolog": "^3.7",
50+
"phan/phan": "^5.5.0",
5051
"phpmd/phpmd": "^2.15",
5152
"phpstan/phpstan": "^2.1.18",
5253
"phpstan/phpstan-deprecation-rules": "^2.0.3",
@@ -68,6 +69,7 @@
6869
}
6970
},
7071
"scripts": {
72+
"phan": "@php vendor/bin/phan",
7173
"phpcs": "@php vendor/bin/phpcs",
7274
"phpstan": "@php vendor/bin/phpstan",
7375
"phpstan-baseline": "@php vendor/bin/phpstan --generate-baseline",

src/Core/ClientCredentialsTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* @author smiley <[email protected]>
77
* @copyright 2024 smiley
88
* @license MIT
9+
*
10+
* @phan-file-suppress PhanUndeclaredConstantOfClass, PhanUndeclaredProperty, PhanUndeclaredMethod
911
*/
1012
declare(strict_types=1);
1113

src/Core/PARTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* @author smiley <[email protected]>
77
* @copyright 2024 smiley
88
* @license MIT
9+
*
10+
* @phan-file-suppress PhanUndeclaredProperty, PhanUndeclaredMethod
911
*/
1012
declare(strict_types=1);
1113

src/Core/PKCETrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* @author smiley <[email protected]>
77
* @copyright 2024 smiley
88
* @license MIT
9+
*
10+
* @phan-file-suppress PhanUndeclaredProperty, PhanUndeclaredMethod
911
*/
1012
declare(strict_types=1);
1113

src/Core/TokenInvalidateTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* @author smiley <[email protected]>
77
* @copyright 2024 smiley
88
* @license MIT
9+
*
10+
* @phan-file-suppress PhanUndeclaredProperty, PhanUndeclaredMethod
911
*/
1012
declare(strict_types=1);
1113

@@ -42,6 +44,7 @@ public function invalidateAccessToken(AccessToken|null $token = null, string|nul
4244
}
4345

4446
$tokenToInvalidate = ($token ?? $this->storage->getAccessToken($this->name));
47+
/** @phan-suppress-next-line PhanTypeMismatchArgumentNullable */
4548
$body = $this->getInvalidateAccessTokenBodyParams($tokenToInvalidate, $type);
4649
$response = $this->sendTokenInvalidateRequest($this->revokeURL, $body);
4750

tests/Core/AccessTokenTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public static function expiryDataProvider():array{
7575

7676
#[DataProvider('expiryDataProvider')]
7777
public function testSetExpiry(DateTime|DateInterval|int|null $expires, int $expected):void{
78+
/** @phan-suppress-next-line PhanPossiblyNullTypeMismatchProperty */
7879
$this->token->expires = $expires;
7980

8081
// time tests are a bit wonky sometimes

0 commit comments

Comments
 (0)