Code Modernization: Use explicit visibility for class property declarations.

Using `var` or only `static` to declare a class property is PHP 4 code.

This updates the codebase to use explicit visibility modifiers introduced in PHP 5.

Props jrf.
Fixes #51557. See #22234.

git-svn-id: https://develop.svn.wordpress.org/trunk@49184 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-10-17 16:24:35 +00:00
parent 5b6a20af07
commit 5bad4e7f8d
38 changed files with 120 additions and 120 deletions

View File

@@ -1,7 +1,7 @@
<?php
class WP_UnitTest_Generator_Sequence {
static $incr = -1;
public static $incr = -1;
public $next;
public $template_string;

View File

@@ -3,7 +3,7 @@ require_once ABSPATH . 'wp-includes/PHPMailer/PHPMailer.php';
require_once ABSPATH . 'wp-includes/PHPMailer/Exception.php';
class MockPHPMailer extends PHPMailer\PHPMailer\PHPMailer {
var $mock_sent = array();
public $mock_sent = array();
function preSend() {
$this->Encoding = '8bit';

View File

@@ -1,13 +1,13 @@
<?php
class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
static $old_current_user;
static $author_id;
static $post_ids = array();
static $comment_ids = array();
static $term_ids = array();
static $terms = array();
static $old_options = array();
public static $old_current_user;
public static $author_id;
public static $post_ids = array();
public static $comment_ids = array();
public static $term_ids = array();
public static $terms = array();
public static $old_options = array();
/**
* This can be defined in a subclass of this class which contains its own data() method.

View File

@@ -38,8 +38,8 @@ function strip_ws( $txt ) {
* add_action( 'foo', array( &$ma, 'action' ) );
*/
class MockAction {
var $events;
var $debug;
public $events;
public $debug;
/**
* PHP5 constructor.
@@ -184,8 +184,8 @@ class MockAction {
// Convert valid XML to an array tree structure.
// Kinda lame, but it works with a default PHP 4 installation.
class TestXMLParser {
var $xml;
var $data = array();
public $xml;
public $data = array();
/**
* PHP5 constructor.

View File

@@ -5,7 +5,7 @@
* @group adminScreen
*/
class Tests_Admin_includesScreen extends WP_UnitTestCase {
var $core_screens = array(
public $core_screens = array(
'index.php' => array(
'base' => 'dashboard',
'id' => 'dashboard',

View File

@@ -4,7 +4,7 @@
* @group cache
*/
class Tests_Cache extends WP_UnitTestCase {
var $cache = null;
public $cache = null;
function setUp() {
parent::setUp();

View File

@@ -9,9 +9,9 @@
* @group feed
*/
class Tests_Feeds_Atom extends WP_UnitTestCase {
static $user_id;
static $posts;
static $category;
public static $user_id;
public static $posts;
public static $category;
/**
* Setup a new user and attribute some posts.

View File

@@ -9,10 +9,10 @@
* @group feed
*/
class Tests_Feeds_RSS2 extends WP_UnitTestCase {
static $user_id;
static $posts;
static $category;
static $post_date;
public static $user_id;
public static $posts;
public static $category;
public static $post_date;
/**
* Setup a new user and attribute some posts.

View File

@@ -8,8 +8,8 @@
* @covers ::wp_list_pluck
*/
class Tests_Functions_wpListFilter extends WP_UnitTestCase {
var $object_list = array();
var $array_list = array();
public $object_list = array();
public $array_list = array();
function setUp() {
parent::setUp();

View File

@@ -12,8 +12,8 @@
*/
abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
// You can use your own version of data/WPHTTP-testcase-redirection-script.php here.
var $redirection_script = 'http://api.wordpress.org/core/tests/1.0/redirection.php';
var $file_stream_url = 'http://s.w.org/screenshots/3.9/dashboard.png';
public $redirection_script = 'http://api.wordpress.org/core/tests/1.0/redirection.php';
public $file_stream_url = 'http://s.w.org/screenshots/3.9/dashboard.png';
protected $http_request_args;

View File

@@ -7,7 +7,7 @@ require_once __DIR__ . '/base.php';
* @group external-http
*/
class Tests_HTTP_curl extends WP_HTTP_UnitTestCase {
var $transport = 'curl';
public $transport = 'curl';
/**
* @ticket 39783

View File

@@ -7,5 +7,5 @@ require_once __DIR__ . '/base.php';
* @group external-http
*/
class Tests_HTTP_streams extends WP_HTTP_UnitTestCase {
var $transport = 'streams';
public $transport = 'streams';
}

View File

@@ -6,7 +6,7 @@ require_once ABSPATH . 'wp-admin/includes/class-custom-image-header.php';
* @group header
*/
class Tests_Image_Header extends WP_UnitTestCase {
var $custom_image_header;
public $custom_image_header;
function setUp() {
parent::setUp();

View File

@@ -4,7 +4,7 @@
* @group link
*/
class Tests_Link_GetDashboardUrl extends WP_UnitTestCase {
static $user_id = false;
public static $user_id = false;
public static function wpSetUpBeforeClass( $factory ) {
self::$user_id = $factory->user->create( array( 'role' => 'administrator' ) );

View File

@@ -12,7 +12,7 @@ if ( is_multisite() ) :
/**
* @var WP_MS_Sites_List_Table
*/
var $table = false;
public $table = false;
function setUp() {
parent::setUp();

View File

@@ -3,9 +3,9 @@
* @group query
*/
class Tests_Query_CommentCount extends WP_UnitTestCase {
static $post_ids = array();
public static $post_ids = array();
public $q;
static $post_type = 'page'; // Can be anything.
public static $post_type = 'page'; // Can be anything.
public function setUp() {
parent::setUp();

View File

@@ -10,7 +10,7 @@ class Tests_Query_Date extends WP_UnitTestCase {
public $q;
static $post_ids = array();
public static $post_ids = array();
public static function wpSetUpBeforeClass( $factory ) {
// Be careful modifying this. Tests are coded to expect this exact sample data.

View File

@@ -9,17 +9,17 @@
class Tests_Query_Results extends WP_UnitTestCase {
protected $q;
static $cat_ids = array();
static $tag_ids = array();
static $post_ids = array();
public static $cat_ids = array();
public static $tag_ids = array();
public static $post_ids = array();
static $parent_one;
static $parent_two;
static $parent_three;
static $child_one;
static $child_two;
static $child_three;
static $child_four;
public static $parent_one;
public static $parent_two;
public static $parent_three;
public static $child_one;
public static $child_two;
public static $child_three;
public static $child_four;
public static function wpSetUpBeforeClass( $factory ) {
$cat_a = $factory->term->create(

View File

@@ -6,7 +6,7 @@
* @group query
*/
class Tests_Query_Stickies extends WP_UnitTestCase {
static $posts = array();
public static $posts = array();
public static function wpSetUpBeforeClass( $factory ) {
// Set post times to get a reliable order.

View File

@@ -4,7 +4,7 @@
*/
class Tests_Theme_Custom_Header extends WP_UnitTestCase {
static $post;
public static $post;
protected static $header_video_id;

View File

@@ -5,7 +5,7 @@
*/
class Tests_Upload extends WP_UnitTestCase {
var $siteurl;
public $siteurl;
function setUp() {
$this->_reset_options();

View File

@@ -5,8 +5,8 @@
* @group post
*/
class Tests_User_CountUserPosts extends WP_UnitTestCase {
static $user_id;
static $post_ids = array();
public static $user_id;
public static $post_ids = array();
public static function wpSetUpBeforeClass( $factory ) {
self::$user_id = $factory->user->create(

View File

@@ -10,7 +10,7 @@ if ( is_multisite() ) :
* @group multisite
*/
class Tests_Multisite_getActiveBlogForUser extends WP_UnitTestCase {
static $user_id = false;
public static $user_id = false;
public static function wpSetUpBeforeClass( $factory ) {
self::$user_id = $factory->user->create();

View File

@@ -4,10 +4,10 @@
* @group user
*/
class Tests_User_ListAuthors extends WP_UnitTestCase {
static $user_ids = array();
static $fred_id;
static $posts = array();
static $user_urls = array();
public static $user_ids = array();
public static $fred_id;
public static $posts = array();
public static $user_urls = array();
/* Defaults
'orderby' => 'name',
'order' => 'ASC',

View File

@@ -286,8 +286,8 @@ class Tests_Walker extends WP_UnitTestCase {
class Walker_Test extends Walker {
var $tree_type = 'test';
var $db_fields = array(
public $tree_type = 'test';
public $db_fields = array(
'parent' => 'parent',
'id' => 'id',
);

View File

@@ -4,7 +4,7 @@
* @group xmlrpc
*/
class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase {
var $post_id;
public $post_id;
function test_invalid_username_password() {
$result = $this->myxmlrpcserver->wp_getComments( array( 1, 'username', 'password', array() ) );

View File

@@ -6,8 +6,8 @@
class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase {
protected static $post_id;
var $attachment_data;
var $attachment_id;
public $attachment_data;
public $attachment_id;
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
self::$post_id = $factory->post->create();

View File

@@ -4,10 +4,10 @@
* @group xmlrpc
*/
class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase {
var $post_data;
var $post_id;
var $post_date_ts;
var $post_custom_field;
public $post_data;
public $post_id;
public $post_date_ts;
public $post_custom_field;
function setUp() {
parent::setUp();

View File

@@ -4,8 +4,8 @@
* @group xmlrpc
*/
class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase {
var $cpt_name;
var $cpt_args;
public $cpt_name;
public $cpt_args;
function setUp() {
parent::setUp();

View File

@@ -4,8 +4,8 @@
* @group xmlrpc
*/
class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase {
var $post_id;
var $revision_id;
public $post_id;
public $revision_id;
function setUp() {
parent::setUp();