@@ -13,7 +13,7 @@ final class SpecifiedTypes
1313
1414 private bool $ overwrite = false ;
1515
16- private bool $ specifyOnly = false ;
16+ private bool $ equality = false ;
1717
1818 /** @var array<string, ConditionalExpressionHolder[]> */
1919 private array $ newConditionalExpressionHolders = [];
@@ -53,34 +53,38 @@ public function setAlwaysOverwriteTypes(): self
5353 {
5454 $ self = new self ($ this ->sureTypes , $ this ->sureNotTypes );
5555 $ self ->overwrite = true ;
56- $ self ->specifyOnly = $ this ->specifyOnly ;
56+ $ self ->equality = $ this ->equality ;
5757 $ self ->newConditionalExpressionHolders = $ this ->newConditionalExpressionHolders ;
5858 $ self ->rootExpr = $ this ->rootExpr ;
5959
6060 return $ self ;
6161 }
6262
6363 /**
64- * Marks these SpecifiedTypes as only narrowing types, not determining
65- * the check outcome. ImpossibleCheckTypeHelper will not use sureTypes
66- * to report always-true/false for the check expression.
64+ * Marks these types as coming from an equality check, the same concept as
65+ * the "=Type" equality assertions documented at
66+ * https://phpstan.org/writing-php-code/narrowing-types#equality-assertions
67+ *
68+ * The narrowed types are only applied; they do not determine the check
69+ * outcome, so ImpossibleCheckTypeHelper will not use them to report
70+ * always-true/false for the check expression.
6771 *
6872 * @api
6973 */
70- public function setSpecifyOnly (): self
74+ public function setEquality (): self
7175 {
7276 $ self = new self ($ this ->sureTypes , $ this ->sureNotTypes );
7377 $ self ->overwrite = $ this ->overwrite ;
74- $ self ->specifyOnly = true ;
78+ $ self ->equality = true ;
7579 $ self ->newConditionalExpressionHolders = $ this ->newConditionalExpressionHolders ;
7680 $ self ->rootExpr = $ this ->rootExpr ;
7781
7882 return $ self ;
7983 }
8084
81- public function shouldSpecifyOnly (): bool
85+ public function isEquality (): bool
8286 {
83- return $ this ->specifyOnly ;
87+ return $ this ->equality ;
8488 }
8589
8690 /**
@@ -90,7 +94,7 @@ public function setRootExpr(?Expr $rootExpr): self
9094 {
9195 $ self = new self ($ this ->sureTypes , $ this ->sureNotTypes );
9296 $ self ->overwrite = $ this ->overwrite ;
93- $ self ->specifyOnly = $ this ->specifyOnly ;
97+ $ self ->equality = $ this ->equality ;
9498 $ self ->newConditionalExpressionHolders = $ this ->newConditionalExpressionHolders ;
9599 $ self ->rootExpr = $ rootExpr ;
96100
@@ -104,7 +108,7 @@ public function setNewConditionalExpressionHolders(array $newConditionalExpressi
104108 {
105109 $ self = new self ($ this ->sureTypes , $ this ->sureNotTypes );
106110 $ self ->overwrite = $ this ->overwrite ;
107- $ self ->specifyOnly = $ this ->specifyOnly ;
111+ $ self ->equality = $ this ->equality ;
108112 $ self ->newConditionalExpressionHolders = $ newConditionalExpressionHolders ;
109113 $ self ->rootExpr = $ this ->rootExpr ;
110114
@@ -156,7 +160,7 @@ public function removeExpr(string $exprString): self
156160
157161 $ self = new self ($ sureTypes , $ sureNotTypes );
158162 $ self ->overwrite = $ this ->overwrite ;
159- $ self ->specifyOnly = $ this ->specifyOnly ;
163+ $ self ->equality = $ this ->equality ;
160164 $ self ->newConditionalExpressionHolders = $ this ->newConditionalExpressionHolders ;
161165 $ self ->rootExpr = $ this ->rootExpr ;
162166
@@ -196,8 +200,8 @@ public function intersectWith(SpecifiedTypes $other): self
196200 if ($ this ->overwrite && $ other ->overwrite ) {
197201 $ result = $ result ->setAlwaysOverwriteTypes ();
198202 }
199- if ($ this ->specifyOnly || $ other ->specifyOnly ) {
200- $ result ->specifyOnly = true ;
203+ if ($ this ->equality || $ other ->equality ) {
204+ $ result ->equality = true ;
201205 }
202206
203207 return $ result ->setRootExpr ($ rootExpr );
@@ -236,8 +240,8 @@ public function unionWith(SpecifiedTypes $other): self
236240 if ($ this ->overwrite || $ other ->overwrite ) {
237241 $ result = $ result ->setAlwaysOverwriteTypes ();
238242 }
239- if ($ this ->specifyOnly || $ other ->specifyOnly ) {
240- $ result ->specifyOnly = true ;
243+ if ($ this ->equality || $ other ->equality ) {
244+ $ result ->equality = true ;
241245 }
242246
243247 $ conditionalExpressionHolders = $ this ->newConditionalExpressionHolders ;
@@ -270,7 +274,7 @@ public function normalize(Scope $scope): self
270274 if ($ this ->overwrite ) {
271275 $ result = $ result ->setAlwaysOverwriteTypes ();
272276 }
273- $ result ->specifyOnly = $ this ->specifyOnly ;
277+ $ result ->equality = $ this ->equality ;
274278
275279 return $ result ->setRootExpr ($ this ->rootExpr );
276280 }
0 commit comments