Skip to content

Commit 03c04a9

Browse files
authored
fix: replace deprecated ArrayAccess methods (attach/detach/contains) for PHP 8.5 compatibility
1 parent b287d2a commit 03c04a9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

library/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public function handleElement(&$token)
7474

7575
if ($current instanceof HTMLPurifier_Token_End && $current->name === 'span') {
7676
// Mark closing span tag for deletion
77-
$this->markForDeletion->attach($current);
77+
// PHP 8.5 compatiblity: replaced attach() with offsetSet()
78+
$this->markForDeletion->offsetSet($current);
7879
// Delete open span tag
7980
$token = false;
8081
}
@@ -85,8 +86,11 @@ public function handleElement(&$token)
8586
*/
8687
public function handleEnd(&$token)
8788
{
88-
if ($this->markForDeletion->contains($token)) {
89-
$this->markForDeletion->detach($token);
89+
// PHP 8.5 compatiblity:
90+
// replaced contains() with offsetExists()
91+
// replaced detach() with offsetUnset()
92+
if ($this->markForDeletion->offsetExists($token)) {
93+
$this->markForDeletion->offsetUnset($token);
9094
$token = false;
9195
}
9296
}

0 commit comments

Comments
 (0)