$rhsX = $arity > 1 && $rhs !== $_; if ($lhsX && $rhsX) { // Both defined // Return the result return $lhs || $rhs; } if ($lhsX) { if ($lhs) { $alwaysTrue = function ($rhs = null) use(&$alwaysTrue, $_) { return func_num_args() !== 0 && $rhs !== $_ ? true : $alwaysTrue; }; return $alwaysTrue; } $rightDeterminate = function ($rhs = null) use(&$rightDeterminate, $_) { return func_num_args() !== 0 && $rhs !== $_ ? (bool) $rhs : $rightDeterminate; }; return $rightDeterminate; } if ($rhsX) { // Is the right hand side defined? $indeterminate = function ($lhs = null) use($_, &$indeterminate, $rhs) { return func_num_args() !== 0 && $lhs !== $_ ? $lhs || $rhs : $indeterminate; }; return $indeterminate; } // both are undefined, send a wrapped version of itself. (rare) return __PRIVATE__::$instance[orL]; } const orL = __NAMESPACE__ . '\\orL'; __PRIVATE__::$instance[orL] = toClosure(orL);
// Return the result return $lhs && $rhs; } if ($lhsX) { // first is defined if (!$lhs) { // if lhs is false, then the result is always false $alwaysFalse = function ($rhs = null) use(&$alwaysFalse, $_) { return func_num_args() !== 0 && $rhs !== $_ ? false : $alwaysFalse; }; return $alwaysFalse; } // Otherwise the value is determined only by the rhs $rightDeterminate = function ($rhs = null) use($_, &$rightDeterminate) { return func_num_args() !== 0 && $rhs !== $_ ? (bool) $rhs : $rightDeterminate; }; return $rightDeterminate; } if ($rhsX) { // Is the right hand side defined? $indeterminate = function ($lhs = null) use($_, &$indeterminate, $rhs) { return func_num_args() !== 0 && $lhs !== $_ ? $lhs && $rhs : $indeterminate; }; return $indeterminate; } // both are undefined, send a wrapped version of itself. (rare) return __PRIVATE__::$instance[andL]; } const andL = __NAMESPACE__ . '\\andL'; __PRIVATE__::$instance[andL] = toClosure(andL);