mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-06 06:57:25 +02:00
singleton fix visible __wakeup()
1) DesignPatterns\Creational\Singleton\Tests\SingletonTest::testUniqueness The magic method DesignPatterns\Creational\Singleton\Singleton::__wakeup() must have public visibility /app/Creational/Singleton/Singleton.php:39 /app/Creational/Singleton/Tests/SingletonTest.php:12 ERRORS!
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace DesignPatterns\Creational\Singleton;
|
||||
|
||||
use Exception;
|
||||
|
||||
final class Singleton
|
||||
{
|
||||
private static ?Singleton $instance = null;
|
||||
@@ -36,7 +38,8 @@ final class Singleton
|
||||
/**
|
||||
* prevent from being unserialized (which would create a second instance of it)
|
||||
*/
|
||||
private function __wakeup()
|
||||
public function __wakeup()
|
||||
{
|
||||
throw new Exception("Cannot unserialize singleton");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user