https://bugzilla.wikimedia.org/show_bug.cgi?id=57585

       Web browser: ---
            Bug ID: 57585
           Summary: Overriding a method to change visibility classified as
                    ""Useless method overriding"
           Product: Wikimedia
           Version: wmf-deployment
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: Continuous integration
          Assignee: wikibugs-l@lists.wikimedia.org
          Reporter: s.mazel...@xs4all.nl
                CC: has...@free.fr, innocentkil...@gmail.com,
                    krinklem...@gmail.com
    Classification: Unclassified
   Mobile Platform: ---

In for example
https://gerrit.wikimedia.org/r/#/c/96456/2/includes/db/ORMTable.php, protected
DBAccessBase::releaseConnection is overridden as public
ORMTable::releaseConnection.

Running CodeSniffer on this, leads to a "useless method overriding" warning.
However, the visibility is intentional and valid, so CodeSniffer should not
warn.

Example code:

    <?php

    class DBAccessBase {
        protected function releaseConnection( DatabaseBase $db ) {
        }
    }

    class ORMTable extends DBAccessBase {
        public function releaseConnection( DatabaseBase $db ) {
            parent::releaseConnection( $db ); // just make it public
        }
    }

CodeSniffer output:

FILE: test.php
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
 9 | WARNING | Useless method overriding detected
   |         | (Generic.CodeAnalysis.UselessOverridingMethod.Found)
--------------------------------------------------------------------------------

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to