Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#50897 closed defect (bug) (fixed)

PHP 8: fix final private methods

Reported by: jrf's profile jrf Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.6 Priority: normal
Severity: minor Version:
Component: General Keywords: has-patch php8 has-unit-tests has-dev-note
Focuses: coding-standards Cc:

Description

Declaring a private method as final is an oxymoron, as private methods cannot be overloaded anyway.

Using final private function... will generate a warning in PHP 8.

The attached patch fixes all known instances of this in WP Core at the time of writing.

Attachments (1)

50897-fix-final-private-methods.patch (2.5 KB) - added by jrf 4 years ago.

Download all attachments as: .zip

Change History (8)

#1 @johnbillion
4 years ago

  • Milestone changed from Awaiting Review to 5.6

This ticket was mentioned in PR #467 on WordPress/wordpress-develop by jrfnl.


4 years ago
#2

  • Keywords has-unit-tests added

Declaring a private method as final is an oxymoron, as private methods cannot be overloaded anyway.

This will generate a warning in PHP 8.

Trac ticket: https://core.trac.wordpress.org/ticket/50897

#3 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#4 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 48788:

Code Modernization: Remove final keyword from private methods.

Declaring a private method as final is an oxymoron, as private methods cannot be overloaded anyway.

Using final private function... will generate a warning in PHP 8.

Props jrf.
Fixes #50897.

jrfnl commented on PR #467:


4 years ago
#5

Patch has been committed. Closing.

#6 @desrosj
4 years ago

  • Keywords needs-dev-note added

Adding needs-dev-note to include in the PHP 8 developer note.

#7 @daisyo
3 years ago

  • Keywords has-dev-note added; needs-dev-note removed
Note: See TracTickets for help on using tickets.