Skip to content

Commit 227c45d

Browse files
committed
:octocat: phpstan is for masochists
1 parent a8d1a46 commit 227c45d

File tree

6 files changed

+133
-5
lines changed

6 files changed

+133
-5
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- "8.2"
3030
- "8.3"
3131
- "8.4"
32-
- "8.5"
32+
# - "8.5"
3333

3434
env:
3535
PHAN_ALLOW_XDEBUG: 0
@@ -43,7 +43,7 @@ jobs:
4343
uses: shivammathur/setup-php@v2
4444
with:
4545
php-version: ${{ matrix.php-version }}
46-
extensions: ${{ env.PHP_EXTENSIONS }}
46+
extensions: ast, ${{ env.PHP_EXTENSIONS }}
4747
ini-values: ${{ env.PHP_INI_VALUES }}
4848
coverage: none
4949

@@ -56,6 +56,9 @@ jobs:
5656
- name: "Run PHP_CodeSniffer"
5757
run: php vendor/bin/phpcs -v
5858

59+
- name: "Run phan"
60+
run: php vendor/bin/phan --target-php-version=${{ matrix.php-version }}
61+
5962
- name: "Run PHPStan"
6063
run: php vendor/bin/phpstan
6164

.phan/config.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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.2',
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+
'tests',
51+
'vendor',
52+
],
53+
];

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@
3939
"ext-curl": "*",
4040
"ext-json": "*",
4141
"ext-sodium": "*",
42+
"phan/phan": "^5.5.2",
4243
"phpmd/phpmd": "^2.15",
43-
"phpstan/phpstan": "^2.1.27",
44+
"phpstan/phpstan": "^2.1.31",
4445
"phpstan/phpstan-deprecation-rules": "^2.0.3",
4546
"phpunit/phpunit": "^11.2",
46-
"slevomat/coding-standard": "^8.23",
47+
"slevomat/coding-standard": "^8.24",
4748
"squizlabs/php_codesniffer": "^4.0"
4849
},
4950
"suggest": {
@@ -60,6 +61,7 @@
6061
}
6162
},
6263
"scripts": {
64+
"phan": "@php vendor/bin/phan",
6365
"phpcs": "@php vendor/bin/phpcs",
6466
"phpunit": "@php vendor/bin/phpunit",
6567
"phpstan": "@php vendor/bin/phpstan",

examples/hotp.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* @author Smiley <smiley@chillerlan.net>
77
* @copyright 2017 Smiley
88
* @license MIT
9+
*
10+
* @phan-file-suppress PhanDeprecatedFunction
911
*/
1012
declare(strict_types=1);
1113

examples/totp.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* @author Smiley <smiley@chillerlan.net>
77
* @copyright 2017 Smiley
88
* @license MIT
9+
*
10+
* @phan-file-suppress PhanDeprecatedFunction
911
*/
1012
declare(strict_types=1);
1113

phpstan-baseline.neon

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,42 @@ parameters:
2020
count: 2
2121
path: examples/totp.php
2222

23+
-
24+
rawMessage: 'Method chillerlan\Authenticator\Authenticator::__construct() has parameter $options with no value type specified in iterable type iterable.'
25+
identifier: missingType.iterableValue
26+
count: 1
27+
path: src/Authenticator.php
28+
29+
-
30+
rawMessage: 'Method chillerlan\Authenticator\Authenticator::setOptions() has parameter $options with no value type specified in iterable type iterable.'
31+
identifier: missingType.iterableValue
32+
count: 1
33+
path: src/Authenticator.php
34+
35+
-
36+
rawMessage: 'Parameter #1 $properties of class chillerlan\Authenticator\AuthenticatorOptions constructor expects array<string, mixed>|null, iterable given.'
37+
identifier: argument.type
38+
count: 1
39+
path: src/Authenticator.php
40+
41+
-
42+
rawMessage: 'Method chillerlan\Authenticator\Authenticators\AuthenticatorAbstract::__construct() has parameter $options with no value type specified in iterable type iterable.'
43+
identifier: missingType.iterableValue
44+
count: 1
45+
path: src/Authenticators/AuthenticatorAbstract.php
46+
47+
-
48+
rawMessage: 'Method chillerlan\Authenticator\Authenticators\AuthenticatorAbstract::setOptions() has parameter $options with no value type specified in iterable type iterable.'
49+
identifier: missingType.iterableValue
50+
count: 1
51+
path: src/Authenticators/AuthenticatorAbstract.php
52+
53+
-
54+
rawMessage: 'Parameter #1 $properties of class chillerlan\Authenticator\AuthenticatorOptions constructor expects array<string, mixed>|null, iterable given.'
55+
identifier: argument.type
56+
count: 1
57+
path: src/Authenticators/AuthenticatorAbstract.php
58+
2359
-
2460
rawMessage: Cannot access offset 'server_time' on mixed.
2561
identifier: offsetAccess.nonOffsetAccessible
@@ -51,17 +87,47 @@ parameters:
5187
in the next major version (6.x)
5288
'''
5389
identifier: method.deprecated
54-
count: 7
90+
count: 1
5591
path: tests/AuthenticatorTest.php
5692

93+
-
94+
rawMessage: 'Method chillerlan\AuthenticatorTest\Authenticators\AuthenticatorInterfaceTestAbstract::uriSettingsProvider() return type has no value type specified in iterable type array.'
95+
identifier: missingType.iterableValue
96+
count: 1
97+
path: tests/Authenticators/AuthenticatorInterfaceTestAbstract.php
98+
99+
-
100+
rawMessage: 'Parameter #1 $options of method chillerlan\Authenticator\Authenticators\AuthenticatorInterface::setOptions() expects chillerlan\Settings\SettingsContainerInterface, array<string, mixed> given.'
101+
identifier: argument.type
102+
count: 1
103+
path: tests/Authenticators/AuthenticatorInterfaceTestAbstract.php
104+
105+
-
106+
rawMessage: 'Method chillerlan\AuthenticatorTest\Authenticators\HOTPTest::uriSettingsProvider() return type has no value type specified in iterable type array.'
107+
identifier: missingType.iterableValue
108+
count: 1
109+
path: tests/Authenticators/HOTPTest.php
110+
57111
-
58112
rawMessage: 'Call to function is_int() with 59|1111111109|1111111111|1234567890|2000000000|20000000000 will always evaluate to true.'
59113
identifier: function.alreadyNarrowedType
60114
count: 1
61115
path: tests/Authenticators/SteamGuardTest.php
62116

117+
-
118+
rawMessage: 'Method chillerlan\AuthenticatorTest\Authenticators\SteamGuardTest::uriSettingsProvider() return type has no value type specified in iterable type array.'
119+
identifier: missingType.iterableValue
120+
count: 1
121+
path: tests/Authenticators/SteamGuardTest.php
122+
63123
-
64124
rawMessage: 'Call to function is_int() with 59|1111111109|1111111111|1234567890|2000000000|20000000000 will always evaluate to true.'
65125
identifier: function.alreadyNarrowedType
66126
count: 1
67127
path: tests/Authenticators/TOTPTest.php
128+
129+
-
130+
rawMessage: 'Method chillerlan\AuthenticatorTest\Authenticators\TOTPTest::uriSettingsProvider() return type has no value type specified in iterable type array.'
131+
identifier: missingType.iterableValue
132+
count: 1
133+
path: tests/Authenticators/TOTPTest.php

0 commit comments

Comments
 (0)