From a70a0ad078017f6b8b928c6d9262ef59b5154f6f Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 27 Aug 2026 18:59:52 +0800 Subject: [PATCH] refactor(parser): remove redundant null checks in binary operation and closure processing - Removed unnecessary null check for left and right types in binary operation detection - Eliminated redundant null check for closure statements before global collection - Simplified type checking logic by relying on subsequent primitive type validation - Improved code flow by removing early returns that were masking actual logic --- src/NativeClass/NativeGlobalDiscovery.php | 4 ---- src/Parser/BinaryOpTrait.php | 3 --- 2 files changed, 7 deletions(-) diff --git a/src/NativeClass/NativeGlobalDiscovery.php b/src/NativeClass/NativeGlobalDiscovery.php index 6220060d..e8604f04 100644 --- a/src/NativeClass/NativeGlobalDiscovery.php +++ b/src/NativeClass/NativeGlobalDiscovery.php @@ -126,10 +126,6 @@ final class NativeGlobalDiscovery array $outerLocals, array &$result, ): void { - if ($closure->stmts === null) { - return; - } - $globals = []; $this->collectGlobals($closure->stmts, $globals); $locals = []; diff --git a/src/Parser/BinaryOpTrait.php b/src/Parser/BinaryOpTrait.php index 30b05b57..804cfb2e 100644 --- a/src/Parser/BinaryOpTrait.php +++ b/src/Parser/BinaryOpTrait.php @@ -904,9 +904,6 @@ trait BinaryOpTrait $leftType = $this->detectTypeOfExpr($astLeft); $rightType = $this->detectTypeOfExpr($astRight); - if ($leftType === null || $rightType === null) { - return null; - } if (!in_array($leftType, $primitiveTypes, true) || !in_array($rightType, $primitiveTypes, true)) { return null; }