PHP8.4: Replace xml_set_object() with callable arrays in Translate ad…#534
Merged
develart-projects merged 2 commits intoShardj:masterfrom Mar 25, 2026
Merged
Conversation
…apters Remove deprecated xml_set_object() from Tmx, Tbx, Qt, Xliff, and XmlTm adapters, replacing string method references with [$this, '_method'] callables. No public API or behaviour changed.
|
... |
3763694 to
0148584
Compare
Author
|
PR is ready for review. Thanks @sreichel for the phpstan support. |
sreichel
approved these changes
Mar 25, 2026
addison74
approved these changes
Mar 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix PHP 8.4 deprecation: replace
xml_set_object()with callable arrays in Translate adaptersSummary
PHP 8.4 deprecated
xml_set_object()(PHP RFC), causing deprecation warnings when using any of the XML-based translation adapters. This PR removes the deprecated call across all affected adapters and replaces string-based method references with proper callable arrays.Changes
Removed
xml_set_object($parser, $this)and updated the string method names passed toxml_set_element_handler()andxml_set_character_data_handler()to use[$this, '_methodName']callables in:library/Zend/Translate/Adapter/Tmx.phplibrary/Zend/Translate/Adapter/Tbx.phplibrary/Zend/Translate/Adapter/Qt.phplibrary/Zend/Translate/Adapter/Xliff.phplibrary/Zend/Translate/Adapter/XmlTm.phpBefore:
After:
Backwards Compatibility
This change is fully backwards compatible:
[$object, 'method']) have been valid since PHP 5.3.0 — well before any PHP version this library targets.xml_set_*_handler()functions have accepted any valid PHP callable (including callable arrays) since PHP 4. Passing a callable array was always the more correct approach;xml_set_object()was merely a convenience that allowed passing bare strings as shorthand.xml_set_object()is deprecated in PHP 8.4, not removed. Existing installations on PHP ≤ 8.3 are unaffected by this change in behaviour; they simply no longer emit the deprecation notice.Testing
Existing unit tests for the affected adapters cover this change. No new tests are required as the observable behaviour is identical.