From 638ce9288774dec153e87ba1ad75d93b1b76e466 Mon Sep 17 00:00:00 2001 From: Ayesh Karunaratne Date: Thu, 31 Aug 2023 21:51:40 +0800 Subject: [PATCH 1/4] Add 'dev' keyword to composer.json to trigger `--dev` prompt Composer 2.4 and later can automatically suggest to use the `--dev` flag when someone runs `composer require phpspec/prophecy` without the `--dev` flag. See [Get Composer to suggest dev packages to `require-dev`](https://php.watch/articles/composer-prompt-require-dev-dev-packages) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0487e1d3f..6b55db996 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "phpspec/prophecy", "description": "Highly opinionated mocking framework for PHP 5.3+", - "keywords": ["Mock", "Stub", "Dummy", "Double", "Fake", "Spy"], + "keywords": ["Mock", "Stub", "Dummy", "Double", "Fake", "Spy", "dev"], "homepage": "https://github.com/phpspec/prophecy", "type": "library", "license": "MIT", From f972b17c177808cc3633362c6bb1a7c1d9071f7c Mon Sep 17 00:00:00 2001 From: Greg Korba Date: Fri, 1 Dec 2023 01:17:03 +0100 Subject: [PATCH 2/4] Rename default PHPStan configuration file It allows per-developer customisation (e.g. editor URL). This approach is officially suggested: https://phpstan.org/config-reference#config-file --- .gitignore | 1 + phpstan.neon => phpstan.dist.neon | 0 2 files changed, 1 insertion(+) rename phpstan.neon => phpstan.dist.neon (100%) diff --git a/.gitignore b/.gitignore index ae8b6cbc0..c7648c5d2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ *.phar /composer.lock /vendor +/phpstan.neon /phpunit.xml /.phpunit.result.cache diff --git a/phpstan.neon b/phpstan.dist.neon similarity index 100% rename from phpstan.neon rename to phpstan.dist.neon From e5aa5ea096f4c4740bcfaed6bc000376363e3564 Mon Sep 17 00:00:00 2001 From: Greg Korba Date: Fri, 1 Dec 2023 01:22:04 +0100 Subject: [PATCH 3/4] Generate new PHPStan baseline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Last commit in the repo is 4 months old, many new versions of PHPStan were released since then 😉. --- phpstan-baseline.neon | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ff18eff5f..52470f1fa 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -35,6 +35,16 @@ parameters: count: 1 path: src/Prophecy/Doubler/Doubler.php + - + message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(ReflectionIntersectionType\\|ReflectionNamedType\\|string\\)\\: mixed\\)\\|null, Closure\\(string\\)\\: string given\\.$#" + count: 1 + path: src/Prophecy/Doubler/Generator/ClassMirror.php + + - + message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(ReflectionIntersectionType\\|ReflectionNamedType\\)\\: mixed\\)\\|null, Closure\\(ReflectionNamedType\\)\\: string given\\.$#" + count: 1 + path: src/Prophecy/Prophecy/MethodProphecy.php + - message: "#^Unable to resolve the template type T in call to method Prophecy\\\\Prophet\\:\\:prophesize\\(\\)$#" count: 1 From 96fbb07f5b623808916e8d5a83b08a97ca62a89f Mon Sep 17 00:00:00 2001 From: Greg Korba Date: Fri, 1 Dec 2023 16:55:06 +0100 Subject: [PATCH 4/4] Introduce Composer scripts for running PHPStan commands --- composer.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/composer.json b/composer.json index 6b55db996..4fa59f837 100644 --- a/composer.json +++ b/composer.json @@ -44,6 +44,16 @@ } }, + "scripts": { + "phpstan": "phpstan analyse", + "phpstan:baseline": "phpstan analyse --generate-baseline" + }, + + "scripts-descriptions": { + "phpstan": "Run PHPStan analysis", + "phpstan:baseline": "Dump PHPStan baseline file - use only for updating, do not add new errors when possible" + }, + "extra": { "branch-alias": { "dev-master": "1.x-dev"