@@ -13,7 +13,7 @@ final class SpecifiedTypes
1313
1414 private bool $ overwrite = false ;
1515
16- private bool $ shouldNotDetermineCheckResult = false ;
16+ private bool $ specifyOnly = false ;
1717
1818 /** @var array<string, ConditionalExpressionHolder[]> */
1919 private array $ newConditionalExpressionHolders = [];
@@ -53,29 +53,28 @@ public function setAlwaysOverwriteTypes(): self
5353 {
5454 $ self = new self ($ this ->sureTypes , $ this ->sureNotTypes );
5555 $ self ->overwrite = true ;
56- $ self ->shouldNotDetermineCheckResult = $ this ->shouldNotDetermineCheckResult ;
56+ $ self ->specifyOnly = $ this ->specifyOnly ;
5757 $ self ->newConditionalExpressionHolders = $ this ->newConditionalExpressionHolders ;
5858 $ self ->rootExpr = $ this ->rootExpr ;
5959
6060 return $ self ;
6161 }
6262
6363 /**
64- * Normally, when a type-specifying extension returns SpecifiedTypes with sureTypes,
65- * ImpossibleCheckTypeHelper will analyze whether those types are already satisfied
66- * and conclude the check is always-true/always-false.
64+ * When set, the sureTypes are only used for narrowing — ImpossibleCheckTypeHelper
65+ * will not use them to determine whether the check is always-true/always-false.
6766 *
68- * When this flag is set, that analysis is skipped. Use this when the sureTypes
69- * are a side effect of the check (e.g. str_contains narrowing haystack to non-empty-string)
67+ * Use this when the sureTypes are a side effect of the check
68+ * (e.g. str_contains narrowing haystack to non-empty-string)
7069 * rather than the determining condition.
7170 *
7271 * @api
7372 */
74- public function setShouldNotDetermineCheckResult (): self
73+ public function setSpecifyOnly (): self
7574 {
7675 $ self = new self ($ this ->sureTypes , $ this ->sureNotTypes );
7776 $ self ->overwrite = $ this ->overwrite ;
78- $ self ->shouldNotDetermineCheckResult = true ;
77+ $ self ->specifyOnly = true ;
7978 $ self ->newConditionalExpressionHolders = $ this ->newConditionalExpressionHolders ;
8079 $ self ->rootExpr = $ this ->rootExpr ;
8180
@@ -89,7 +88,7 @@ public function setRootExpr(?Expr $rootExpr): self
8988 {
9089 $ self = new self ($ this ->sureTypes , $ this ->sureNotTypes );
9190 $ self ->overwrite = $ this ->overwrite ;
92- $ self ->shouldNotDetermineCheckResult = $ this ->shouldNotDetermineCheckResult ;
91+ $ self ->specifyOnly = $ this ->specifyOnly ;
9392 $ self ->newConditionalExpressionHolders = $ this ->newConditionalExpressionHolders ;
9493 $ self ->rootExpr = $ rootExpr ;
9594
@@ -103,7 +102,7 @@ public function setNewConditionalExpressionHolders(array $newConditionalExpressi
103102 {
104103 $ self = new self ($ this ->sureTypes , $ this ->sureNotTypes );
105104 $ self ->overwrite = $ this ->overwrite ;
106- $ self ->shouldNotDetermineCheckResult = $ this ->shouldNotDetermineCheckResult ;
105+ $ self ->specifyOnly = $ this ->specifyOnly ;
107106 $ self ->newConditionalExpressionHolders = $ newConditionalExpressionHolders ;
108107 $ self ->rootExpr = $ this ->rootExpr ;
109108
@@ -133,9 +132,9 @@ public function shouldOverwrite(): bool
133132 return $ this ->overwrite ;
134133 }
135134
136- public function shouldNotDetermineCheckResult (): bool
135+ public function isSpecifyOnly (): bool
137136 {
138- return $ this ->shouldNotDetermineCheckResult ;
137+ return $ this ->specifyOnly ;
139138 }
140139
141140 /**
@@ -160,7 +159,7 @@ public function removeExpr(string $exprString): self
160159
161160 $ self = new self ($ sureTypes , $ sureNotTypes );
162161 $ self ->overwrite = $ this ->overwrite ;
163- $ self ->shouldNotDetermineCheckResult = $ this ->shouldNotDetermineCheckResult ;
162+ $ self ->specifyOnly = $ this ->specifyOnly ;
164163 $ self ->newConditionalExpressionHolders = $ this ->newConditionalExpressionHolders ;
165164 $ self ->rootExpr = $ this ->rootExpr ;
166165
@@ -200,8 +199,8 @@ public function intersectWith(SpecifiedTypes $other): self
200199 if ($ this ->overwrite && $ other ->overwrite ) {
201200 $ result = $ result ->setAlwaysOverwriteTypes ();
202201 }
203- if ($ this ->shouldNotDetermineCheckResult || $ other ->shouldNotDetermineCheckResult ) {
204- $ result = $ result ->setShouldNotDetermineCheckResult ();
202+ if ($ this ->specifyOnly || $ other ->specifyOnly ) {
203+ $ result = $ result ->setSpecifyOnly ();
205204 }
206205
207206 return $ result ->setRootExpr ($ rootExpr );
@@ -240,8 +239,8 @@ public function unionWith(SpecifiedTypes $other): self
240239 if ($ this ->overwrite || $ other ->overwrite ) {
241240 $ result = $ result ->setAlwaysOverwriteTypes ();
242241 }
243- if ($ this ->shouldNotDetermineCheckResult || $ other ->shouldNotDetermineCheckResult ) {
244- $ result = $ result ->setShouldNotDetermineCheckResult ();
242+ if ($ this ->specifyOnly || $ other ->specifyOnly ) {
243+ $ result = $ result ->setSpecifyOnly ();
245244 }
246245
247246 $ conditionalExpressionHolders = $ this ->newConditionalExpressionHolders ;
@@ -274,8 +273,8 @@ public function normalize(Scope $scope): self
274273 if ($ this ->overwrite ) {
275274 $ result = $ result ->setAlwaysOverwriteTypes ();
276275 }
277- if ($ this ->shouldNotDetermineCheckResult ) {
278- $ result = $ result ->setShouldNotDetermineCheckResult ();
276+ if ($ this ->specifyOnly ) {
277+ $ result = $ result ->setSpecifyOnly ();
279278 }
280279
281280 return $ result ->setRootExpr ($ this ->rootExpr );
0 commit comments