From 07a0b365627011f95692d2858691b2bedd5596f5 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Tue, 10 Jan 2023 14:00:36 +0000 Subject: [PATCH] I18N: Initialize `WP_Locale` array properties. Initializing the `WP_Locale` array properties to an empty array at the class definition point. Why? * Ensure the properties initialize to an `array` data type at instantiation (rather than `null`). This initialization is needed to ensure the properties are not `null` if another class inherits from `WP_Locale` but does not run `WP_Locale::init()` from the constructor. In this case, the initialization prevents {{{ Warning: array_values() expects parameter 1 to be array, null given }}} when Core uses any of the properties. * Good design practice. The code and documentation are clearly expecting these properties to be an `array` data type. Setting each to a default `array()` state further helps to clearly communicate the code design. Follow-up to [37889], [36292], [31078], [3676], [6589]. Props tyxla, SergeyBiryukov, azaozz, hellofromTonya, mukesh27. See #57427. Built from https://develop.svn.wordpress.org/trunk@55047 git-svn-id: http://core.svn.wordpress.org/trunk@54580 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-locale.php | 24 ++++++++++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/wp-includes/class-wp-locale.php b/wp-includes/class-wp-locale.php index b001a09964..ea8b67c987 100644 --- a/wp-includes/class-wp-locale.php +++ b/wp-includes/class-wp-locale.php @@ -19,9 +19,10 @@ class WP_Locale { * Stores the translated strings for the full weekday names. * * @since 2.1.0 + * @since 6.2.0 Initialized to an empty array. * @var string[] */ - public $weekday; + public $weekday = array(); /** * Stores the translated strings for the one character weekday names. @@ -32,41 +33,46 @@ class WP_Locale { * @see WP_Locale::init() for how to handle the hack. * * @since 2.1.0 + * @since 6.2.0 Initialized to an empty array. * @var string[] */ - public $weekday_initial; + public $weekday_initial = array(); /** * Stores the translated strings for the abbreviated weekday names. * * @since 2.1.0 + * @since 6.2.0 Initialized to an empty array. * @var string[] */ - public $weekday_abbrev; + public $weekday_abbrev = array(); /** * Stores the translated strings for the full month names. * * @since 2.1.0 + * @since 6.2.0 Initialized to an empty array. * @var string[] */ - public $month; + public $month = array(); /** * Stores the translated strings for the month names in genitive case, if the locale specifies. * * @since 4.4.0 + * @since 6.2.0 Initialized to an empty array. * @var string[] */ - public $month_genitive; + public $month_genitive = array(); /** * Stores the translated strings for the abbreviated month names. * * @since 2.1.0 + * @since 6.2.0 Initialized to an empty array. * @var string[] */ - public $month_abbrev; + public $month_abbrev = array(); /** * Stores the translated strings for 'am' and 'pm'. @@ -74,9 +80,10 @@ class WP_Locale { * Also the capitalized versions. * * @since 2.1.0 + * @since 6.2.0 Initialized to an empty array. * @var string[] */ - public $meridiem; + public $meridiem = array(); /** * The text direction of the locale language. @@ -92,9 +99,10 @@ class WP_Locale { * The thousands separator and decimal point values used for localizing numbers. * * @since 2.3.0 + * @since 6.2.0 Initialized to an empty array. * @var array */ - public $number_format; + public $number_format = array(); /** * The separator string used for localizing list item separator. diff --git a/wp-includes/version.php b/wp-includes/version.php index 3f83875497..bc296d727d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55046'; +$wp_version = '6.2-alpha-55047'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.