File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -4103,6 +4103,12 @@ private function createConditionalExpressions(
41034103 if ($ mergedExpressionTypes [$ exprString ]->equalTypes ($ holder )) {
41044104 continue ;
41054105 }
4106+ if (
4107+ array_key_exists ($ exprString , $ theirExpressionTypes )
4108+ && !$ theirExpressionTypes [$ exprString ]->getCertainty ()->yes ()
4109+ ) {
4110+ continue ;
4111+ }
41064112
41074113 $ typeGuards [$ exprString ] = $ holder ;
41084114 }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace ConditionalHoldersOrAssertIsset ;
4+
5+ use function PHPStan \Testing \assertType ;
6+
7+ /**
8+ * @return list<int>
9+ */
10+ function getListOfIds (): array {
11+ return [3 ];
12+ }
13+
14+ /**
15+ * @phpstan-impure
16+ */
17+ function getBool (): bool {
18+ return (bool ) rand (0 , 1 );
19+ }
20+
21+ $ displayDetails = getBool ();
22+ $ displayList = getBool ();
23+
24+ if ($ displayList || $ displayDetails ) {
25+ $ listOfIds = getListOfIds ();
26+ }
27+
28+ if ($ displayList ) {
29+ assert (isset ($ listOfIds ));
30+ }
31+
32+ if ($ displayDetails ) {
33+ assert (isset ($ listOfIds ));
34+ assertType ('bool ' , $ displayList );
35+ }
You can’t perform that action at this time.
0 commit comments