@@ -262,6 +262,7 @@ public function __construct(
262
262
private readonly bool $ detectDeadTypeInMultiCatch ,
263
263
private readonly bool $ paramOutType ,
264
264
private readonly bool $ preciseMissingReturn ,
265
+ private readonly bool $ explicitThrow ,
265
266
)
266
267
{
267
268
$ earlyTerminatingMethodNames = [];
@@ -1545,6 +1546,7 @@ private function processStmtNode(
1545
1546
}
1546
1547
1547
1548
// explicit only
1549
+ $ onlyExplicitIsThrow = true ;
1548
1550
if (count ($ matchingThrowPoints ) === 0 ) {
1549
1551
foreach ($ throwPoints as $ throwPointIndex => $ throwPoint ) {
1550
1552
foreach ($ catchTypes as $ catchTypeIndex => $ catchTypeItem ) {
@@ -1556,13 +1558,24 @@ private function processStmtNode(
1556
1558
if (!$ throwPoint ->isExplicit ()) {
1557
1559
continue ;
1558
1560
}
1561
+ $ throwNode = $ throwPoint ->getNode ();
1562
+ if (
1563
+ !$ throwNode instanceof Throw_
1564
+ && !$ throwNode instanceof Expr \Throw_
1565
+ && !($ throwNode instanceof Node \Stmt \Expression && $ throwNode ->expr instanceof Expr \Throw_)
1566
+ ) {
1567
+ $ onlyExplicitIsThrow = false ;
1568
+ }
1559
1569
$ matchingThrowPoints [$ throwPointIndex ] = $ throwPoint ;
1560
1570
}
1561
1571
}
1562
1572
}
1563
1573
1564
1574
// implicit only
1565
- if (count ($ matchingThrowPoints ) === 0 ) {
1575
+ if (
1576
+ count ($ matchingThrowPoints ) === 0
1577
+ || ($ this ->explicitThrow && $ onlyExplicitIsThrow )
1578
+ ) {
1566
1579
foreach ($ throwPoints as $ throwPointIndex => $ throwPoint ) {
1567
1580
if ($ throwPoint ->isExplicit ()) {
1568
1581
continue ;
0 commit comments