66
77namespace Compwright \PhpSession ;
88
9+ use InvalidArgumentException ;
10+ use RuntimeException ;
11+ use SessionUpdateTimestampHandlerInterface ;
12+ use Throwable ;
13+
914class Manager
1015{
1116 protected Config $ config ;
@@ -87,7 +92,7 @@ public function commit(): bool
8792 public function create_id (string $ prefix = "" )
8893 {
8994 if ($ prefix && preg_match ("/^[a-zA-Z0-9,-]+$/ " , $ prefix ) === 0 ) {
90- throw new \ InvalidArgumentException ("\$prefix contains disallowed characters " );
95+ throw new InvalidArgumentException ("\$prefix contains disallowed characters " );
9196 }
9297
9398 $ this ->config ->setSidPrefix ($ prefix );
@@ -112,7 +117,7 @@ public function decode(string $data)
112117 $ serializer = $ this ->config ->getSerializeHandler ();
113118 $ this ->currentSession ->setContents ($ serializer ->unserialize ($ data ));
114119 return true ;
115- } catch (\ Exception $ e ) {
120+ } catch (Throwable $ e ) {
116121 return false ;
117122 }
118123 }
@@ -135,7 +140,7 @@ public function encode()
135140 try {
136141 $ serializer = $ this ->config ->getSerializeHandler ();
137142 return $ serializer ->serialize ($ this ->currentSession ->toArray ());
138- } catch (\ Exception $ e ) {
143+ } catch (Throwable $ e ) {
139144 return false ;
140145 }
141146 }
@@ -321,7 +326,7 @@ public function start(): bool
321326 if (
322327 !$ this ->currentSession
323328 || (
324- $ handler instanceof \ SessionUpdateTimestampHandlerInterface
329+ $ handler instanceof SessionUpdateTimestampHandlerInterface
325330 && !$ handler ->validateId ($ this ->currentSession ->getId ())
326331 )
327332 ) {
@@ -427,7 +432,7 @@ public function write_close(): bool
427432 $ handler ->destroy ($ id );
428433 $ handler ->close ();
429434 $ this ->currentSession ->close ();
430- throw new \ RuntimeException ("Data serialization failure " );
435+ throw new RuntimeException ("Data serialization failure " );
431436 return false ;
432437 }
433438
0 commit comments