Make Profiler::$instance private and drop double underscores
authorChad Horohoe <chadh@wikimedia.org>
Thu, 12 Feb 2015 20:53:39 +0000 (12:53 -0800)
committerChad Horohoe <chadh@wikimedia.org>
Thu, 12 Feb 2015 20:54:11 +0000 (12:54 -0800)
Nothing calls it anymore outside of the class

Change-Id: Icc9ebcd63e440f9bafca29647856d36fc493ff39

includes/profiler/Profiler.php

index 9bb2db9..4b74206 100644 (file)
@@ -48,10 +48,8 @@ abstract class Profiler {
                'udp' => 'ProfilerOutputUdp',
        );
 
-       // @codingStandardsIgnoreStart PSR2.Classes.PropertyDeclaration.Underscore
-       /** @var Profiler Do not call this outside Profiler and ProfileSection */
-       public static $__instance = null;
-       // @codingStandardsIgnoreEnd
+       /** @var Profiler */
+       private static $instance = null;
 
        /**
         * @param array $params
@@ -69,7 +67,7 @@ abstract class Profiler {
         * @return Profiler
         */
        final public static function instance() {
-               if ( self::$__instance === null ) {
+               if ( self::$instance === null ) {
                        global $wgProfiler;
                        if ( is_array( $wgProfiler ) ) {
                                $class = isset( $wgProfiler['class'] ) ? $wgProfiler['class'] : 'ProfilerStub';
@@ -77,12 +75,12 @@ abstract class Profiler {
                                if ( PHP_SAPI === 'cli' || mt_rand( 0, $factor - 1 ) != 0 ) {
                                        $class = 'ProfilerStub';
                                }
-                               self::$__instance = new $class( $wgProfiler );
+                               self::$instance = new $class( $wgProfiler );
                        } else {
-                               self::$__instance = new ProfilerStub( array() );
+                               self::$instance = new ProfilerStub( array() );
                        }
                }
-               return self::$__instance;
+               return self::$instance;
        }
 
        /**
@@ -93,10 +91,10 @@ abstract class Profiler {
         * @since 1.25
         */
        final public static function replaceStubInstance( Profiler $profiler ) {
-               if ( self::$__instance && !( self::$__instance instanceof ProfilerStub ) ) {
+               if ( self::$instance && !( self::$instance instanceof ProfilerStub ) ) {
                        throw new MWException( 'Could not replace non-stub profiler instance.' );
                } else {
-                       self::$__instance = $profiler;
+                       self::$instance = $profiler;
                }
        }