in src/main/kotlin/com/pestphp/pest/inspections/MultipleExpectChainableInspection.kt [16:36]
override fun visitPhpGroupStatement(groupStatement: GroupStatement) {
var counter = 1
groupStatement.statements
.filterIsInstance(Statement::class.java)
.groupBy {
val methodReference = it.firstPsiChild as? MethodReference
if (methodReference?.text?.startsWith("expect") != true || !methodReference.type.isExpectation(holder.project)) {
counter++
return@groupBy 0
}
counter
}
.toMutableMap()
// Drop index 0, as that is all non expect calls
.also { it.remove(0) }
// Filter all expect call groups with only one expect call
.filterValues { it.size >= 2 }
.forEach {
declareProblemType(holder, it.value)
}
}