Mantis - Quercus
Viewing Issue Advanced Details
2550 minor have not tried 03-24-08 15:47 05-12-08 17:19
mardala  
ferg  
normal  
closed 3.1.3  
fixed  
none    
none 3.2.0  
0002550: PHP5 singleton example not working the same as Apache module php 5
given something like this:

class Singleton {
  // object instance
  private static $instance;
 
  private function __construct() {}
 
  public static function getInstance() {
    if (self::$instance === null) self::$instance = new self;
    return self::$instance;
  }
 
  public function doAction() {
    ...
  }
}

This will not work. Quercus throws an exception (com.caucho.quercus.QuercusException: no matching class self) on "new self;" ... the fix is "new Singleton();"

Not a show stopper by anymeans at all, but just a subtle difference than php on apache.
I did a quick search of singleton in Quercus and didn't see anything so I hope this is not a dupe.

Notes
(0002889)
mardala   
03-24-08 16:00   
self(); works. I just found out. Also this works: $c = __CLASS__, self::$instance = new $c;
(0003058)
ferg   
05-12-08 17:19   
php/0957, php/3957