88
99class  RefCountDisposable implements  DisposableInterface
1010{
11-     private  $ count  = 0 ;
12-     private  $ disposable ;
13-     private  $ isDisposed  = false ;
14-     private  $ isPrimaryDisposed  = false ;
1511
16-     public  function  __construct (DisposableInterface   $ disposable )
17-     {
18-         $ this  ->disposable  = $ disposable ;
12+     public  function  __construct (
13+         private  readonly  DisposableInterface   $ disposable ,
14+         private  int                           $ count  = 0 ,
15+         private  bool                          $ isDisposed  = false ,
16+         private  bool                          $ isPrimaryDisposed  = false 
17+     ) {
1918    }
2019
21-     public  function  dispose ()
20+     public  function  dispose ():  void 
2221    {
2322        if  ($ this  ->isDisposed ) {
2423            return ;
@@ -32,13 +31,13 @@ public function dispose()
3231        }
3332    }
3433
35-     public  function  getDisposable ()
34+     public  function  getDisposable ():  DisposableInterface | CallbackDisposable 
3635    {
3736        if  (!$ this  ->isDisposed ) {
3837            return  $ this  ->createInnerDisposable ();
3938        }
4039
41-         return  new  CallbackDisposable (function  () {
40+         return  new  CallbackDisposable (function  ():  void  {
4241        }); // no op 
4342    }
4443
@@ -57,7 +56,7 @@ private function createInnerDisposable(): DisposableInterface
5756        $ this  ->count ++;
5857        $ isInnerDisposed  = false ;
5958
60-         return  new  CallbackDisposable (function  () use  (&$ isInnerDisposed ) {
59+         return  new  CallbackDisposable (function  () use  (&$ isInnerDisposed ):  void  {
6160            if  ($ this  ->isDisposed ()) {
6261                return ;
6362            }
0 commit comments