isVariableName.php
Table of Contents
Functions
- isVariableName() : bool
- Tells whether a string is a safe AQL **variable** name — the identifier a `LET` binds, not a path to an attribute.
Functions
isVariableName()
Tells whether a string is a safe AQL **variable** name — the identifier a `LET` binds, not a path to an attribute.
isVariableName(mixed $value) : bool
The distinction matters, and isAttributeName() is the wrong guard for
this job: it validates a path, so it accepts address.city, which reads
perfectly as an attribute and is a syntax error as a variable
(LET address.city = …). A variable name is a single identifier: a letter or
an underscore, then letters, digits and underscores.
Two failures this cannot see, because they are not about shape:
- an AQL keyword (
LET,RETURN,FILTER, …) has the shape of an identifier and is refused by the server (expecting identifier); - a name already bound in the query —
docabove all — parses, then fails on execution (variable 'doc' is assigned multiple times).
Both are refused loudly by ArangoDB at the first query, with a message naming the variable, so they surface immediately rather than corrupting a result. Enumerating the keyword list here would only add a copy to keep in sync with the server, and a false sense of completeness.
Parameters
- $value : mixed
-
The candidate variable name.
Tags
Return values
bool —Whether it is a well-formed AQL variable name.