fix(diagnostics): declare $cleanDiagnostics property - #136
Open
faisalahammad wants to merge 1 commit into
Open
Conversation
Fixes PHP 8.3 'Creation of dynamic property' deprecation warning emitted by the diagnostic AJAX class on every WP_DEBUG request. PHP 8.3 deprecates assigning to an undeclared class property; PHP 8.4 escalates the same notice to a fatal error. The class already declared three siblings at the top of the file but $cleanDiagnostics was only assigned in the constructor, leaving the rest of the file (line 176, line 348) to rely on the implicit dynamic property. Adding the declaration next to its siblings silences the warning with no behaviour change. Fixes wpexpertsio#126
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.
Summary
Fixes the PHP 8.3 deprecation notice emitted on every diagnostic AJAX request:
Deprecated: Creation of dynamic property PostmanGetDiagnosticsViaAjax::$cleanDiagnostics is deprecated. The class assigned to the property in its constructor without declaring it, so PHP 8.3 flags it and PHP 8.4 would escalate it to a fatal error.\nFixes #126
Changes
Postman/Postman-Diagnostic-Test/PostmanDiagnosticTestController.phpBefore:
After:
Why: The constructor at line 170 assigns
$this->cleanDiagnostics = '';without a matching declaration, so every call creates the property dynamically. Adding the declaration next to its siblings silences the deprecation without changing behaviour. All existing usage at lines 170, 176, and 348 still works.Testing
PHP 8.3 + WP_DEBUG
wp-adminand confirmwp-content/debug.logcontains the "Creation of dynamic property" deprecation line.post_smtp_clean_diagnostic_report_dataoption is still populated with the diagnostic text as before.\nTested manually against a WordPress 6.8.1 install on PHP 8.3.