Skip to content

[4.x] Use array access on SplObjectStorage instead of the methods deprecated in PHP 8.5 - #42

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-splobjectstorage-array-access
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-splobjectstorage-array-access

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

PHP 8.5 deprecates SplObjectStorage::attach() and SplObjectStorage::contains(). DataObject::dump(), DataObject::dumpProperty() and DataSet::dump() use them to track already-dumped objects, so every dump() (and every json_encode() of a DataObject) emits deprecation notices on PHP 8.5, and the calls will fail on PHP 9.

They are replaced by array access ($dumped[$this] = null, isset($dumped[$value])), i.e. offsetSet()/offsetExists(), which PHP recommends as the replacement and which behave the same on every supported PHP version. No behaviour change, so this goes to 4.x rather than waiting for 5.0.

Testing Instructions

DataObjectTest::testDumpTriggersNoDeprecations() dumps an object with nested objects (one of them twice) and a DataSet, and collects E_DEPRECATED notices. On PHP 8.5 it fails before the change (notices from attach()/contains()) and passes after; on PHP 8.3/8.4 it passes either way. Run e.g. php8.5 vendor/bin/phpunit --filter testDumpTriggersNoDeprecations.

Documentation Changes Required

None (no behaviour change).

🤖 Generated with Claude Code

PHP 8.5 deprecates SplObjectStorage::attach() and contains(), so every
dump() of a DataObject or DataSet emitted deprecation notices there.
offsetSet()/offsetExists() through array access are equivalent and
available on all supported PHP versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Hackwar
Hackwar force-pushed the 4.x-splobjectstorage-array-access branch from 9682e3a to f086363 Compare November 12, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant