File tree Expand file tree Collapse file tree 6 files changed +68
-0
lines changed Expand file tree Collapse file tree 6 files changed +68
-0
lines changed Original file line number Diff line number Diff line change 44/.github / export-ignore
55/CONTRIBUTING.md export-ignore
66/fixtures / export-ignore
7+ /phpstan-fixtures / export-ignore
8+ /phpstan.dist.neon export-ignore
79/phpunit.xml.dist export-ignore
810/tests / export-ignore
Original file line number Diff line number Diff line change 6464
6565 - name : Execute Unit Tests
6666 run : vendor/bin/phpunit
67+
68+ phpstan :
69+ runs-on : ubuntu-latest
70+ name : Static analysis
71+ steps :
72+ - uses : actions/checkout@v4
73+ - name : Set up PHP
74+ uses : shivammathur/setup-php@v2
75+ with :
76+ php-version : " 8.2"
77+ ini-file : development
78+ coverage : none
79+ - name : Install dependencies
80+ run : composer update --ansi --no-interaction --no-progress
81+ - run : ./vendor/bin/phpstan
Original file line number Diff line number Diff line change 2424 "autoload-dev" : {
2525 "psr-4" : {
2626 "Prophecy\\ PhpUnit\\ Tests\\ Fixtures\\ " : " fixtures" ,
27+ "Prophecy\\ PhpUnit\\ Tests\\ PhpstanFixtures\\ " : " phpstan-fixtures" ,
2728 "Prophecy\\ PhpUnit\\ Tests\\ " : " tests"
2829 }
2930 },
3031 "extra" : {
3132 "branch-alias" : {
3233 "dev-master" : " 2.x-dev"
3334 }
35+ },
36+ "require-dev" : {
37+ "phpstan/phpstan" : " ^1.10"
3438 }
3539}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Prophecy \PhpUnit \Tests \PhpstanFixtures ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use Prophecy \PhpUnit \ProphecyTrait ;
7+ use Prophecy \Prophecy \ObjectProphecy ;
8+
9+ class ExampleUsage extends TestCase
10+ {
11+ use ProphecyTrait;
12+
13+ public function testExplicitClass (): void
14+ {
15+ $ prophecy = $ this ->prophesize (\DateTimeImmutable::class);
16+
17+ $ this ->configureDouble ($ prophecy );
18+
19+ $ double = $ prophecy ->reveal ();
20+
21+ $ this ->checkValue ($ double ->format ('Y-m-d ' ));
22+ }
23+
24+ /**
25+ * @param ObjectProphecy<\DateTimeImmutable> $double
26+ */
27+ private function configureDouble (ObjectProphecy $ double ): void
28+ {
29+ }
30+
31+ private function checkValue (string $ value ): void
32+ {
33+ self ::assertNotEmpty ($ value );
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ parameters :
2+ level : 9
3+ treatPhpDocTypesAsCertain : false
4+ paths :
5+ - ./src/
6+ - ./phpstan-fixtures/
7+ ignoreErrors :
8+ # recordDoubledType exist only in PHPUnit < 10 but the code is checking that before using it.
9+ -
10+ message : ' #^Call to an undefined method Prophecy\\PhpUnit\\Tests\\PhpstanFixtures\\[^:]++\:\:recordDoubledType\(\)\.$#'
11+ path : src/ProphecyTrait.php
Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ protected function tearDownProphecy(): void
9898 private function countProphecyAssertions (): void
9999 {
100100 \assert ($ this instanceof TestCase);
101+ \assert ($ this ->prophet !== null );
101102 $ this ->prophecyAssertionsCounted = true ;
102103
103104 foreach ($ this ->prophet ->getProphecies () as $ objectProphecy ) {
You can’t perform that action at this time.
0 commit comments