Summary
When running the application on PHP 8.5, a notice is triggered regarding the deprecation of SplObjectStorage::contains().
Error Message
Method SplObjectStorage::contains() is deprecated since 8.5, use method SplObjectStorage::offsetExists() instead
Affected File
library/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php at line 88 (inside handleEnd).
Analysis
The SplObjectStorage class usage has changed in newer PHP versions. The contains method is being deprecated in favor of offsetExists.
Proposed Fix
Update the handleEnd method to use offsetExists.
Current Code (implied by error):
public function handleEnd(&$token)
{
if ($this->markForDeletion->contains($token)) {
$this->markForDeletion->detach($token);
$token = false;
}
}
Suggested Change:
public function handleEnd(&$token)
{
if ($this->markForDeletion->offsetExists($token)) {
$this->markForDeletion->offsetUnset($token);
$token = false;
}
}
Note: offsetUnset should also be used as detach is similarly affected, or for consistency with offsetExists.
And the same for line 77, markForDeletion->attach should be markForDeletion->offsetSet.
Summary
When running the application on PHP 8.5, a notice is triggered regarding the deprecation of
SplObjectStorage::contains().Error Message
Affected File
library/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.phpat line 88 (insidehandleEnd).Analysis
The
SplObjectStorageclass usage has changed in newer PHP versions. Thecontainsmethod is being deprecated in favor ofoffsetExists.Proposed Fix
Update the
handleEndmethod to useoffsetExists.Current Code (implied by error):
Suggested Change:
Note:
offsetUnsetshould also be used asdetachis similarly affected, or for consistency withoffsetExists.And the same for line 77,
markForDeletion->attachshould bemarkForDeletion->offsetSet.