class

Analyzer::Php::Laminas

Inherits Analyzer::Php::PhpEngine < FileScanEngine < Analyzer < FileHelper < Reference < Object

Constants

CONSTRAINT_METACHARACTERS = "\\^$.|?*+()[]{}"

Regex metacharacters. A Laminas constraint is a validation pattern ('itemId' => '[0-9]+'), so it only doubles as a value when it matches exactly one string — i.e. when it contains none of these.

HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]
NAMESPACE_MARKER_RE = /Laminas\\|Zend\\|Mezzio\\/

Precompiled once at load: the three namespace markers used to be three separate String#includes? scans of the whole file ORed together. Crystal's String#includes? is measurably slower than a single precompiled Regex#matches? call, and this runs on every .php file fed into the analyzer during a project-wide scan.

PARAM_PATTERNS = [{/->getQueryParams\s*\(\s*\)\s*\[\s*['"]([^'"]+)['"]\s*\]/, "query"}, {/->getParsedBody\s*\(\s*\)\s*\[\s*['"]([^'"]+)['"]\s*\]/, "form"}, {/->getUploadedFiles\s*\(\s*\)\s*\[\s*['"]([^'"]+)['"]\s*\]/, "form"}, {/->getHeaderLine\s*\(\s*['"]([^'"]+)['"]\s*\)/, "header"}, {/->getHeader\s*\(\s*['"]([^'"]+)['"]\s*\)/, "header"}, {/->getCookieParams\s*\(\s*\)\s*\[\s*['"]([^'"]+)['"]\s*\]/, "cookie"}]
SPLIT_ARGS_RULES = Noir::TopLevelSplit::Rules.new(nest: (Noir::TopLevelSplit::Nest::Paren | Noir::TopLevelSplit::Nest::Bracket) | Noir::TopLevelSplit::Nest::Brace, quotes: "\"'", escape: Noir::TopLevelSplit::Escape::InQuotes, strip: false, empties: Noir::TopLevelSplit::Empties::DropTrailing, per_kind: false, clamp: true)

Rules::SHARED_DEPTH_RAW with a trailing empty dropped, then a strip applied by this method rather than by the splitter.

The order matters and is not cosmetic. The body this replaces stripped each part as it pushed it, but decided whether to emit the tail from the RAW slice (if start < size), so f(a, ) kept a final "" while f(a,) did not. Stripping inside the splitter would test the stripped tail and drop both. Splitting raw and stripping afterwards reproduces the original exactly.

The old scan walked bytes to dodge String#[](Int); the shared splitter is a single forward each_char pass, so it is O(n) on any input without needing the byte detour. Every delimiter, quote and bracket involved is ASCII and UTF-8 continuation bytes are all

= 0x80, so the two scans see the same split points.

Class methods

tech_name
Source

Instance methods

analyze_file(path : String) : Array(Endpoint)
Source
tech

Instance-side view of the same declaration. The per-file rescues live on this base class, which has no way to name the analyzer that is running inside them, so a skipped file could not be attributed to a tech. Deriving it from analyzer_for keeps the name written exactly once.

Source