Repository: Codeception/Codeception (language: php)

Issue:
Allow to disable coverage.serialized report and reduce memory usage.
#### What are you trying to achieve?
Currently `SebastianBergmann\CodeCoverage\Report\PHP` runs by default
Saving this  report consumes a lot of memory for the large projects. 
I want to be able to disable generating this type of coverage report.

#### What do you get instead?

My propose to add some new option `--disable-coverage-php` this will not provoke BC changes
```bash
php bin/codecept run unit --coverage --coverage-html --disable-coverage-php
```

Or changing behaviur of the CLI. If we was't call `--coverage` option but call any other `--coverage-*` format than don't generate default php serialize  report.
```bash
php bin/codecept run unit --coverage-html
```


Discussion / hints:

Fix patch:
diff --git a/src/Codeception/Codecept.php b/src/Codeception/Codecept.php
index 0689f02c3c..46dd63ab09 100644
--- a/src/Codeception/Codecept.php
+++ b/src/Codeception/Codecept.php
@@ -45,33 +45,34 @@ class Codecept
     protected ExtensionLoader $extensionLoader;
 
     protected array $options = [
-        'silent'             => false,
-        'debug'              => false,
-        'steps'              => false,
-        'html'               => false,
-        'xml'                => false,
-        'phpunit-xml'        => false,
-        'no-redirect'        => true,
-        'report'             => false,
-        'colors'             => false,
-        'coverage'           => false,
-        'coverage-xml'       => false,
-        'coverage-html'      => false,
-        'coverage-text'      => false,
-        'coverage-crap4j'    => false,
-        'coverage-cobertura' => false,
-        'coverage-phpunit'   => false,
-        'groups'             => null,
-        'excludeGroups'      => null,
-        'filter'             => null,
-        'shard'              => null,
-        'env'                => null,
-        'fail-fast'          => 0,
-        'ansi'               => true,
-        'verbosity'          => 1,
-        'interactive'        => true,
-        'no-rebuild'         => false,
-        'quiet'              => false,
+        'silent'               => false,
+        'debug'                => false,
+        'steps'                => false,
+        'html'                 => false,
+        'xml'                  => false,
+        'phpunit-xml'          => false,
+        'no-redirect'          => true,
+        'report'               => false,
+        'colors'               => false,
+        'coverage'             => false,
+        'coverage-xml'         => false,
+        'coverage-html'        => false,
+        'coverage-text'        => false,
+        'coverage-crap4j'      => false,
+        'coverage-cobertura'   => false,
+        'coverage-phpunit'     => false,
+        'disable-coverage-php' => false,
+        'groups'               => null,
+        'excludeGroups'        => null,
+        'filter'               => null,
+        'shard'                => null,
+        'env'                  => null,
+        'fail-fast'            => 0,
+        'ansi'                 => true,
+        'verbosity'            => 1,
+        'interactive'          => true,
+        'no-rebuild'           => false,
+        'quiet'                => false,
     ];
 
     protected array $config = [];
diff --git a/src/Codeception/Command/Run.php b/src/Codeception/Command/Run.php
index 398c6cdeae..ac326b4b70 100644
--- a/src/Codeception/Command/Run.php
+++ b/src/Codeception/Command/Run.php
@@ -89,39 +89,40 @@
  *
  * Options:
  *  -o, --override=OVERRIDE Override config values (multiple values allowed)
- *  --config (-c)         Use custom path for config
- *  --report              Show output in compact style
- *  --html                Generate html with results (default: "report.html")
- *  --xml                 Generate JUnit XML Log (default: "report.xml")
- *  --phpunit-xml         Generate PhpUnit XML Log (default: "phpunit-report.xml")
- *  --no-redirect         Do not redirect to Composer-installed version in vendor/codeception
- *  --colors              Use colors in output
- *  --no-colors           Force no colors in output (useful to override config file)
- *  --silent              Only outputs suite names and final results. Almost the same as `--quiet`
- *  --steps               Show steps in output
- *  --debug (-d)          Alias for `-vv`
- *  --bootstrap           Execute bootstrap script before the test
- *  --coverage            Run with code coverage (default: "coverage.serialized")
- *  --coverage-html       Generate CodeCoverage HTML report in path (default: "coverage")
- *  --coverage-xml        Generate CodeCoverage XML report in file (default: "coverage.xml")
- *  --coverage-text       Generate CodeCoverage text report in file (default: "coverage.txt")
- *  --coverage-phpunit    Generate CodeCoverage PHPUnit report in file (default: "coverage-phpunit")
- *  --coverage-cobertura  Generate CodeCoverage Cobertura report in file (default: "coverage-cobertura")
- *  --no-exit             Don't finish with exit code
- *  --group (-g)          Groups of tests to be executed (multiple values allowed)
- *  --skip (-s)           Skip selected suites (multiple values allowed)
- *  --skip-group (-x)     Skip selected groups (multiple values allowed)
- *  --env                 Run tests in selected environments. (multiple values allowed, environments can be merged with ',')
- *  --fail-fast (-f)      Stop after nth failure (defaults to 1)
- *  --no-rebuild          Do not rebuild actor classes on start
- *  --help (-h)           Display this help message.
- *  --quiet (-q)          Do not output any message. Almost the same as `--silent`
- *  --verbose (-v|vv|vvv) Increase the verbosity of messages: `v` for normal output, `vv` for steps and debug, `vvv` for Codeception-internal debug
- *  --version (-V)        Display this application version.
- *  --ansi                Force ANSI output.
- *  --no-ansi             Disable ANSI output.
- *  --no-interaction (-n) Do not ask any interactive question.
- *  --seed                Use the given seed for shuffling tests
+ *  --config (-c)          Use custom path for config
+ *  --report               Show output in compact style
+ *  --html                 Generate html with results (default: "report.html")
+ *  --xml                  Generate JUnit XML Log (default: "report.xml")
+ *  --phpunit-xml          Generate PhpUnit XML Log (default: "phpunit-report.xml")
+ *  --no-redirect          Do not redirect to Composer-installed version in vendor/codeception
+ *  --colors               Use colors in output
+ *  --no-colors            Force no colors in output (useful to override config file)
+ *  --silent               Only outputs suite names and final results. Almost the same as `--quiet`
+ *  --steps                Show steps in output
+ *  --debug (-d)           Alias for `-vv`
+ *  --bootstrap            Execute bootstrap script before the test
+ *  --coverage             Run with code coverage (default: "coverage.serialized")
+ *  --disable-coverage-php Don't generate CodeCoverage report in raw PHP serialized format
+ *  --coverage-html        Generate CodeCoverage HTML report in path (default: "coverage")
+ *  --coverage-xml         Generate CodeCoverage XML report in file (default: "coverage.xml")
+ *  --coverage-text        Generate CodeCoverage text report in file (default: "coverage.txt")
+ *  --coverage-phpunit     Generate CodeCoverage PHPUnit report in file (default: "coverage-phpunit")
+ *  --coverage-cobertura   Generate CodeCoverage Cobertura report in file (default: "coverage-cobertura")
+ *  --no-exit              Don't finish with exit code
+ *  --group (-g)           Groups of tests to be executed (multiple values allowed)
+ *  --skip (-s)            Skip selected suites (multiple values allowed)
+ *  --skip-group (-x)      Skip selected groups (multiple values allowed)
+ *  --env                  Run tests in selected environments. (multiple values allowed, environments can be merged with ',')
+ *  --fail-fast (-f)       Stop after nth failure (defaults to 1)
+ *  --no-rebuild           Do not rebuild actor classes on start
+ *  --help (-h)            Display this help message.
+ *  --quiet (-q)           Do not output any message. Almost the same as `--silent`
+ *  --verbose (-v|vv|vvv)  Increase the verbosity of messages: `v` for normal output, `vv` for steps and debug, `vvv` for Codeception-internal debug
+ *  --version (-V)         Display this application version.
+ *  --ansi                 Force ANSI output.
+ *  --no-ansi              Disable ANSI output.
+ *  --no-interaction (-n)  Do not ask any interactive question.
+ *  --seed                 Use the given seed for shuffling tests
  * ```
  *
  */
@@ -173,6 +174,7 @@ protected function configure(): void
             ->addOption('coverage-crap4j', '', InputOption::VALUE_OPTIONAL, 'Generate CodeCoverage report in Crap4J XML format')
             ->addOption('coverage-cobertura', '', InputOption::VALUE_OPTIONAL, 'Generate CodeCoverage report in Cobertura XML format')
             ->addOption('coverage-phpunit', '', InputOption::VALUE_OPTIONAL, 'Generate CodeCoverage PHPUnit report in path')
+            ->addOption('disable-coverage-php', '', InputOption::VALUE_NONE, "Don't generate CodeCoverage report in raw PHP serialized format")
             ->addOption('no-exit', '', InputOption::VALUE_NONE, "Don't finish with exit code")
             ->addOption('group', 'g', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Groups of tests to be executed')
             ->addOption('skip', 's', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Skip selected suites')
@@ -240,6 +242,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
         $userOptions['verbosity'] = $this->output->getVerbosity();
         $userOptions['interactive'] = !$input->hasParameterOption(['--no-interaction', '-n']);
         $userOptions['ansi'] = (!$input->hasParameterOption('--no-ansi') xor $input->hasParameterOption('ansi'));
+        $userOptions['disable-coverage-php'] = (bool) $this->options['disable-coverage-php'];
 
         $userOptions['seed'] = $this->options['seed'] ? (int)$this->options['seed'] : rand();
         if ($this->options['no-colors'] || !$userOptions['ansi']) {
diff --git a/src/Codeception/Coverage/Subscriber/Printer.php b/src/Codeception/Coverage/Subscriber/Printer.php
index b1ddabb2da..718d46476b 100644
--- a/src/Codeception/Coverage/Subscriber/Printer.php
+++ b/src/Codeception/Coverage/Subscriber/Printer.php
@@ -83,7 +83,11 @@ public function printResult(PrintResultEvent $event): void
             $this->printConsole();
         }
         $this->output->write("Remote CodeCoverage reports are not printed to console\n");
-        $this->printPHP();
+        if ($this->options['disable-coverage-php'] === true) {
+            $this->output->write("PHP serialized report was skipped\n");
+        } else {
+            $this->printPHP();
+        }
         $this->output->write("\n");
 
         $reports = [


Test patch:
diff --git a/tests/cli/IncludedCest.php b/tests/cli/IncludedCest.php
index fb7fb343db..0feaf51559 100644
--- a/tests/cli/IncludedCest.php
+++ b/tests/cli/IncludedCest.php
@@ -125,10 +125,11 @@ public function runIncludedWithHtmlOutput(CliGuy $I)
 
     #[Before('moveToIncluded')]
     #[Group('coverage')]
-    public function runIncludedWithCoverage(CliGuy $I)
+    public function runIncludedWithCoverage(CliGuy $I): void
     {
         $I->executeCommand('run --coverage-xml');
         $I->amInPath('_log');
+        $I->seeFileFound('coverage.serialized');
         $I->seeFileFound('coverage.xml');
         //these assertions shrank over the years to be compatible with many versions of php-code-coverage library
         $I->seeInThisFile('BillEvans" namespace="');
@@ -136,6 +137,16 @@ public function runIncludedWithCoverage(CliGuy $I)
         $I->seeInThisFile('Hobbit" namespace="');
     }
 
+    #[Before('moveToIncluded')]
+    #[Group('coverage')]
+    public function runIncludedWithoutPhpReport(CliGuy $I): void
+    {
+        $I->executeCommand('run --coverage-text --disable-coverage-php');
+        $I->amInPath('_log');
+        $I->seeFileFound('coverage.txt');
+        $I->cantSeeFileFound('coverage.serialized');
+    }
+
     #[Before('moveToIncluded')]
     public function buildIncluded(CliGuy $I)
     {