From 2308d9bba0e895fd7c13d6c585a65228e67e8ea3 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Sat, 31 Aug 2024 23:04:41 +0200 Subject: [PATCH] build: Rewrite exclude rule Generic.CodeAnalysis.AssignmentInCondition The is managed by libup and when a rule passed, it get removed from the list. Failing rules on update are added. Setting the severity for the rule to none avoid that this is changed by libup and it is more visible, that the disable is wanted and there is nothing to "fix" as usually assumend for sniffs in the exclude list. Follow-Up: I8adfdce01ea96f4b62dabd3dea130f9593c7e5ac Change-Id: If42dade02c6ceed1e00f5a3dc846e1578b960ca6 --- .phpcs.xml | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index c4ca61e22..b8ec41cfd 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -1,22 +1,24 @@ - - - - + It's particularly helpful in combination with Phan, which can infer that `$foo` is non-null from + the code above, but it can't infer that `$foo->nextSibling` is non-null in code like this: + while ( $foo->nextSibling && someCondition( $foo->nextSibling ) ) { … } + + When the variable is the only condition, we add extra parentheses to indicate that it isn't a + typo for `==`, which is a convention borrowed from C: + while ( ( $foo = $foo->nextSibling ) ) { … } + --> + + 0 + .