@@ -27,6 +27,19 @@ public static function myRand(): int
2727
2828 }
2929
30+ public static function createException (): MyInvalidArgumentException
31+ {
32+
33+ }
34+
35+ /**
36+ * @throws MyRuntimeException
37+ */
38+ public static function createExceptionOrThrow (): MyInvalidArgumentException
39+ {
40+
41+ }
42+
3043}
3144
3245function (): void {
@@ -105,3 +118,66 @@ function (): void {
105118 assertVariableCertainty (TrinaryLogic::createYes (), $ foo );
106119 }
107120};
121+
122+ function (): void {
123+ try {
124+ if (Foo::myRand () === 0 ) {
125+ $ foo = 1 ;
126+ throw Foo::createException ();
127+ }
128+
129+ if (Foo::myRand () === 1 ) {
130+ $ bar = 1 ;
131+ throw Foo::createExceptionOrThrow ();
132+ }
133+ } catch (MyInvalidArgumentException $ e ) {
134+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ foo );
135+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ bar );
136+ } catch (\Throwable $ e ) {
137+ assertVariableCertainty (TrinaryLogic::createNo (), $ foo );
138+ assertVariableCertainty (TrinaryLogic::createYes (), $ bar );
139+ }
140+ };
141+
142+ function (): void {
143+ try {
144+ if (Foo::myRand () === 0 ) {
145+ $ foo = 1 ;
146+ throw Foo::createException ();
147+ }
148+
149+ if (Foo::myRand () === 1 ) {
150+ $ bar = 1 ;
151+ throw Foo::createExceptionOrThrow ();
152+ }
153+ } catch (MyInvalidArgumentException $ e ) {
154+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ foo );
155+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ bar );
156+ } catch (\Exception $ e ) {
157+ assertVariableCertainty (TrinaryLogic::createNo (), $ foo );
158+ assertVariableCertainty (TrinaryLogic::createYes (), $ bar );
159+ }
160+ };
161+
162+ function (): void {
163+ try {
164+ if (Foo::myRand () === 0 ) {
165+ $ foo = 1 ;
166+ throw Foo::createException ();
167+ }
168+
169+ if (Foo::myRand () === 1 ) {
170+ $ bar = 1 ;
171+ throw Foo::createExceptionOrThrow ();
172+ }
173+ } catch (MyInvalidArgumentException $ e ) {
174+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ foo );
175+ assertVariableCertainty (TrinaryLogic::createMaybe (), $ bar );
176+ } catch (\Exception $ e ) {
177+ assertVariableCertainty (TrinaryLogic::createNo (), $ foo );
178+ assertVariableCertainty (TrinaryLogic::createYes (), $ bar );
179+ } catch (\Throwable $ e ) {
180+ assertVariableCertainty (TrinaryLogic::createNo (), $ foo );
181+ assertVariableCertainty (TrinaryLogic::createYes (), $ bar );
182+ }
183+ };
0 commit comments