[wp-trac] [WordPress Trac] #53978: Non-static method 'get_default_primary_column_name' should not be called statically

WordPress Trac noreply at wordpress.org
Thu Feb 10 20:17:09 UTC 2022


#53978: Non-static method 'get_default_primary_column_name' should not be called
statically
---------------------------+-----------------------------------------------
 Reporter:                 |       Owner:  (none)
  volodymyrkolesnykov      |
     Type:  defect (bug)   |      Status:  closed
 Priority:  normal         |   Milestone:
Component:                 |     Version:  4.3
  Administration           |
 Severity:  normal         |  Resolution:  invalid
 Keywords:  dev-feedback   |     Focuses:  administration, coding-standards
---------------------------+-----------------------------------------------

Comment (by knutsp):

 Replying to [comment:8 jrf]:
 > I think there is a misconception here - using `self::`, `parent::` or
 `static::` for a method call does NOT make it a static method call.
 Calling a method using these keywords is about scope resolution in a class
 hierarchy, not about whether a method is declared as `static` or not.

 `::` is the static call operator, so I would say it's a static call. It
 is, however, allowed to call a non-static method statically from
 ''inside'' the class scope, even in PHP 8.0
 [https://php.watch/versions/8.0/non-static-static-call-fatal-error].

 See

 > It would be a static call if the method was called like so:
 `WP_List_Table::get_default_primary_column_name()`

 Indeed.

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


More information about the wp-trac mailing list