WordPress.org

Make WordPress Core

Changeset 28525


Ignore:
Timestamp:
05/19/2014 03:22:45 PM (7 years ago)
Author:
wonderboymusic
Message:

Add access modifiers to WP_Text_Diff_Renderer_Table that are compatible with its parent class. Some of the inline docs suggest access that, if implemented, would produce fatal errors.

Add magic methods for BC: get(), set(), isset(), unset(), and call().

See #27881, #22234.

File:
1 edited

Legend:

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

    r26051 r28525  
    2929     * @see Text_Diff_Renderer::_leading_context_lines
    3030     * @var int
    31      * @access protected
    32      * @since 2.6.0
    33      */
    34     var $_leading_context_lines  = 10000;
     31     * @access public
     32     * @since 2.6.0
     33     */
     34    public $_leading_context_lines  = 10000;
    3535
    3636    /**
    3737     * @see Text_Diff_Renderer::_trailing_context_lines
    3838     * @var int
    39      * @access protected
    40      * @since 2.6.0
    41      */
    42     var $_trailing_context_lines = 10000;
     39     * @access public
     40     * @since 2.6.0
     41     */
     42    public $_trailing_context_lines = 10000;
    4343
    4444    /**
     
    4949     * @since 2.6.0
    5050     */
    51     var $_diff_threshold = 0.6;
     51    protected $_diff_threshold = 0.6;
    5252
    5353    /**
     
    5858     * @since 2.6.0
    5959     */
    60     var $inline_diff_renderer = 'WP_Text_Diff_Renderer_inline';
     60    protected $inline_diff_renderer = 'WP_Text_Diff_Renderer_inline';
    6161
    6262    /**
     
    6767     * @since 3.6.0
    6868     */
    69     var $_show_split_view = true;
     69    protected $_show_split_view = true;
    7070
    7171    /**
     
    7878     * @param array $params
    7979     */
    80     function __construct( $params = array() ) {
     80    public function __construct( $params = array() ) {
    8181        parent::__construct( $params );
    8282        if ( isset( $params[ 'show_split_view' ] ) )
     
    9090     * @return string
    9191     */
    92     function _startBlock( $header ) {
     92    public function _startBlock( $header ) {
    9393        return '';
    9494    }
     
    100100     * @param string $prefix
    101101     */
    102     function _lines( $lines, $prefix=' ' ) {
     102    public function _lines( $lines, $prefix=' ' ) {
    103103    }
    104104
     
    109109     * @return string
    110110     */
    111     function addedLine( $line ) {
     111    public function addedLine( $line ) {
    112112        return "<td class='diff-addedline'>{$line}</td>";
    113113
     
    120120     * @return string
    121121     */
    122     function deletedLine( $line ) {
     122    public function deletedLine( $line ) {
    123123        return "<td class='diff-deletedline'>{$line}</td>";
    124124    }
     
    130130     * @return string
    131131     */
    132     function contextLine( $line ) {
     132    public function contextLine( $line ) {
    133133        return "<td class='diff-context'>{$line}</td>";
    134134    }
     
    139139     * @return string
    140140     */
    141     function emptyLine() {
     141    public function emptyLine() {
    142142        return '<td>&nbsp;</td>';
    143143    }
     
    145145    /**
    146146     * @ignore
    147      * @access private
     147     * @access public
    148148     *
    149149     * @param array $lines
     
    151151     * @return string
    152152     */
    153     function _added( $lines, $encode = true ) {
     153    public function _added( $lines, $encode = true ) {
    154154        $r = '';
    155155        foreach ($lines as $line) {
     
    167167    /**
    168168     * @ignore
    169      * @access private
     169     * @access public
    170170     *
    171171     * @param array $lines
     
    173173     * @return string
    174174     */
    175     function _deleted( $lines, $encode = true ) {
     175    public function _deleted( $lines, $encode = true ) {
    176176        $r = '';
    177177        foreach ($lines as $line) {
     
    190190    /**
    191191     * @ignore
    192      * @access private
     192     * @access public
    193193     *
    194194     * @param array $lines
     
    196196     * @return string
    197197     */
    198     function _context( $lines, $encode = true ) {
     198    public function _context( $lines, $encode = true ) {
    199199        $r = '';
    200200        foreach ($lines as $line) {
     
    216216     * We do additional processing to figure that out
    217217     *
    218      * @access private
     218     * @access public
    219219     * @since 2.6.0
    220220     *
     
    223223     * @return string
    224224     */
    225     function _changed( $orig, $final ) {
     225    public function _changed( $orig, $final ) {
    226226        $r = '';
    227227
     
    314314     * @return unknown
    315315     */
    316     function interleave_changed_lines( $orig, $final ) {
     316    public function interleave_changed_lines( $orig, $final ) {
    317317
    318318        // Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array.
     
    403403     * @return int
    404404     */
    405     function compute_string_distance( $string1, $string2 ) {
     405    public function compute_string_distance( $string1, $string2 ) {
    406406        // Vectors containing character frequency for all chars in each string
    407407        $chars1 = count_chars($string1);
     
    427427     * @return int
    428428     */
    429     function difference( $a, $b ) {
     429    public function difference( $a, $b ) {
    430430        return abs( $a - $b );
    431431    }
    432432
     433    /**
     434     * Make private properties readable for backwards compatibility
     435     *
     436     * @since 4.0.0
     437     * @param string $name
     438     * @return mixed
     439     */
     440    public function __get( $name ) {
     441        return $this->$name;
     442    }
     443
     444    /**
     445     * Make private properties setable for backwards compatibility
     446     *
     447     * @since 4.0.0
     448     * @param string $name
     449     * @param string $value
     450     * @return mixed
     451     */
     452    public function __set( $name, $value ) {
     453        return $this->$name = $value;
     454    }
     455
     456    /**
     457     * Make private properties checkable for backwards compatibility
     458     *
     459     * @since 4.0.0
     460     * @param string $name
     461     * @return mixed
     462     */
     463    public function __isset( $name ) {
     464        return isset( $this->$name );
     465    }
     466
     467    /**
     468     * Make private properties unsetable for backwards compatibility
     469     *
     470     * @since 4.0.0
     471     * @param string $name
     472     * @return mixed
     473     */
     474    public function __unset( $name ) {
     475        unset( $this->$name );
     476    }
     477
     478    /**
     479     * Make private/protected methods readable for backwards compatibility
     480     *
     481     * @since 4.0.0
     482     * @param string $name
     483     * @param array $arguments
     484     * @return mixed
     485     */
     486    public function __call( $name, $arguments ) {
     487        return call_user_func_array( array( $this, $name ), $arguments );
     488    }
    433489}
    434490
     
    449505     * @return string
    450506     */
    451     function _splitOnWords($string, $newlineEscape = "\n") {
     507    public function _splitOnWords($string, $newlineEscape = "\n") {
    452508        $string = str_replace("\0", '', $string);
    453509        $words  = preg_split( '/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
Note: See TracChangeset for help on using the changeset viewer.