| Subject: | You should change the PHP version... |  
| Summary: | Package rating comment |  
| Messages: | 3 |  
| Author: | Artur Graniszewski |  
| Date: | 2011-02-14 07:51:05 |  
| Update: | 2011-02-17 06:56:41 |  
|   |  
 
 | 
 | 
Artur Graniszewski rated this package as follows:
| Utility:  | Sufficient | 
| Consistency:  | Good | 
| Examples:  | Good | 
| 
 | 
  Artur Graniszewski - 2011-02-14 07:51:06  
You should change the PHP version requirement to 5.3. get_called_class() function does not exists in PHP 5-5.2 
  
  Artem - 2011-02-14 08:06:21 -  In reply to message 1 from Artur Graniszewski 
It`s true. Thx 
  
  Ghigea Gabriel - 2011-02-17 06:56:41 -  In reply to message 2 from Artem 
Also, your solution is not complete. 
Think about overriding your Singleton class. If you have something like that: 
 
class MyCustomeSingleton extends Singleton { 
   public function __construct() { 
     return parent::__construct(); 
   } 
} 
 
what's stopping me to do: 
 
$s1= new MyCustomeSingleton(); 
$s1->test(); 
 
$s2= new MyCustomeSingleton(); 
$s2->test(); 
 
To avoid this, you have the simple solution by marking constructor & clone magic method from Singleton class as final (or entire class Singleton if you don't want to be extended anymore). 
 
To be a class a singleton, basically you should follow 3 rules: 
1. constructor shouldn't be public 
2. inhibit the clone operator 
3. do not allow first two points to be changed by overriding. 
 
Mihai 
  
   |