Skip to content

LogarithmInvalidRealDomain ​

warning native on by default

Group: Probable bugs

Use a positive logarithm argument.

Example ​

php
<?php
$n = log(-7);

Reported:

  • line 2: Use a positive logarithm argument.

Detection ​

  • log, log10 or log1p has a proven numeric value outside its real-valued finite-result domain: log/log10 argument <= 0; log1p argument <= -1. Also report log base <= 0 or equal to 1 when explicit.
  • Resolve builtin functions, extension classes, constants and method receivers, including aliases and supported named arguments. Inspect reachable operations in one lexical scope with bounded local flow.
  • Emit one finding per violating operation. Never infer policy from names or comments. When the proof is inconclusive, nothing is reported.

Exceptions (no report) ​

  • Exclude shadowed or unresolved symbols, incomplete code, unknown required constants, ambiguous receiver identity and unsupported versions. Reassignment, escaping aliases, and unknown calls invalidate dependent flow facts.
  • Both @custos-ignore LogarithmInvalidRealDomain and @noinspection LogarithmInvalidRealDomain suppress this native rule.

Fix ​

None. A safe repair requires choosing values, error handling, or application behavior.

PHP versions ​

Apply throughout PHP 5.3–8.5 only where the extension API and syntax exist. Do not flag API unavailability through this rule.

Options ​

None. Use normal rule configuration to enable or disable the inspection.

Configure ​

In custos.json:

json
{
  "rules": {
    "LogarithmInvalidRealDomain": {
      "enabled": false
    }
  }
}

Suppress ​

Before the statement or declaration (or the first statement of the file):

php
// @custos-ignore LogarithmInvalidRealDomain

Released under the MIT License. Native rules and rules modeled on Php Inspections (EA Extended); independent clean-room implementation.