From ddbc593eece21617ef731293ef858e1d25918304 Mon Sep 17 00:00:00 2001 From: "ondrej@mirtes.cz" Date: Sat, 14 Nov 2026 22:30:26 +0000 Subject: [PATCH 1/2] Update phpstan/tally to ^1.0 ExpectationSource::rewrite() is replaced by edits(), which returns the CodeEdit of the header comment instead of the rewritten file. Amp-Thread-ID: https://ampcode.com/threads/T-01a1dc2a-acc9-71d3-bf5f-24be38444155 --- composer.json | 2 +- composer.lock | 25 ++++++++++++++---------- tests/bench/AnalysedFileExpectations.php | 4 ++-- tests/bench/AnalysedFileHeader.php | 17 ++++++++-------- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/composer.json b/composer.json index cce4687e096..48f55d4b0f8 100644 --- a/composer.json +++ b/composer.json @@ -71,7 +71,7 @@ "phpstan/phpstan-nette": "^2.0", "phpstan/phpstan-phpunit": "^2.1", "phpstan/phpstan-strict-rules": "^2.1", - "phpstan/tally": "dev-release/1.x", + "phpstan/tally": "^1.0", "phpunit/phpunit": "^11.5.23", "shipmonk/composer-dependency-analyser": "^1.5", "shipmonk/dead-code-detector": "^1.4.2", diff --git a/composer.lock b/composer.lock index 4487df6fbf1..82ee9f6b6d0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c8e816333f58f55b9348aa729f3d31a4", + "content-hash": "acd0e792aa33507c68e696d5190fabbd", "packages": [ { "name": "clue/ndjson-react", @@ -4205,19 +4205,20 @@ }, { "name": "phpstan/tally", - "version": "dev-release/1.x", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/phpstan/tally.git", - "reference": "e67008ced513658b84e40992268763385218b228" + "reference": "e5f91f6e91b2e10aaa24032b881368a6228c37c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/tally/zipball/e67008ced513658b84e40992268763385218b228", - "reference": "e67008ced513658b84e40992268763385218b228", + "url": "https://api.github.com/repos/phpstan/tally/zipball/e5f91f6e91b2e10aaa24032b881368a6228c37c4", + "reference": "e5f91f6e91b2e10aaa24032b881368a6228c37c4", "shasum": "" }, "require": { + "ext-posix": "*", "php": "^8.2" }, "require-dev": { @@ -4234,6 +4235,11 @@ "bin/tally" ], "type": "library", + "extra": { + "skills": { + "source": "skills" + } + }, "autoload": { "psr-4": { "Tally\\": "src/" @@ -4251,10 +4257,10 @@ ], "support": { "issues": "https://github.com/phpstan/tally/issues", - "source": "https://github.com/phpstan/tally/tree/release/1.x" + "source": "https://github.com/phpstan/tally/tree/1.0.0" }, - "time": "2026-11-14T11:09:44+00:00", - "published-time": "2026-11-14T11:09:50+00:00" + "time": "2026-11-14T22:23:02+00:00", + "published-time": "2026-11-14T22:24:20+00:00" }, { "name": "phpunit/php-code-coverage", @@ -5935,8 +5941,7 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { - "jetbrains/phpstorm-stubs": 20, - "phpstan/tally": 20 + "jetbrains/phpstorm-stubs": 20 }, "prefer-stable": true, "prefer-lowest": false, diff --git a/tests/bench/AnalysedFileExpectations.php b/tests/bench/AnalysedFileExpectations.php index a6d2c1de5c9..2d66d37b345 100644 --- a/tests/bench/AnalysedFileExpectations.php +++ b/tests/bench/AnalysedFileExpectations.php @@ -28,9 +28,9 @@ public function file(): string } #[Override] - public function rewrite(string $code, Metrics $measured): string + public function edits(string $code, Metrics $measured): array { - return $this->header->write($code, $measured); + return [$this->header->write($code, $measured)]; } #[Override] diff --git a/tests/bench/AnalysedFileHeader.php b/tests/bench/AnalysedFileHeader.php index d15bea1e012..164d135ff93 100644 --- a/tests/bench/AnalysedFileHeader.php +++ b/tests/bench/AnalysedFileHeader.php @@ -2,16 +2,14 @@ namespace PHPStan\Benchmark; +use Tally\Expectation\CodeEdit; use Tally\Expectation\ExpectationException; use Tally\Metric; use Tally\Metrics; use Tally\Quantity\InvalidQuantityException; -use function addcslashes; use function preg_match; -use function preg_replace; use function sprintf; use function strlen; -use function substr; /** * Reads and writes the expected numbers in the comment after the first line of a benchmark in data/: @@ -24,7 +22,7 @@ * * memory: 4.520MiB * *\/ * - * Takes code and returns code, AnalysedFileExpectations reads the file. + * Takes code and returns the edit of it, AnalysedFileExpectations reads the file. */ final class AnalysedFileHeader { @@ -47,9 +45,11 @@ public function read(string $code): ?Metrics } /** + * Replaces the comment, or adds it after the format($metrics, Metric::Cycles), $this->format($metrics, Metric::Memory), ); - if (preg_match(self::PATTERN, $code) === 1) { - // the replacement reads $ and \ - return (string) preg_replace(self::PATTERN, '$1' . "\n" . addcslashes($header, '$\\'), $code); + if (preg_match(self::PATTERN, $code, $matches) === 1) { + return new CodeEdit(strlen($matches[1]), strlen($matches[0]) - strlen($matches[1]), "\n" . $header); } if (preg_match('~\A<\?php[^\n]*\n~', $code, $matches) !== 1) { throw new ExpectationException('The benchmark does not start with a Date: Sat, 14 Nov 2026 22:42:34 +0000 Subject: [PATCH 2/2] Update phpstan/tally to 1.0.1 1.0.1 requires ext-posix only for its own development, so phpstan-src installs on Windows again. Amp-Thread-ID: https://ampcode.com/threads/T-01a1dc31-07ff-7750-b3ea-2915ebc9d89a --- composer.json | 2 +- composer.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 48f55d4b0f8..f95adb69640 100644 --- a/composer.json +++ b/composer.json @@ -71,7 +71,7 @@ "phpstan/phpstan-nette": "^2.0", "phpstan/phpstan-phpunit": "^2.1", "phpstan/phpstan-strict-rules": "^2.1", - "phpstan/tally": "^1.0", + "phpstan/tally": "^1.0.1", "phpunit/phpunit": "^11.5.23", "shipmonk/composer-dependency-analyser": "^1.5", "shipmonk/dead-code-detector": "^1.4.2", diff --git a/composer.lock b/composer.lock index 82ee9f6b6d0..31ccd7593f9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "acd0e792aa33507c68e696d5190fabbd", + "content-hash": "1267a1b194e9dd3c379a9fe16dabe494", "packages": [ { "name": "clue/ndjson-react", @@ -4205,23 +4205,23 @@ }, { "name": "phpstan/tally", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpstan/tally.git", - "reference": "e5f91f6e91b2e10aaa24032b881368a6228c37c4" + "reference": "f62fb265cbe7fd916af1e8d61ee49bb2c1af4b21" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/tally/zipball/e5f91f6e91b2e10aaa24032b881368a6228c37c4", - "reference": "e5f91f6e91b2e10aaa24032b881368a6228c37c4", + "url": "https://api.github.com/repos/phpstan/tally/zipball/f62fb265cbe7fd916af1e8d61ee49bb2c1af4b21", + "reference": "f62fb265cbe7fd916af1e8d61ee49bb2c1af4b21", "shasum": "" }, "require": { - "ext-posix": "*", "php": "^8.2" }, "require-dev": { + "ext-posix": "*", "infection/infection": "^0.35.10", "php-parallel-lint/php-parallel-lint": "^1.4", "phpstan/phpstan": "^2.1", @@ -4257,10 +4257,10 @@ ], "support": { "issues": "https://github.com/phpstan/tally/issues", - "source": "https://github.com/phpstan/tally/tree/1.0.0" + "source": "https://github.com/phpstan/tally/tree/1.0.1" }, - "time": "2026-11-14T22:23:02+00:00", - "published-time": "2026-11-14T22:24:20+00:00" + "time": "2026-11-14T22:36:03+00:00", + "published-time": "2026-11-14T22:42:17+00:00" }, { "name": "phpunit/php-code-coverage",