Skip to content

Instantly share code, notes, and snippets.

@sebastianbergmann
Created September 10, 2025 09:13
Show Gist options
  • Select an option

  • Save sebastianbergmann/19f8586b01a03868758ff8026d9a4181 to your computer and use it in GitHub Desktop.

Select an option

Save sebastianbergmann/19f8586b01a03868758ff8026d9a4181 to your computer and use it in GitHub Desktop.
diff --git a/src/CodeCoverage.php b/src/CodeCoverage.php
index 6976d7b8..ded2ebb2 100644
--- a/src/CodeCoverage.php
+++ b/src/CodeCoverage.php
@@ -78,23 +78,32 @@ public function __construct(Driver $driver, Filter $filter)
     }
 
     /**
-     * @return non-empty-list<non-empty-string>
+     * @return array{
+     *     cacheDirectory: ?string,
+     *     checkForUnintentionallyCoveredCode: bool,
+     *     includeUncoveredFiles: bool,
+     *     ignoreDeprecatedCode: bool,
+     *     parentClassesExcludedFromUnintentionallyCoveredCodeCheck: list<class-string>,
+     *     filter: Filter,
+     *     data: ProcessedCodeCoverageData,
+     *     tests: array<string, TestType>
+     * }
      */
-    public function __sleep(): array
+    public function __serialize(): array
     {
         return [
             // Configuration
-            'cacheDirectory',
-            'checkForUnintentionallyCoveredCode',
-            'includeUncoveredFiles',
-            'ignoreDeprecatedCode',
-            'parentClassesExcludedFromUnintentionallyCoveredCodeCheck',
-            'useAnnotationsForIgnoringCode',
-            'filter',
+            'cacheDirectory'                                           => $this->cacheDirectory,
+            'checkForUnintentionallyCoveredCode'                       => $this->checkForUnintentionallyCoveredCode,
+            'includeUncoveredFiles'                                    => $this->includeUncoveredFiles,
+            'ignoreDeprecatedCode'                                     => $this->ignoreDeprecatedCode,
+            'parentClassesExcludedFromUnintentionallyCoveredCodeCheck' => $this->parentClassesExcludedFromUnintentionallyCoveredCodeCheck,
+            'useAnnotationsForIgnoringCode'                            => $this->useAnnotationsForIgnoringCode,
+            'filter'                                                   => $this->filter,
 
             // Data
-            'data',
-            'tests',
+            'data'  => $this->data,
+            'tests' => $this->tests,
         ];
     }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment