Skip to content

Commit 21838f4

Browse files
committed
:octocat: phpstan ignore by php version
1 parent 36c7a35 commit 21838f4

File tree

5 files changed

+119
-18
lines changed

5 files changed

+119
-18
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ jobs:
5858
- name: "Run phan"
5959
run: php vendor/bin/phan --target-php-version=${{ matrix.php-version }}
6060

61-
# - name: "Run PHPStan"
62-
# run: php vendor/bin/phpstan
61+
- name: "Run PHPStan"
62+
run: php vendor/bin/phpstan
6363

6464

6565
build-docs:

.phpstan/baseline-lt-8.4.neon

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
parameters:
2+
excludePaths:
3+
- ../tests/PropertyHooksContainer.php
4+
5+
ignoreErrors:
6+
-
7+
rawMessage: Access to constant Get on an unknown class PropertyHookType.
8+
identifier: class.notFound
9+
count: 1
10+
path: ../src/SettingsContainerAbstract.php
11+
12+
-
13+
rawMessage: Access to constant Set on an unknown class PropertyHookType.
14+
identifier: class.notFound
15+
count: 1
16+
path: ../src/SettingsContainerAbstract.php
17+
18+
-
19+
rawMessage: 'Call to an undefined method ReflectionProperty::getRawValue().'
20+
identifier: method.notFound
21+
count: 2
22+
path: ../src/SettingsContainerAbstract.php
23+
24+
-
25+
rawMessage: 'Call to an undefined method ReflectionProperty::hasHook().'
26+
identifier: method.notFound
27+
count: 2
28+
path: ../src/SettingsContainerAbstract.php
29+
30+
-
31+
rawMessage: 'Call to an undefined method ReflectionProperty::setRawValue().'
32+
identifier: method.notFound
33+
count: 1
34+
path: ../src/SettingsContainerAbstract.php

.phpstan/ignore-by-php-version.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
// see: https://github.com/phpstan/phpstan/issues/7843
3+
4+
declare(strict_types = 1);
5+
6+
$includes = [];
7+
8+
if(PHP_VERSION_ID < 80400){
9+
$includes[] = __DIR__.'/baseline-lt-8.4.neon';
10+
}
11+
12+
$config = [];
13+
$config['includes'] = $includes;
14+
$config['parameters']['phpVersion'] = PHP_VERSION_ID;
15+
16+
return $config;
17+
18+

phpstan-baseline.neon

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,79 @@
11
parameters:
22
ignoreErrors:
33
-
4-
rawMessage: Access to constant Get on an unknown class PropertyHookType.
5-
identifier: class.notFound
4+
rawMessage: Access to an undefined property chillerlan\SettingsTest\TestContainer::$foo.
5+
identifier: property.notFound
66
count: 1
7-
path: src/SettingsContainerAbstract.php
7+
path: tests/ContainerTest.php
88

99
-
10-
rawMessage: Access to constant Set on an unknown class PropertyHookType.
11-
identifier: class.notFound
10+
rawMessage: Access to private property chillerlan\SettingsTest\TestContainer::$test3.
11+
identifier: property.private
12+
count: 6
13+
path: tests/ContainerTest.php
14+
15+
-
16+
rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertFalse() with true will always evaluate to false.'
17+
identifier: staticMethod.impossibleType
1218
count: 1
13-
path: src/SettingsContainerAbstract.php
19+
path: tests/ContainerTest.php
1420

1521
-
16-
rawMessage: 'Call to an undefined method ReflectionProperty::getRawValue().'
17-
identifier: method.notFound
18-
count: 2
19-
path: src/SettingsContainerAbstract.php
22+
rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertFalse() with true will always evaluate to true.'
23+
identifier: staticMethod.alreadyNarrowedType
24+
count: 1
25+
path: tests/ContainerTest.php
26+
27+
-
28+
rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertNull() with string will always evaluate to false.'
29+
identifier: staticMethod.impossibleType
30+
count: 3
31+
path: tests/ContainerTest.php
2032

2133
-
22-
rawMessage: 'Call to an undefined method ReflectionProperty::hasHook().'
23-
identifier: method.notFound
34+
rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertTrue() with true will always evaluate to true.'
35+
identifier: staticMethod.alreadyNarrowedType
36+
count: 1
37+
path: tests/ContainerTest.php
38+
39+
-
40+
rawMessage: 'Property chillerlan\SettingsTest\TestContainer::$test1 (string) in isset() is not nullable.'
41+
identifier: isset.property
2442
count: 2
25-
path: src/SettingsContainerAbstract.php
43+
path: tests/ContainerTest.php
44+
45+
-
46+
rawMessage: 'Property chillerlan\SettingsTest\TestContainer::$test3 (string) in isset() is not nullable.'
47+
identifier: isset.property
48+
count: 1
49+
path: tests/ContainerTest.php
50+
51+
-
52+
rawMessage: Access to protected property chillerlan\SettingsTest\PropertyHooksContainer::$test1.
53+
identifier: property.protected
54+
count: 4
55+
path: tests/PropertyHooksTest.php
56+
57+
-
58+
rawMessage: Access to protected property chillerlan\SettingsTest\PropertyHooksContainer::$test2.
59+
identifier: property.protected
60+
count: 4
61+
path: tests/PropertyHooksTest.php
62+
63+
-
64+
rawMessage: Access to protected property chillerlan\SettingsTest\PropertyHooksContainer::$test3.
65+
identifier: property.protected
66+
count: 5
67+
path: tests/PropertyHooksTest.php
68+
69+
-
70+
rawMessage: Access to protected property chillerlan\SettingsTest\PropertyHooksContainer::$test4.
71+
identifier: property.protected
72+
count: 5
73+
path: tests/PropertyHooksTest.php
2674

2775
-
28-
rawMessage: 'Call to an undefined method ReflectionProperty::setRawValue().'
29-
identifier: method.notFound
76+
rawMessage: 'Property chillerlan\SettingsTest\TestContainer::$test3 is never read, only written.'
77+
identifier: property.onlyWritten
3078
count: 1
31-
path: src/SettingsContainerAbstract.php
79+
path: tests/TestContainer.php

phpstan.dist.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ parameters:
1111
treatPhpDocTypesAsCertain: false
1212

1313
includes:
14+
- .phpstan/ignore-by-php-version.php
1415
- phpstan-baseline.neon
1516
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
1617
- vendor/phpstan/phpstan-deprecation-rules/rules.neon

0 commit comments

Comments
 (0)