Make WordPress Core

Changeset 53938


Ignore:
Timestamp:
08/24/2022 02:03:12 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Remove dynamic properties in Tests_Comment_Walker.

Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this test file, the Tests_Comment_Walker::set_up() method created a dynamic $post_id property, which should have been explicitly declared.

Along the same lines, the Comment_Callback_Test::__construct() method also assigned values to two undeclared properties.

This is now fixed by explicitly declaring the properties in both classes.

Includes renaming the Comment_Callback_Test class to Comment_Callback_Test_Helper as it does not contain any test methods and its only purpose is as a “helper” class for the Tests_Comment_Walker::test_has_children() test.

Follow-up to [28824], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937].

Props jrf.
See #56033.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/walker.php

    r53863 r53938  
    77 */
    88class Tests_Comment_Walker extends WP_UnitTestCase {
     9
     10        /**
     11         * Comment post ID.
     12         *
     13         * @var int
     14         */
     15        private $post_id;
    916
    1017        public function set_up() {
     
    2936
    3037                $comment_walker   = new Walker_Comment();
    31                 $comment_callback = new Comment_Callback_Test( $this, $comment_walker );
     38                $comment_callback = new Comment_Callback_Test_Helper( $this, $comment_walker );
    3239
    3340                wp_list_comments(
     
    5057}
    5158
    52 class Comment_Callback_Test {
     59class Comment_Callback_Test_Helper {
     60        private $test_walker;
     61        private $walker;
     62
    5363        public function __construct( Tests_Comment_Walker $test_walker, Walker_Comment $walker ) {
    5464                $this->test_walker = $test_walker;
Note: See TracChangeset for help on using the changeset viewer.