From fb28c54a9d95af51547fee33ee2dd47010598681 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 13 Mar 2024 14:16:16 +0100 Subject: [PATCH 01/13] Add static analysis with phpstan --- .gitattributes | 2 ++ .github/workflows/ci.yml | 15 +++++++++++++ composer.json | 4 ++++ phpstan-fixtures/ExampleUsage.php | 35 +++++++++++++++++++++++++++++++ phpstan.dist.neon | 11 ++++++++++ src/ProphecyTrait.php | 1 + 6 files changed, 68 insertions(+) create mode 100644 phpstan-fixtures/ExampleUsage.php create mode 100644 phpstan.dist.neon diff --git a/.gitattributes b/.gitattributes index 9091cc7..3b7ebf0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,5 +4,7 @@ /.github/ export-ignore /CONTRIBUTING.md export-ignore /fixtures/ export-ignore +/phpstan-fixtures/ export-ignore +/phpstan.dist.neon export-ignore /phpunit.xml.dist export-ignore /tests/ export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed3020b..1182293 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,3 +64,18 @@ jobs: - name: Execute Unit Tests run: vendor/bin/phpunit + + phpstan: + runs-on: ubuntu-latest + name: Static analysis + steps: + - uses: actions/checkout@v4 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: "8.2" + ini-file: development + coverage: none + - name: Install dependencies + run: composer update --ansi --no-interaction --no-progress + - run: ./vendor/bin/phpstan diff --git a/composer.json b/composer.json index a27bf91..a8e0cbd 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "autoload-dev": { "psr-4": { "Prophecy\\PhpUnit\\Tests\\Fixtures\\": "fixtures", + "Prophecy\\PhpUnit\\Tests\\PhpstanFixtures\\": "phpstan-fixtures", "Prophecy\\PhpUnit\\Tests\\": "tests" } }, @@ -31,5 +32,8 @@ "branch-alias": { "dev-master": "2.x-dev" } + }, + "require-dev": { + "phpstan/phpstan": "^1.10" } } diff --git a/phpstan-fixtures/ExampleUsage.php b/phpstan-fixtures/ExampleUsage.php new file mode 100644 index 0000000..93c71a2 --- /dev/null +++ b/phpstan-fixtures/ExampleUsage.php @@ -0,0 +1,35 @@ +prophesize(\DateTimeImmutable::class); + + $this->configureDouble($prophecy); + + $double = $prophecy->reveal(); + + $this->checkValue($double->format('Y-m-d')); + } + + /** + * @param ObjectProphecy<\DateTimeImmutable> $double + */ + private function configureDouble(ObjectProphecy $double): void + { + } + + private function checkValue(string $value): void + { + self::assertNotEmpty($value); + } +} diff --git a/phpstan.dist.neon b/phpstan.dist.neon new file mode 100644 index 0000000..28633dc --- /dev/null +++ b/phpstan.dist.neon @@ -0,0 +1,11 @@ +parameters: + level: 9 + treatPhpDocTypesAsCertain: false + paths: + - ./src/ + - ./phpstan-fixtures/ + ignoreErrors: + # recordDoubledType exist only in PHPUnit < 10 but the code is checking that before using it. + - + message: '#^Call to an undefined method Prophecy\\PhpUnit\\Tests\\PhpstanFixtures\\[^:]++\:\:recordDoubledType\(\)\.$#' + path: src/ProphecyTrait.php diff --git a/src/ProphecyTrait.php b/src/ProphecyTrait.php index db1676f..31812cb 100644 --- a/src/ProphecyTrait.php +++ b/src/ProphecyTrait.php @@ -98,6 +98,7 @@ protected function tearDownProphecy(): void private function countProphecyAssertions(): void { \assert($this instanceof TestCase); + \assert($this->prophet !== null); $this->prophecyAssertionsCounted = true; foreach ($this->prophet->getProphecies() as $objectProphecy) { From 9fa6cf271faa51b22309442f4527d6c66f5121ee Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 19 Nov 2024 14:17:30 +0100 Subject: [PATCH 02/13] Add a CI job running on PHP 8.4 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1182293..5e8fce3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] min_stability: [''] name_suffix: [''] include: From 8819516c1b489ecee4c60db5f5432fac1ea8ac6f Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 19 Nov 2024 14:24:17 +0100 Subject: [PATCH 03/13] Update changelog --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 6fda5e5..269d07c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +# 2.3.0 + +* Add more precise type for the `prophesize` method + # 2.2.0 * Add support for PHPUnit 11 From d95a27c9ee8c0bd8fb5656f1fff7db10af3e97f1 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Fri, 7 Feb 2025 10:22:59 +0100 Subject: [PATCH 04/13] Allow PHPUnit 12 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a8e0cbd..d57b8c1 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "require": { "php": "^7.3 || ^8", "phpspec/prophecy": "^1.18", - "phpunit/phpunit":"^9.1 || ^10.1 || ^11.0" + "phpunit/phpunit":"^9.1 || ^10.1 || ^11.0 || ^12.0" }, "autoload": { "psr-4": { From 954024eb3c4facc98d3dee12571d0e683ed3b3b3 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Mon, 12 May 2025 14:47:52 +0200 Subject: [PATCH 05/13] Add changelog entry --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 269d07c..944e389 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,6 @@ +# 2.4.0 +* Add support for PHPUnit 12 + # 2.3.0 * Add more precise type for the `prophesize` method From 24555bdffed25345669c700c5d1b9ec01bc77a33 Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Fri, 6 Feb 2026 09:36:13 +0100 Subject: [PATCH 06/13] Allow PHPUnit 13 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d57b8c1..0a5a005 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "require": { "php": "^7.3 || ^8", "phpspec/prophecy": "^1.18", - "phpunit/phpunit":"^9.1 || ^10.1 || ^11.0 || ^12.0" + "phpunit/phpunit":"^9.1 || ^10.1 || ^11.0 || ^12.0 || ^13.0" }, "autoload": { "psr-4": { From 04039e91ee8fe03ff8517ff50080190738078022 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Mon, 9 Feb 2026 14:20:18 +0100 Subject: [PATCH 07/13] Add a CI job running PHP 8.5 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e8fce3..4743a7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,11 +34,11 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] min_stability: [''] name_suffix: [''] include: - - php: '8.3' + - php: '8.5' min_stability: 'dev' name_suffix: ' (dev deps)' From 89f91b01d0640b7820e427e02a007bc6489d8a26 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Mon, 9 Feb 2026 16:40:55 +0100 Subject: [PATCH 08/13] Update changelog --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 944e389..00f407f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +# 2.5.0 + +* Add support for PHPUnit 13 +* Add a CI job running on PHP 8.5 + # 2.4.0 * Add support for PHPUnit 12 From aaf870add23332d318dc634ff2a83b53928cc229 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 11 Feb 2026 15:35:38 +0100 Subject: [PATCH 09/13] Drop support for PHP 8.1 and older The min supported PHP version is now PHP 8.2, aligning with the PHP versions supported by Prophecy. --- .github/workflows/ci.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4743a7a..11cd633 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] + php: ['8.2', '8.3', '8.4', '8.5'] min_stability: [''] name_suffix: [''] include: diff --git a/composer.json b/composer.json index 0a5a005..17da9c3 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ } ], "require": { - "php": "^7.3 || ^8", + "php": "^8.2", "phpspec/prophecy": "^1.18", "phpunit/phpunit":"^9.1 || ^10.1 || ^11.0 || ^12.0 || ^13.0" }, From 34114bb62fbc94fdadac0c859fec042fcc60eebc Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 11 Feb 2026 13:56:28 +0100 Subject: [PATCH 10/13] Enforce package sorting in composer.json --- composer.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 17da9c3..1417a13 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,9 @@ "phpspec/prophecy": "^1.18", "phpunit/phpunit":"^9.1 || ^10.1 || ^11.0 || ^12.0 || ^13.0" }, + "require-dev": { + "phpstan/phpstan": "^1.10" + }, "autoload": { "psr-4": { "Prophecy\\PhpUnit\\": "src" @@ -33,7 +36,7 @@ "dev-master": "2.x-dev" } }, - "require-dev": { - "phpstan/phpstan": "^1.10" + "config": { + "sort-packages": true } } From 3d547b09856c009054ab448df1067e851eb98653 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 11 Feb 2026 13:57:47 +0100 Subject: [PATCH 11/13] Use phpstan 2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1417a13..b52b41e 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "phpunit/phpunit":"^9.1 || ^10.1 || ^11.0 || ^12.0 || ^13.0" }, "require-dev": { - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^2.1.38" }, "autoload": { "psr-4": { From be86bfaaaa82055e94f84c6392e8dcfb4580b1cb Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Mon, 9 Feb 2026 14:32:27 +0100 Subject: [PATCH 12/13] Update CI setup --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11cd633..d585b6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,15 +14,15 @@ concurrency: jobs: check_composer: name: Check composer.json - runs-on: ubuntu-latest + runs-on: ubuntu-slim steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.2' + php-version: '8.5' coverage: none - name: Validate composer.json @@ -46,7 +46,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -69,11 +69,11 @@ jobs: runs-on: ubuntu-latest name: Static analysis steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.2" + php-version: "8.5" ini-file: development coverage: none - name: Install dependencies From 6ba84f51140a85161678eb24a360de01207bb8e1 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 14 May 2026 13:07:00 +0300 Subject: [PATCH 13/13] Removing PHPStan-related changes (can't adapt them to PHP 5.6) --- .gitattributes | 2 -- .github/workflows/ci.yml | 15 ------------- CHANGES.md | 2 +- composer.json | 4 ---- phpstan-fixtures/ExampleUsage.php | 35 ------------------------------- phpstan.dist.neon | 11 ---------- 6 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 phpstan-fixtures/ExampleUsage.php delete mode 100644 phpstan.dist.neon diff --git a/.gitattributes b/.gitattributes index 3b7ebf0..9091cc7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,7 +4,5 @@ /.github/ export-ignore /CONTRIBUTING.md export-ignore /fixtures/ export-ignore -/phpstan-fixtures/ export-ignore -/phpstan.dist.neon export-ignore /phpunit.xml.dist export-ignore /tests/ export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a62fd8..26c80e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,18 +64,3 @@ jobs: - name: Execute Unit Tests run: vendor/bin/phpunit - - phpstan: - runs-on: ubuntu-latest - name: Static analysis - steps: - - uses: actions/checkout@v6 - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "8.5" - ini-file: development - coverage: none - - name: Install dependencies - run: composer update --ansi --no-interaction --no-progress - - run: ./vendor/bin/phpstan diff --git a/CHANGES.md b/CHANGES.md index 884bdbc..b6fb637 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,7 +12,7 @@ # 2.3.0 -* Add more precise type for the `prophesize` method +* changes unmerged # 2.2.0 diff --git a/composer.json b/composer.json index 8a36bb8..a605d7d 100644 --- a/composer.json +++ b/composer.json @@ -16,9 +16,6 @@ "phpspec/prophecy": "^1.3", "phpunit/phpunit": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0" }, - "require-dev": { - "phpstan/phpstan": "^2.1.38" - }, "autoload": { "psr-4": { "Prophecy\\PhpUnit\\": "src" @@ -27,7 +24,6 @@ "autoload-dev": { "psr-4": { "Prophecy\\PhpUnit\\Tests\\Fixtures\\": "fixtures", - "Prophecy\\PhpUnit\\Tests\\PhpstanFixtures\\": "phpstan-fixtures", "Prophecy\\PhpUnit\\Tests\\": "tests" } }, diff --git a/phpstan-fixtures/ExampleUsage.php b/phpstan-fixtures/ExampleUsage.php deleted file mode 100644 index 93c71a2..0000000 --- a/phpstan-fixtures/ExampleUsage.php +++ /dev/null @@ -1,35 +0,0 @@ -prophesize(\DateTimeImmutable::class); - - $this->configureDouble($prophecy); - - $double = $prophecy->reveal(); - - $this->checkValue($double->format('Y-m-d')); - } - - /** - * @param ObjectProphecy<\DateTimeImmutable> $double - */ - private function configureDouble(ObjectProphecy $double): void - { - } - - private function checkValue(string $value): void - { - self::assertNotEmpty($value); - } -} diff --git a/phpstan.dist.neon b/phpstan.dist.neon deleted file mode 100644 index 28633dc..0000000 --- a/phpstan.dist.neon +++ /dev/null @@ -1,11 +0,0 @@ -parameters: - level: 9 - treatPhpDocTypesAsCertain: false - paths: - - ./src/ - - ./phpstan-fixtures/ - ignoreErrors: - # recordDoubledType exist only in PHPUnit < 10 but the code is checking that before using it. - - - message: '#^Call to an undefined method Prophecy\\PhpUnit\\Tests\\PhpstanFixtures\\[^:]++\:\:recordDoubledType\(\)\.$#' - path: src/ProphecyTrait.php