1111use PhpParser \Node \Expr \BinaryOp \NotIdentical ;
1212use PHPStan \Analyser \Scope ;
1313use PHPStan \Reflection \ReflectionProvider ;
14+ use PHPStan \Rules \IdentifierRuleError ;
1415use PHPStan \Rules \Rule ;
15- use PHPStan \Rules \RuleError ;
1616use PHPStan \Rules \RuleErrorBuilder ;
17- use PHPStan \Type \ArrayType ;
1817use PHPStan \Type \BooleanType ;
1918use PHPStan \Type \CallableType ;
20- use PHPStan \Type \Constant \ConstantBooleanType ;
2119use PHPStan \Type \FloatType ;
2220use PHPStan \Type \IntegerType ;
2321use PHPStan \Type \MixedType ;
@@ -83,7 +81,7 @@ public function getNodeType(): string
8381
8482 /**
8583 * @param BinaryOp $node
86- * @return list<RuleError >
84+ * @return list<IdentifierRuleError >
8785 */
8886 public function processNode (Node $ node , Scope $ scope ): array
8987 {
@@ -92,7 +90,7 @@ public function processNode(Node $node, Scope $scope): array
9290 }
9391
9492 $ nodeType = $ scope ->getType ($ node );
95- if ($ nodeType instanceof ConstantBooleanType ) {
93+ if ($ nodeType-> isTrue ()-> yes () || $ nodeType -> isFalse ()-> yes () ) {
9694 return []; // always-true or always-false, already reported by native PHPStan (like $a === $a)
9795 }
9896
@@ -109,7 +107,9 @@ public function processNode(Node $node, Scope $scope): array
109107 $ node ->getOperatorSigil (),
110108 $ leftType ->describe (VerbosityLevel::typeOnly ()),
111109 $ rightType ->describe (VerbosityLevel::typeOnly ()),
112- ))->build (),
110+ ))
111+ ->identifier ('assoconnect.identicalClassComparison ' )
112+ ->build (),
113113 ];
114114 }
115115
@@ -130,12 +130,14 @@ private function isAccepted(Type $firstArm, Type $otherArm): bool
130130 }
131131
132132
133- if ($ firstArm instanceof ArrayType) {
133+ $ arrays = $ firstArm ->getArrays ();
134+ if ([] !== $ arrays ) {
135+ $ firstArray = $ arrays [0 ];
134136 // Empty array
135- if ($ firstArm ->isIterableAtLeastOnce ()->no ()) {
137+ if ($ firstArray ->isIterableAtLeastOnce ()->no ()) {
136138 return true ;
137139 }
138- return $ this ->isAccepted ($ firstArm ->getIterableValueType (), $ otherArm );
140+ return $ this ->isAccepted ($ firstArray ->getIterableValueType (), $ otherArm );
139141 }
140142
141143 if ($ this ->typeIsEnumOrNull ($ firstArm ) && $ this ->typeIsEnumOrNull ($ otherArm )) {
0 commit comments