mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Code Modernization: Use correct property in IXR_Message::tag_open().
The `IXR_Message` class declares a property `_currentTag`, which is never assigned or used. It does assign to `currentTag` instead, which outside of that one assignment is never used either.
Since there are various other underscore-prefixed properties declared on the class, including one named `_currentTagContents` which is used in several places, it appears that the declared property is correct and the assignment is a typo.
This commit resolves a notice on PHP 8.2:
{{{
Deprecated: Creation of dynamic property IXR_Message::$currentTag is deprecated
}}}
Follow-up to [1346].
Props bjorsch, kraftbj, jrf, mukesh27, SergeyBiryukov.
See #56790.
git-svn-id: https://develop.svn.wordpress.org/trunk@55105 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d6afa281b6
commit
675fe390b9
@ -144,7 +144,7 @@ class IXR_Message
|
||||
function tag_open($parser, $tag, $attr)
|
||||
{
|
||||
$this->_currentTagContents = '';
|
||||
$this->currentTag = $tag;
|
||||
$this->_currentTag = $tag;
|
||||
switch($tag) {
|
||||
case 'methodCall':
|
||||
case 'methodResponse':
|
||||
|
||||
34
tests/phpunit/tests/xmlrpc/message.php
Normal file
34
tests/phpunit/tests/xmlrpc/message.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Unit tests covering IXR_Message functionality.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage IXR
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test wp-includes/IXR/class-IXR-message.php
|
||||
*
|
||||
* @group xmlrpc
|
||||
*/
|
||||
class Tests_XMLRPC_Message extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests that `IXR_Message::tag_open()` does not create a dynamic `currentTag` property,
|
||||
* and uses the declared `_currentTag` property instead.
|
||||
*
|
||||
* The notice that we should not see:
|
||||
* `Deprecated: Creation of dynamic property IXR_Message::$currentTag is deprecated`.
|
||||
*
|
||||
* @ticket 56033
|
||||
*
|
||||
* @covers IXR_Message::tag_open
|
||||
*/
|
||||
public function test_tag_open_does_not_create_dynamic_property() {
|
||||
$message = new IXR_Message( '<methodResponse><params><param><value>1</value></param></params></methodResponse>' );
|
||||
$this->assertTrue( $message->parse() );
|
||||
$this->assertSame( 'methodResponse', $message->messageType ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
|
||||
$this->assertSame( array( '1' ), $message->params );
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user