Make WordPress Core

Changeset 28511


Ignore:
Timestamp:
05/19/2014 05:49:22 AM (13 years ago)
Author:
wonderboymusic
Message:

Add access modifiers to methods/members in WP_Error. Add a magic __get() method for BC.

See #27881, #22234.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-error.php

    r24507 r28511  
    2727         * @access private
    2828         */
    29         var $errors = array();
     29        private $errors = array();
    3030
    3131        /**
    … …  
    3636         * @access private
    3737         */
    38         var $error_data = array();
     38        private $error_data = array();
    3939
    4040        /**
    … …  
    5555         * @return WP_Error
    5656         */
    57         function __construct($code = '', $message = '', $data = '') {
     57        public function __construct($code = '', $message = '', $data = '') {
    5858                if ( empty($code) )
    5959                        return;
    … …  
    6666
    6767        /**
     68         * Make private properties readable for backwards compatibility
     69         *
     70         * @since 4.0.0
     71         * @param string $name
     72         * @return mixed
     73         */
     74        public function __get( $name ) {
     75                return $this->$name;
     76        }
     77
     78        /**
    6879         * Retrieve all error codes.
    6980         *
    … …  
    7384         * @return array List of error codes, if available.
    7485         */
    75         function get_error_codes() {
     86        public function get_error_codes() {
    7687                if ( empty($this->errors) )
    7788                        return array();
    … …  
    8899         * @return string|int Empty string, if no error codes.
    89100         */
    90         function get_error_code() {
     101        public function get_error_code() {
    91102                $codes = $this->get_error_codes();
    92103
    … …  
    105116         * @return array Error strings on success, or empty array on failure (if using code parameter).
    106117         */
    107         function get_error_messages($code = '') {
     118        public function get_error_messages($code = '') {
    108119                // Return all messages if no code specified.
    109120                if ( empty($code) ) {
    … …  
    132143         * @return string
    133144         */
    134         function get_error_message($code = '') {
     145        public function get_error_message($code = '') {
    135146                if ( empty($code) )
    136147                        $code = $this->get_error_code();
    … …  
    149160         * @return mixed Null, if no errors.
    150161         */
    151         function get_error_data($code = '') {
     162        public function get_error_data($code = '') {
    152163                if ( empty($code) )
    153164                        $code = $this->get_error_code();
    … …  
    168179         * @param mixed $data Optional. Error data.
    169180         */
    170         function add($code, $message, $data = '') {
     181        public function add($code, $message, $data = '') {
    171182                $this->errors[$code][] = $message;
    172183                if ( ! empty($data) )
    … …  
    184195         * @param string|int $code Error code.
    185196         */
    186         function add_data($data, $code = '') {
     197        public function add_data($data, $code = '') {
    187198                if ( empty($code) )
    188199                        $code = $this->get_error_code();
Note: See TracChangeset for help on using the changeset viewer.