Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Nov 4, 2025

similar to phpstan/build-infection#30

requires #4525

@staabm staabm marked this pull request as draft November 4, 2025 16:44
@staabm staabm marked this pull request as ready for review November 8, 2025 09:00
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@staabm
Copy link
Contributor Author

staabm commented Nov 8, 2025

I tried so many variants.. but this one is the only one working atm, because infection has some problems regarding relative paths (finding the phpunit.xml depending on the location of the infection.json5 etc).

lets move forward with this suboptimal first version and improve on it in future infection version, when the file resolution is more sane.

@staabm
Copy link
Contributor Author

staabm commented Dec 7, 2025

so finally this seem to work like expected

➜  phpstan-src git:(make-inf) ✗ make infection
git -C build-infection pull || git clone https://github.com/phpstan/build-infection.git
Bereits aktuell.
git -C build-infection fetch origin && git -C build-infection reset --hard origin/1.x
HEAD ist jetzt bei 8bc54ab Update actions/checkout action to v6 (#40)
composer install --working-dir build-infection --no-interaction --no-progress
Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9003 (through xdebug.client_host/xdebug.client_port).
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating autoload files
51 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
infection/extension-installer: No extensions found
php build-infection/bin/infection-config.php --source-directory='build/PHPStan/Build'> infection.json5
Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9003 (through xdebug.client_host/xdebug.client_port).
XDEBUG_MODE=coverage php tests/vendor/bin/paratest \
                --coverage-xml=tmp/coverage/coverage-xml \
                --log-junit=tmp/coverage/junit.xml
ParaTest v7.8.4 upon PHPUnit 11.5.45 by Sebastian Bergmann and contributors.

Warming cache for static analysis ... [00:00.058]
Processes:     14
Runtime:       PHP 8.3.28 with Xdebug 3.5.0
Configuration: /Users/staabm/workspace/phpstan-src/phpunit.xml
Random Seed:   1765098695

............S.S......SS..S.................................    59 / 13558 (  0%)
...........................................................   118 / 13558 (  0%)
.....................S......S.....S.........SS.S...........   177 / 13558 (  1%)
...........................................................   236 / 13558 (  1%)
...........................................................   295 / 13558 (  2%)
...........................................................   354 / 13558 (  2%)
...........................................................   413 / 13558 (  3%)
...........................................................   472 / 13558 (  3%)
...........SS..........S.S.................................   531 / 13558 (  3%)
...........................................................   590 / 13558 (  4%)
...........................................................   649 / 13558 (  4%)
...........................................................   708 / 13558 (  5%)
...........................................................   767 / 13558 (  5%)
...........................................................   826 / 13558 (  6%)
...........................................................   885 / 13558 (  6%)
...........................................................   944 / 13558 (  6%)
...........................................................  1003 / 13558 (  7%)
...........................................................  1062 / 13558 (  7%)
...........................................................  1121 / 13558 (  8%)
...........................................................  1180 / 13558 (  8%)
...........................................................  1239 / 13558 (  9%)
...........................................................  1298 / 13558 (  9%)
...........................................................  1357 / 13558 ( 10%)
...........................................................  1416 / 13558 ( 10%)
...........................................................  1475 / 13558 ( 10%)
...........................................................  1534 / 13558 ( 11%)
...........................................................  1593 / 13558 ( 11%)
...........................................................  1652 / 13558 ( 12%)
...........................................................  1711 / 13558 ( 12%)
...........................................................  1770 / 13558 ( 13%)
...........................................................  1829 / 13558 ( 13%)
...........................................................  1888 / 13558 ( 13%)
...........................................................  1947 / 13558 ( 14%)
...........................................................  2006 / 13558 ( 14%)
...........................................................  2065 / 13558 ( 15%)
...........................................................  2124 / 13558 ( 15%)
...........................................................  2183 / 13558 ( 16%)
...........................................................  2242 / 13558 ( 16%)
...........................................................  2301 / 13558 ( 16%)
...........................................................  2360 / 13558 ( 17%)
...........................................................  2419 / 13558 ( 17%)
...........................................................  2478 / 13558 ( 18%)
...........................................................  2537 / 13558 ( 18%)
...........................................................  2596 / 13558 ( 19%)
...........................................................  2655 / 13558 ( 19%)
...........................................................  2714 / 13558 ( 20%)
...........................................................  2773 / 13558 ( 20%)
...........................................................  2832 / 13558 ( 20%)
...........................................................  2891 / 13558 ( 21%)
...........................................................  2950 / 13558 ( 21%)
...........................................................  3009 / 13558 ( 22%)
...........................................................  3068 / 13558 ( 22%)
...........................................................  3127 / 13558 ( 23%)
...........................................................  3186 / 13558 ( 23%)
............................................S..............  3245 / 13558 ( 23%)
...............................................S.......SSSS  3304 / 13558 ( 24%)
SSSSS..........SSSSSSSS....................................  3363 / 13558 ( 24%)
...........................................................  3422 / 13558 ( 25%)
...........................................................  3481 / 13558 ( 25%)
...........................................................  3540 / 13558 ( 26%)
..........S................................................  3599 / 13558 ( 26%)
...........................................................  3658 / 13558 ( 26%)
.......S...................................................  3717 / 13558 ( 27%)
..............................................S............  3776 / 13558 ( 27%)
...........................................................  3835 / 13558 ( 28%)
...........................................................  3894 / 13558 ( 28%)
...............S.....................SSS..SS...............  3953 / 13558 ( 29%)
...........................................................  4012 / 13558 ( 29%)
.......................................SS..................  4071 / 13558 ( 30%)
..................S........................................  4130 / 13558 ( 30%)
............SS................................S............  4189 / 13558 ( 30%)
..........................................S................  4248 / 13558 ( 31%)
....S............S.............................S...........  4307 / 13558 ( 31%)
...........................................................  4366 / 13558 ( 32%)
...........................................................  4425 / 13558 ( 32%)
.......................S.............SSSSSSS...............  4484 / 13558 ( 33%)
...........................................................  4543 / 13558 ( 33%)
...........................................................  4602 / 13558 ( 33%)
...........................................................  4661 / 13558 ( 34%)
.....S...........S...S.....................................  4720 / 13558 ( 34%)
....................................................S......  4779 / 13558 ( 35%)
S..........................................................  4838 / 13558 ( 35%)
..........................SS.....SS........................  4897 / 13558 ( 36%)
.................................S.........................  4956 / 13558 ( 36%)
...................................SS................S.....  5015 / 13558 ( 36%)
...........................................................  5074 / 13558 ( 37%)
......S.S.................................S............S...  5133 / 13558 ( 37%)
................S.....................................SS...  5192 / 13558 ( 38%)
...........................................................  5251 / 13558 ( 38%)
...........................................................  5310 / 13558 ( 39%)
..................................................S........  5369 / 13558 ( 39%)
...........................................................  5428 / 13558 ( 40%)
...........................................................  5487 / 13558 ( 40%)
..............................................S............  5546 / 13558 ( 40%)
.................................................S.........  5605 / 13558 ( 41%)
...........................................................  5664 / 13558 ( 41%)
...........................................................  5723 / 13558 ( 42%)
..................S........................................  5782 / 13558 ( 42%)
...........................................................  5841 / 13558 ( 43%)
...........................................................  5900 / 13558 ( 43%)
...S.......................................................  5959 / 13558 ( 43%)
...........................................................  6018 / 13558 ( 44%)
...........................................................  6077 / 13558 ( 44%)
.............SSSSSSSSSSSSSSSSS.............................  6136 / 13558 ( 45%)
...........................................................  6195 / 13558 ( 45%)
.........SS................................................  6254 / 13558 ( 46%)
...........................................................  6313 / 13558 ( 46%)
.................SSS...................................SSSS  6372 / 13558 ( 46%)
SSSSSSSSSS.S..........S....S......S........................  6431 / 13558 ( 47%)
................SS...........................S.....SS...S..  6490 / 13558 ( 47%)
..................S..........S.............................  6549 / 13558 ( 48%)
...........................................................  6608 / 13558 ( 48%)
...........................................................  6667 / 13558 ( 49%)
...........................................................  6726 / 13558 ( 49%)
...........................................................  6785 / 13558 ( 50%)
...........................................................  6844 / 13558 ( 50%)
...........................................................  6903 / 13558 ( 50%)
...........................................................  6962 / 13558 ( 51%)
...........................................................  7021 / 13558 ( 51%)
...........................................................  7080 / 13558 ( 52%)
...........................................................  7139 / 13558 ( 52%)
...........................................................  7198 / 13558 ( 53%)
...........................................................  7257 / 13558 ( 53%)
...........................................................  7316 / 13558 ( 53%)
...........................................................  7375 / 13558 ( 54%)
...........................................................  7434 / 13558 ( 54%)
...........................................................  7493 / 13558 ( 55%)
...........................................................  7552 / 13558 ( 55%)
.S.................................S.......................  7611 / 13558 ( 56%)
...........................................................  7670 / 13558 ( 56%)
...........................................................  7729 / 13558 ( 57%)
...........................................................  7788 / 13558 ( 57%)
...........................................................  7847 / 13558 ( 57%)
S...........S...S..........................................  7906 / 13558 ( 58%)
.......S...................................................  7965 / 13558 ( 58%)
...................S.......................................  8024 / 13558 ( 59%)
..................S.............................SSS........  8083 / 13558 ( 59%)
...........................................................  8142 / 13558 ( 60%)
...................S.......S...............................  8201 / 13558 ( 60%)
.................................................S.........  8260 / 13558 ( 60%)
...........................................................  8319 / 13558 ( 61%)
...........................................................  8378 / 13558 ( 61%)
.................................SS........................  8437 / 13558 ( 62%)
...........................................................  8496 / 13558 ( 62%)
...........................................................  8555 / 13558 ( 63%)
...........................................................  8614 / 13558 ( 63%)
..............S.................S..........................  8673 / 13558 ( 63%)
SSS.SSS......................S.............................  8732 / 13558 ( 64%)
...........................................................  8791 / 13558 ( 64%)
...........................................................  8850 / 13558 ( 65%)
........................................................S..  8909 / 13558 ( 65%)
..................................S........................  8968 / 13558 ( 66%)
................SS.........................................  9027 / 13558 ( 66%)
...........................................................  9086 / 13558 ( 67%)
......S....................................................  9145 / 13558 ( 67%)
...........................................................  9204 / 13558 ( 67%)
...........................................................  9263 / 13558 ( 68%)
...............S............S..............................  9322 / 13558 ( 68%)
...........................................................  9381 / 13558 ( 69%)
....................................................SS.....  9440 / 13558 ( 69%)
.................S.........................................  9499 / 13558 ( 70%)
...........................................................  9558 / 13558 ( 70%)
...........................................................  9617 / 13558 ( 70%)
...........................................................  9676 / 13558 ( 71%)
...........................................................  9735 / 13558 ( 71%)
...........................................................  9794 / 13558 ( 72%)
...........................................................  9853 / 13558 ( 72%)
...........................................................  9912 / 13558 ( 73%)
...........................................................  9971 / 13558 ( 73%)
........................................................... 10030 / 13558 ( 73%)
........................................................... 10089 / 13558 ( 74%)
........................................................... 10148 / 13558 ( 74%)
........................................................... 10207 / 13558 ( 75%)
........................................................... 10266 / 13558 ( 75%)
........................................................... 10325 / 13558 ( 76%)
........................................................... 10384 / 13558 ( 76%)
........................................................... 10443 / 13558 ( 77%)
........................................................... 10502 / 13558 ( 77%)
........................................................... 10561 / 13558 ( 77%)
........................................................... 10620 / 13558 ( 78%)
........................................................... 10679 / 13558 ( 78%)
........................................................... 10738 / 13558 ( 79%)
........................................................... 10797 / 13558 ( 79%)
........................................................... 10856 / 13558 ( 80%)
........................................................... 10915 / 13558 ( 80%)
........................................................... 10974 / 13558 ( 80%)
........................................................... 11033 / 13558 ( 81%)
........................................................... 11092 / 13558 ( 81%)
........................................................... 11151 / 13558 ( 82%)
........................................................... 11210 / 13558 ( 82%)
........................................................... 11269 / 13558 ( 83%)
.................................................S......... 11328 / 13558 ( 83%)
........................................................... 11387 / 13558 ( 83%)
........................................................... 11446 / 13558 ( 84%)
........................................................... 11505 / 13558 ( 84%)
........................................................... 11564 / 13558 ( 85%)
........................................................... 11623 / 13558 ( 85%)
........................................................... 11682 / 13558 ( 86%)
........................................................... 11741 / 13558 ( 86%)
........................................................... 11800 / 13558 ( 87%)
........................................................... 11859 / 13558 ( 87%)
........................................................... 11918 / 13558 ( 87%)
........................................................... 11977 / 13558 ( 88%)
........................................................... 12036 / 13558 ( 88%)
........................................................... 12095 / 13558 ( 89%)
.............................................S............. 12154 / 13558 ( 89%)
........................................................... 12213 / 13558 ( 90%)
........................................................... 12272 / 13558 ( 90%)
........................................................... 12331 / 13558 ( 90%)
....
....................................................... 12390 / 13558 ( 91%)
........................................................... 12449 / 13558 ( 91%)
........................................................... 12508 / 13558 ( 92%)
........................................................... 12567 / 13558 ( 92%)
........................................................... 12626 / 13558 ( 93%)
........................................................... 12685 / 13558 ( 93%)
........................................................... 12744 / 13558 ( 93%)
........................................................... 12803 / 13558 ( 94%)
........................................................... 12862 / 13558 ( 94%)
........................................................... 12921 / 13558 ( 95%)
........................................................... 12980 / 13558 ( 95%)
........................................................... 13039 / 13558 ( 96%)
........................................................... 13098 / 13558 ( 96%)
........................................................... 13157 / 13558 ( 97%)
........................................................... 13216 / 13558 ( 97%)
........................................................... 13275 / 13558 ( 97%)
........................................................... 13334 / 13558 ( 98%)
........................................................... 13393 / 13558 ( 98%)
........................................................... 13452 / 13558 ( 99%)
........................................................... 13511 / 13558 ( 99%)
...............................................             13558 / 13558 (100%)

Time: 03:47.108, Memory: 634.50 MB

OK, but some tests were skipped!
Tests: 13558, Assertions: 80816, Skipped: 171.

Generating code coverage report in PHPUnit XML format ... done [00:31.872]
php build-infection/vendor/bin/infection \
                --configuration=infection.json5 \
                --git-diff-base=origin/HEAD \
                --git-diff-lines \
                --coverage=tmp/coverage \
                --skip-initial-tests \
                --ignore-msi-with-no-mutations \
                --logger-text=php://stdout
Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9003 (through xdebug.client_host/xdebug.client_port).

    ____      ____          __  _
   /  _/___  / __/__  _____/ /_(_)___  ____
   / // __ \/ /_/ _ \/ ___/ __/ / __ \/ __ \
 _/ // / / / __/  __/ /__/ /_/ / /_/ / / / /
/___/_/ /_/_/  \___/\___/\__/_/\____/_/ /_/

#StandWithUkraine

Infection - PHP Mutation Testing Framework version 0.31.9

[warning] Skipping the initial test run can be very dangerous.
It is your responsibility to ensure the tests are in a passing state to begin.                                                                                                       
If this is not done then mutations may report as caught when they are not.                                                                                                           


Running initial Static Analysis...

PHPStan version: 2.1.x-dev@ab48233

    4 [============================] 2 secs

Generate mutants...

Processing source code files: 38/38
.: killed by tests, A: killed by SA, M: escaped, U: uncovered
E: fatal error, X: syntax error, T: timed out, S: skipped, I: ignored

SSSSSSSSSS..                                         (12 / 12)

12 mutations were generated:
       2 mutants were killed by Test Framework
      10 mutants required more time than configured

Metrics:
         Mutation Code Coverage: 100%
         Covered Code MSI: 100%

Please note that some mutants will inevitably be harmless (i.e. false positives).
Note: Pass `--log-verbosity=all` to log information about killed and errored mutants.
Note: Pass `--debug` to log test-framework output.

Escaped mutants:
================

Timed Out mutants:
==================

Skipped mutants:
================

1) /Users/staabm/workspace/phpstan-src/src/Reflection/InitializerExprTypeResolver.php:592    [M] PHPStan\Infection\TrinaryLogicMutator [ID] e4030d1ea6a6f8fb531dc0f668c4e140

@@ @@
         }
         $leftNumericStringNonEmpty = TypeCombinator::remove($leftStringType, new ConstantStringType(''));
         if ($leftNumericStringNonEmpty->isNumericString()->yes()) {
-            $validationCallback = $left->isInteger()->yes() ? static fn(string $value): bool => !str_starts_with($value, '-') : static fn(string $value): bool => Strings::match($value, '#^\d+$#') !== null;
+            $validationCallback = !$left->isInteger()->no() ? static fn(string $value): bool => !str_starts_with($value, '-') : static fn(string $value): bool => Strings::match($value, '#^\d+$#') !== null;
             $allRightConstantsZeroOrMore = false;
             foreach ($rightConstantStrings as $rightConstantString) {
                 if ($rightConstantString->getValue() === '') {


2) /Users/staabm/workspace/phpstan-src/src/Reflection/InitializerExprTypeResolver.php:1018    [M] PHPStan\Infection\TrinaryLogicMutator [ID] d2ea82f95ec61c31c5a74165fef149b0

@@ @@
         }
         $leftIsString = $leftType->isString();
         $rightIsString = $rightType->isString();
-        if (($leftIsString->yes() || $leftType instanceof MixedType) && ($rightIsString->yes() || $rightType instanceof MixedType)) {
+        if ((!$leftIsString->no() || $leftType instanceof MixedType) && ($rightIsString->yes() || $rightType instanceof MixedType)) {
             return new StringType();
         }
         if ($leftIsString->maybe() && $rightIsString->maybe()) {


3) /Users/staabm/workspace/phpstan-src/src/Reflection/InitializerExprTypeResolver.php:1019    [M] PHPStan\Infection\TrinaryLogicMutator [ID] 039966573398955f595c6d1666df11d2

@@ @@
         }
         $leftIsString = $leftType->isString();
         $rightIsString = $rightType->isString();
-        if (($leftIsString->yes() || $leftType instanceof MixedType) && ($rightIsString->yes() || $rightType instanceof MixedType)) {
+        if (($leftIsString->yes() || $leftType instanceof MixedType) && (!$rightIsString->no() || $rightType instanceof MixedType)) {
             return new StringType();
         }
         if ($leftIsString->maybe() && $rightIsString->maybe()) {


4) /Users/staabm/workspace/phpstan-src/src/Reflection/InitializerExprTypeResolver.php:1104    [M] PHPStan\Infection\TrinaryLogicMutator [ID] bf2fc74d6a822a81295c74f262e4c0c8

@@ @@
         }
         $leftIsString = $leftType->isString();
         $rightIsString = $rightType->isString();
-        if (($leftIsString->yes() || $leftType instanceof MixedType) && ($rightIsString->yes() || $rightType instanceof MixedType)) {
+        if ((!$leftIsString->no() || $leftType instanceof MixedType) && ($rightIsString->yes() || $rightType instanceof MixedType)) {
             return new StringType();
         }
         if ($leftIsString->maybe() && $rightIsString->maybe()) {


5) /Users/staabm/workspace/phpstan-src/src/Reflection/InitializerExprTypeResolver.php:1105    [M] PHPStan\Infection\TrinaryLogicMutator [ID] af2a0a45f37b8f3b68a4aa72362cfd52

@@ @@
         }
         $leftIsString = $leftType->isString();
         $rightIsString = $rightType->isString();
-        if (($leftIsString->yes() || $leftType instanceof MixedType) && ($rightIsString->yes() || $rightType instanceof MixedType)) {
+        if (($leftIsString->yes() || $leftType instanceof MixedType) && (!$rightIsString->no() || $rightType instanceof MixedType)) {
             return new StringType();
         }
         if ($leftIsString->maybe() && $rightIsString->maybe()) {


6) /Users/staabm/workspace/phpstan-src/src/Reflection/InitializerExprTypeResolver.php:1180    [M] PHPStan\Infection\TrinaryLogicMutator [ID] 4646d1e79ad806c92f11c3bea98fe8cd

@@ @@
         }
         $leftIsString = $leftType->isString();
         $rightIsString = $rightType->isString();
-        if (($leftIsString->yes() || $leftType instanceof MixedType) && ($rightIsString->yes() || $rightType instanceof MixedType)) {
+        if ((!$leftIsString->no() || $leftType instanceof MixedType) && ($rightIsString->yes() || $rightType instanceof MixedType)) {
             return new StringType();
         }
         if ($leftIsString->maybe() && $rightIsString->maybe()) {


7) /Users/staabm/workspace/phpstan-src/src/Reflection/InitializerExprTypeResolver.php:1181    [M] PHPStan\Infection\TrinaryLogicMutator [ID] 8c0a37f3ea3db544e6fec06807c41c4a

@@ @@
         }
         $leftIsString = $leftType->isString();
         $rightIsString = $rightType->isString();
-        if (($leftIsString->yes() || $leftType instanceof MixedType) && ($rightIsString->yes() || $rightType instanceof MixedType)) {
+        if (($leftIsString->yes() || $leftType instanceof MixedType) && (!$rightIsString->no() || $rightType instanceof MixedType)) {
             return new StringType();
         }
         if ($leftIsString->maybe() && $rightIsString->maybe()) {


8) /Users/staabm/workspace/phpstan-src/src/Type/Php/CountFunctionReturnTypeExtension.php:39    [M] PHPStan\Infection\TrinaryLogicMutator [ID] 8c514423618e99c7a5fffb47764ee93f

@@ @@
             return null;
         }
         $arrayType = $scope->getType($args[0]->value);
-        if (!$this->isNormalCount($functionCall, $arrayType, $scope)->yes()) {
+        if ($this->isNormalCount($functionCall, $arrayType, $scope)->no()) {
             if ($arrayType->isIterableAtLeastOnce()->yes()) {
                 return IntegerRangeType::fromInterval(1, null);
             }


9) /Users/staabm/workspace/phpstan-src/src/Type/Php/CountFunctionReturnTypeExtension.php:40    [M] PHPStan\Infection\TrinaryLogicMutator [ID] 89c8b0d4f7a14b97b3aae3db67bdc98f

@@ @@
         }
         $arrayType = $scope->getType($args[0]->value);
         if (!$this->isNormalCount($functionCall, $arrayType, $scope)->yes()) {
-            if ($arrayType->isIterableAtLeastOnce()->yes()) {
+            if (!$arrayType->isIterableAtLeastOnce()->no()) {
                 return IntegerRangeType::fromInterval(1, null);
             }
             return null;


10) /Users/staabm/workspace/phpstan-src/src/Type/Php/CountFunctionReturnTypeExtension.php:55    [M] PHPStan\Infection\IsSuperTypeOfCalleeAndArgumentMutator [ID] 50387e70c251ddba4f44862902466589

@@ @@
             $isNormalCount = TrinaryLogic::createYes();
         } else {
             $mode = $scope->getType($countFuncCall->getArgs()[1]->value);
-            $isNormalCount = (new ConstantIntegerType(COUNT_NORMAL))->isSuperTypeOf($mode)->result->or($countedType->getIterableValueType()->isArray()->negate());
+            $isNormalCount = $mode->isSuperTypeOf(new ConstantIntegerType(COUNT_NORMAL))->result->or($countedType->getIterableValueType()->isArray()->negate());
         }
         return $isNormalCount;
     }
 }

Time: 19s. Memory: 1.21GB. Threads: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants