Skip to content

Conversation

@deviantintegral
Copy link
Owner

The splitLogEntries() method was doing a shallow clone, which meant that modifying the cloned object's log entries also modified the original object's entries.

This commit implements __clone() methods in both Har and Log classes to ensure proper deep cloning:

  • Har::__clone() deep clones the Log object
  • Log::__clone() deep clones all object properties (Creator, Browser, Pages, Entries) with proper isset() checks to handle uninitialized properties

Added testCloneIsDeep() to verify that modifying a cloned Har object doesn't affect the original.

The splitLogEntries() method was doing a shallow clone, which meant that modifying the cloned object's log entries also modified the original object's entries. This commit implements __clone() methods in both Har and Log classes to ensure proper deep cloning: - Har::__clone() deep clones the Log object - Log::__clone() deep clones all object properties (Creator, Browser, Pages, Entries) with proper isset() checks to handle uninitialized properties Added testCloneIsDeep() to verify that modifying a cloned Har object doesn't affect the original.
Added testCloneBrowserIsDeep() to verify that the Browser object within the Log is properly deep cloned. This ensures that modifying the Browser in a cloned Har object doesn't affect the original.
@deviantintegral deviantintegral marked this pull request as ready for review December 15, 2025 21:22
@deviantintegral deviantintegral enabled auto-merge (squash) December 15, 2025 21:23
@deviantintegral deviantintegral merged commit 41bef31 into main Dec 15, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants