File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ /**
6+ * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+ * SPDX-License-Identifier: AGPL-3.0-or-later
8+ */
9+
10+ use Psalm \CodeLocation ;
11+ use Psalm \IssueBuffer ;
12+ use Psalm \Plugin \EventHandler \AfterExpressionAnalysisInterface ;
13+ use Psalm \Plugin \EventHandler \Event \AfterExpressionAnalysisEvent ;
14+
15+ class LogicalOperatorChecker implements AfterExpressionAnalysisInterface {
16+ public static function afterExpressionAnalysis (AfterExpressionAnalysisEvent $ event ): ?bool {
17+ $ stmt = $ event ->getExpr ();
18+ if ($ stmt instanceof PhpParser \Node \Expr \BinaryOp \LogicalAnd
19+ || $ stmt instanceof PhpParser \Node \Expr \BinaryOp \LogicalOr) {
20+ IssueBuffer::maybeAdd (
21+ new \Psalm \Issue \UnrecognizedExpression (
22+ 'Logical binary operators AND and OR are not allowed in the Nextcloud codebase ' ,
23+ new CodeLocation ($ event ->getStatementsSource ()->getSource (), $ stmt ),
24+ ),
25+ $ event ->getStatementsSource ()->getSuppressedIssues (),
26+ );
27+ }
28+ return null ;
29+ }
30+ }
Original file line number Diff line number Diff line change 1717 <plugins >
1818 <plugin filename =" build/psalm/AppFrameworkTainter.php" />
1919 <plugin filename =" build/psalm/AttributeNamedParameters.php" />
20+ <plugin filename =" build/psalm/LogicalOperatorChecker.php" />
2021 </plugins >
2122 <projectFiles >
2223 <directory name =" apps/admin_audit" />
You can’t perform that action at this time.
0 commit comments