[wp-trac] [WordPress Trac] #56033: PHP 8.2: explicitly declare all known properties

WordPress Trac noreply at wordpress.org
Wed Aug 24 14:03:26 UTC 2022


#56033: PHP 8.2: explicitly declare all known properties
--------------------------------------------+-----------------------------
 Reporter:  jrf                             |       Owner:  SergeyBiryukov
     Type:  task (blessed)                  |      Status:  accepted
 Priority:  normal                          |   Milestone:  6.1
Component:  General                         |     Version:
 Severity:  normal                          |  Resolution:
 Keywords:  has-patch php82 has-unit-tests  |     Focuses:
--------------------------------------------+-----------------------------

Comment (by SergeyBiryukov):

 In [changeset:"53938" 53938]:
 {{{
 #!CommitTicketReference repository="" revision="53938"
 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.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56033#comment:71>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list