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
master
韩天峰 4 days ago
parent 06023674fe
commit a70a0ad078
  1. 4
      src/NativeClass/NativeGlobalDiscovery.php
  2. 3
      src/Parser/BinaryOpTrait.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 = [];

@ -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;
}

Loading…
Cancel
Save