Make WordPress Core

Ticket #50897: 50897-fix-final-private-methods.patch

File 50897-fix-final-private-methods.patch, 2.5 KB (added by jrf, 6 years ago)
  • src/wp-includes/class-wp-session-tokens.php

    From a1ba777925d4846a406068b367bab207ab89b10f Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Tue, 11 Aug 2020 03:40:44 +0200
    Subject: [PATCH] PHP 8.0: fix final private methods
    
    Declaring a `private` method as `final` is an oxymoron, as `private` methods cannot be overloaded anyway.
    
    This will generate a warning in PHP 8.
    ---
     src/wp-includes/class-wp-session-tokens.php | 2 +-
     tests/phpunit/tests/user/capabilities.php   | 8 ++++----
     2 files changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/src/wp-includes/class-wp-session-tokens.php b/src/wp-includes/class-wp-session-tokens.php
    index 033add33c4..a1a779b236 100644
    a b abstract class WP_Session_Tokens {  
    6666         * @param string $token Session token to hash.
    6767         * @return string A hash of the session token (a verifier).
    6868         */
    69         final private function hash_token( $token ) {
     69        private function hash_token( $token ) {
    7070                // If ext/hash is not present, use sha1() instead.
    7171                if ( function_exists( 'hash' ) ) {
    7272                        return hash( 'sha256', $token );
  • tests/phpunit/tests/user/capabilities.php

    diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php
    index a5b7f3c55d..7a55db18d1 100644
    a b class Tests_User_Capabilities extends WP_UnitTestCase {  
    7373                return $meta_value;
    7474        }
    7575
    76         final private function _getSingleSitePrimitiveCaps() {
     76        private function _getSingleSitePrimitiveCaps() {
    7777                return array(
    7878
    7979                        'unfiltered_html'         => array( 'administrator', 'editor' ),
    class Tests_User_Capabilities extends WP_UnitTestCase {  
    155155
    156156        }
    157157
    158         final private function _getMultiSitePrimitiveCaps() {
     158        private function _getMultiSitePrimitiveCaps() {
    159159                return array(
    160160
    161161                        'unfiltered_html'         => array(),
    class Tests_User_Capabilities extends WP_UnitTestCase {  
    238238
    239239        }
    240240
    241         final private function _getSingleSiteMetaCaps() {
     241        private function _getSingleSiteMetaCaps() {
    242242                return array(
    243243                        'create_sites'                => array(),
    244244                        'delete_sites'                => array(),
    class Tests_User_Capabilities extends WP_UnitTestCase {  
    276276                );
    277277        }
    278278
    279         final private function _getMultiSiteMetaCaps() {
     279        private function _getMultiSiteMetaCaps() {
    280280                return array(
    281281                        'create_sites'                => array(),
    282282                        'delete_sites'                => array(),