Make WordPress Core


Ignore:
Timestamp:
06/28/2015 03:26:41 PM (11 years ago)
Author:
jorbin
Message:

Deprecate php4 style constructors

PHP7 is deprecating PHP4 style constructors, so we need to modify our code to have _construct methods that fire before the named PHP4 style constructors. The PHP4 style constructors will call the PHP5 style constructor in case it is being called directly (usually via parent::METHOD).

This modifies external libraries to add PHP5 style constructors, but doesn't add a notice for when they are used. In WordPress core code, PHP4 style constructors are being given a call to _deprecated_constructor. To the PHP4 style constructor I say "I know that I can't take no more | It ain't no lie | I wanna see you out that door | Baby, bye, bye, bye..."

Upstream: ​https://wiki.php.net/rfc/remove_php4_constructors

Props jdgrimes, netweb, jorbin
See #31982

File:
1 edited

Legend:

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

    r24363 r32990  
    3434     *                           containing the lines from a file.
    3535     */
    36     function Text_Diff($engine, $params)
     36    function __construct( $engine, $params )
    3737    {
    3838        // Backward compatibility workaround.
    … …  
    5555        $this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params);
    5656    }
     57
     58        /**
     59         * PHP4 constructor.
     60         */
     61        public function Text_Diff( $engine, $params ) {
     62                self::__construct( $engine, $params );
     63        }
    5764
    5865    /**
    … …  
    305312     *                                  of elements as $to_lines.
    306313     */
    307     function Text_MappedDiff($from_lines, $to_lines,
     314    function __construct($from_lines, $to_lines,
    308315                             $mapped_from_lines, $mapped_to_lines)
    309316    {
    … …  
    329336    }
    330337
     338        /**
     339         * PHP4 constructor.
     340         */
     341        public function Text_MappedDiff( $from_lines, $to_lines,
     342                             $mapped_from_lines, $mapped_to_lines ) {
     343                self::__construct( $from_lines, $to_lines,
     344                             $mapped_from_lines, $mapped_to_lines );
     345        }
     346
    331347}
    332348
    … …  
    367383class Text_Diff_Op_copy extends Text_Diff_Op {
    368384
    369     function Text_Diff_Op_copy($orig, $final = false)
     385        /**
     386         * PHP5 constructor.
     387         */
     388    function __construct( $orig, $final = false )
    370389    {
    371390        if (!is_array($final)) {
    … …  
    376395    }
    377396
     397        /**
     398         * PHP4 constructor.
     399         */
     400        public function Text_Diff_Op_copy( $orig, $final = false ) {
     401                self::__construct( $orig, $final );
     402        }
     403
    378404    function &reverse()
    379405    {
    … …  
    392418class Text_Diff_Op_delete extends Text_Diff_Op {
    393419
    394     function Text_Diff_Op_delete($lines)
     420        /**
     421         * PHP5 constructor.
     422         */
     423        function __construct( $lines )
    395424    {
    396425        $this->orig = $lines;
    … …  
    398427    }
    399428
     429        /**
     430         * PHP4 constructor.
     431         */
     432        public function Text_Diff_Op_delete( $lines ) {
     433                self::__construct( $lines );
     434        }
     435
    400436    function &reverse()
    401437    {
    … …  
    414450class Text_Diff_Op_add extends Text_Diff_Op {
    415451
    416     function Text_Diff_Op_add($lines)
     452        /**
     453         * PHP5 constructor.
     454         */
     455    function __construct( $lines )
    417456    {
    418457        $this->final = $lines;
    … …  
    420459    }
    421460
     461        /**
     462         * PHP4 constructor.
     463         */
     464        public function Text_Diff_Op_add( $lines ) {
     465                self::__construct( $lines );
     466        }
     467
    422468    function &reverse()
    423469    {
    … …  
    436482class Text_Diff_Op_change extends Text_Diff_Op {
    437483
    438     function Text_Diff_Op_change($orig, $final)
     484        /**
     485         * PHP5 constructor.
     486         */
     487    function __construct( $orig, $final )
    439488    {
    440489        $this->orig = $orig;
    … …  
    442491    }
    443492
     493        /**
     494         * PHP4 constructor.
     495         */
     496        public function Text_Diff_Op_change( $orig, $final ) {
     497                self::__construct( $orig, $final );
     498        }
     499
    444500    function &reverse()
    445501    {
Note: See TracChangeset for help on using the changeset viewer.