952 days continuous production uptime, 40k+ tp/s single node. Original corpo Bitbucket history not included — clean archive commit.
42 lines
900 B
PHP
42 lines
900 B
PHP
<?php
|
|
/**
|
|
* point of this stub is to show that explicit return values have no impact in static singleton class instantiation
|
|
*/
|
|
class foo {
|
|
private $bar = 0;
|
|
private static $instance;
|
|
|
|
private function __construct($_which)
|
|
{
|
|
static::$instance = null;
|
|
switch ($_which) {
|
|
case 1 :
|
|
return true;
|
|
break;
|
|
case 2 :
|
|
return false;
|
|
break;
|
|
default :
|
|
return null;
|
|
break;
|
|
}
|
|
}
|
|
|
|
public static function getInstance($_w)
|
|
{
|
|
if (static::$instance === null) {
|
|
$c = __CLASS__;
|
|
static::$instance = new $c($_w);
|
|
}
|
|
return(static::$instance);
|
|
}
|
|
}
|
|
|
|
$bar = foo::getInstance(1);
|
|
var_export($bar);
|
|
$bar = foo::getInstance(2);
|
|
var_export($bar);
|
|
$bar = foo::getInstance(0);
|
|
var_export($bar);
|
|
|