title: Assigning a Static Class to a Local Variable
body: <p>So, in PHP, I know that static classes exist in the Global namespace, and thus cause overhead when having to call them.</p>
  
  <p>But what happens when you assign a local class variable, or just a local variable, to that static class? Is the overhead of the Global reference removed?</p>
  
  <p>In my specific case, I'm using a static singleton.</p>
  
  <pre><code>class Registry {
  
       public static $user;
       public static $DB;
       public static $config;
       public static $user_data;
       private static $initialized = FALSE;
  
       public static function init($config) {
            if (!registry::$initialized) {
                 registry::$config = $config;
                 registry::$DB = new db($config['mysql']);
                 registry::$user = new user();
                 registry::$initialized = TRUE;
            } else {
                 throw new Exception('Registry has already been initialized.');
            }
       }
  }
  </code></pre>
  
  <p>Now, to make the question clearer, would it be beneficial to map the Registry in another class to a class variable/local variable for successive function calls?</p>
  
  <pre><code>class SomethingSomethingDarkSide {
  
       private $registry;
       private $db;
       private $config;
  
       public function __construct() {
            $this-&gt;registry = Registry;
            $this-&gt;db = Registry::$db;
            $this-&gt;config = Registry::$config;
       }
  }
  </code></pre>
  
  <p>Since the static members are now assigned to a class variable after it's been initialized, would calling successive methods that utilize those class variables remove the overhead of the Global namespace that persist with static members?</p>
  
  <p><strong>EDIT: Please remove the idea of Singleton in this case. The question is more about whether we have to look up <code>Registry</code> each time after its been referenced to a variable.</strong></p>
  
  <p>IE:</p>
  
  <pre><code>$registry = Registry;
  $registry::doSomething();
  $registry::doSomething2();
  $registry::doSomething3();
  </code></pre>
  
  <p>vs.</p>
  
  <pre><code>Registry::doSomething();
  Registry::doSomething2();
  Registry::doSomething3();
  </code></pre>
  
  <p>OR:</p>
  
  <pre><code>class Test {
        public static function sayHi() {
            echo 'Hi';
        }
  }
  
  $test = Test;
  
  echo $test::sayHi(); // This being done multiple times versus
  echo Test::sayHi(); // That being done multiple times
  </code></pre>