Documentation

Less_Parser
in package

Class for parsing and compiling less files into css

Tags
subpackage

parser

Table of Contents

$contentsMap  : array<string|int, mixed>
Filename to contents of all parsed the files
$default_options  : mixed
Default parser options
$has_extends  : mixed
$next_id  : mixed
$options  : mixed
$rules  : mixed
$env  : Less_Environment
$furthest  : mixed
$imports  : mixed
$input  : mixed
$input_len  : mixed
$mb_internal_encoding  : mixed
$pos  : mixed
$saveStack  : mixed
__construct()  : mixed
AbsPath()  : mixed
AddParsedFile()  : mixed
AllParsedFiles()  : mixed
ArgCache()  : mixed
ArgString()  : string
Convert an argument to a string for use in the parser cache
CacheEnabled()  : mixed
CacheFile()  : mixed
Error()  : mixed
expect()  : mixed
expectChar()  : mixed
FileParsed()  : mixed
findValueOf()  : mixed
findVarByName()  : mixed
getCss()  : string
Get the current css buffer
getVariables()  : array<string|int, mixed>
this function gets the private rules variable and returns an array of the found variables it uses a helper method getVariableValue() that contains the logic ot fetch the value from the rule object
is_method()  : mixed
Some versions of php have trouble with method_exists($a,$b) if $a is not an object
ModifyVars()  : Less_Parser
Allows a user to set variables values
NewObj0()  : mixed
Create Less_Tree_* objects and optionally generate a cache string
NewObj1()  : mixed
NewObj2()  : mixed
NewObj3()  : mixed
NewObj4()  : mixed
NewObj5()  : mixed
NewObj6()  : mixed
NewObj7()  : mixed
ObjCache()  : mixed
parse()  : Less_Tree_Ruleset|Less_Parser
Parse a Less string into css
parseAnonymousValue()  : mixed
parseExtend()  : mixed
parseFile()  : Less_Tree_Ruleset|Less_Parser
Parse a Less string from a given file
parseMultiplication()  : Less_Tree_Operation|null
Parses multiplication operation
parseUnicodeDescriptor()  : mixed
PeekChar()  : mixed
PeekReg()  : int
Same as match(), but don't change the state of the parser, just return the match.
registerFunction()  : mixed
Registers a new custom function
Reset()  : mixed
Reset the parser state completely
round()  : mixed
Round numbers similarly to javascript eg: 1.499999 to 1 instead of 2
save()  : mixed
serializeVars()  : mixed
SetCacheDir()  : mixed
SetFileInfo()  : mixed
SetImportDirs()  : mixed
Set a list of directories or callbacks the parser should use for determining import paths
SetInput()  : mixed
Set up the input buffer
SetOption()  : mixed
Set one compiler option
SetOptions()  : mixed
Set one or more compiler options options: import_dirs, cache_dir, cache_method
skipWhitespace()  : mixed
unregisterFunction()  : mixed
Removed an already registered function
UnsetInput()  : mixed
Free up some memory
WinPath()  : mixed
_parse()  : mixed
forget()  : mixed
FromKeyword()  : mixed
GetRules()  : mixed
Return the results of parsePrimary for $file_path Use cache and save cached results if possible
getVariableValue()  : bool|string
This method gets the value of the less variable from the rules object.
isWhitespace()  : bool
Determine if the character at the specified offset from the current position is a white space.
match()  : array<string|int, mixed>
Parse from a token, regexp or string, and move forward if match
MatchChar()  : mixed
MatchFuncs()  : string
MatchQuoted()  : mixed
When PCRE JIT is enabled in php, regular expressions don't work for matching quoted strings
MatchReg()  : mixed
parseAddition()  : Less_Tree_Operation|null
Parses an addition operation
parseAlpha()  : mixed
parseAttribute()  : mixed
parseBlock()  : mixed
parseBlockRuleset()  : mixed
parseCombinator()  : mixed
parseComment()  : mixed
parseComments()  : mixed
parseCondition()  : mixed
parseConditions()  : Less_Tree_Condition|null
Parses the conditions
parseDetachedRuleset()  : mixed
parseDirective()  : mixed
parseElement()  : mixed
parseEnd()  : mixed
parseEntitiesArguments()  : array<string|int, mixed>
Parse a list of arguments
parseEntitiesAssignment()  : mixed
parseEntitiesCall()  : mixed
parseEntitiesColor()  : mixed
parseEntitiesDimension()  : mixed
parseEntitiesJavascript()  : mixed
parseEntitiesKeyword()  : mixed
parseEntitiesLiteral()  : mixed
parseEntitiesQuoted()  : mixed
parseEntitiesUrl()  : mixed
parseEntitiesVariable()  : mixed
parseEntitiesVariableCurly()  : mixed
parseEntity()  : mixed
parseExpression()  : Less_Tree_Expression|null
Expressions either represent mathematical operations, or white-space delimited Entities.
parseImport()  : mixed
parseImportant()  : mixed
parseImportOption()  : mixed
parseImportOptions()  : mixed
parseLessSelector()  : mixed
parseMedia()  : mixed
parseMediaFeature()  : mixed
parseMediaFeatures()  : mixed
parseMixinArgs()  : mixed
parseMixinCall()  : mixed
parseMixinCallElements()  : mixed
parseMixinDefinition()  : mixed
parseNameValue()  : mixed
Custom less.php parse function for finding simple name-value css pairs ex: width:100px;
parseOperand()  : mixed
An operand is anything that can be part of an operation, such as a Color, or a Variable
parsePrimary()  : mixed
parseProperty()  : string
Parse a property eg: 'min-width', 'orientation', etc
parseRule()  : mixed
parseRuleProperty()  : string
Parse a rule property eg: 'color', 'width', 'height', etc
parseRuleset()  : mixed
parseRulesetCall()  : mixed
parseSelector()  : mixed
parseSub()  : mixed
parseTag()  : mixed
parseValue()  : mixed
parseVariable()  : mixed
PostVisitors()  : mixed
Run post-compile visitors
PreVisitors()  : mixed
Run pre-compile visitors
restore()  : mixed
rgb2html()  : mixed
rulePropertyMatch()  : mixed

Properties

$contentsMap

Filename to contents of all parsed the files

public static array<string|int, mixed> $contentsMap = array()

$default_options

Default parser options

public static mixed $default_options = array( 'compress' => alse, // option - whether to compress 'strictUnits' => alse, // whether units need to evaluate correctly 'strictMath' => alse, // whether math has to be within parenthesis 'relativeUrls' => rue, // option - whether to adjust URL's to be relative 'urlArgs' => '', // whether to add args into url tokens 'numPrecision' => 8, 'import_dirs' => array(), 'import_callback' => ull, 'cache_dir' => ull, 'cache_method' => 'php', // false, 'serialize', 'php', 'var_export', 'callback'; 'cache_callback_get' => ull, 'cache_callback_set' => ull, 'sourceMap' => alse, // whether to output a source map 'sourceMapBasepath' => ull, 'sourceMapWriteTo' => ull, 'sourceMapURL' => ull, 'indentation' => ' ', 'plugins' => array(), )

$has_extends

public static mixed $has_extends = alse

$next_id

public static mixed $next_id = 0

$options

public static mixed $options = array()

$rules

protected mixed $rules = array()

$furthest

private mixed $furthest

$imports

private static mixed $imports = array()

$input_len

private mixed $input_len

$mb_internal_encoding

private mixed $mb_internal_encoding = ''

$saveStack

private mixed $saveStack = array()

Methods

__construct()

public __construct([Less_Environment|array<string|int, mixed>|null $env = null ]) : mixed
Parameters
$env : Less_Environment|array<string|int, mixed>|null = null
Return values
mixed

AbsPath()

public static AbsPath(mixed $path[, mixed $winPath = false ]) : mixed
Parameters
$path : mixed
$winPath : mixed = false
Return values
mixed

AddParsedFile()

public static AddParsedFile(mixed $file) : mixed
Parameters
$file : mixed
Return values
mixed

AllParsedFiles()

public static AllParsedFiles() : mixed
Return values
mixed

ArgCache()

public ArgCache(mixed $args) : mixed
Parameters
$args : mixed
Return values
mixed

ArgString()

Convert an argument to a string for use in the parser cache

public static ArgString(mixed $arg) : string
Parameters
$arg : mixed
Return values
string

CacheEnabled()

public CacheEnabled() : mixed
Return values
mixed

CacheFile()

public CacheFile(mixed $file_path) : mixed
Parameters
$file_path : mixed
Return values
mixed

Error()

public Error(mixed $msg) : mixed
Parameters
$msg : mixed
Return values
mixed

expect()

public expect(string $tok[, string|null $msg = NULL ]) : mixed
Parameters
$tok : string
$msg : string|null = NULL
Return values
mixed

expectChar()

public expectChar(string $tok[, mixed $msg = null ]) : mixed
Parameters
$tok : string
$msg : mixed = null
Return values
mixed

FileParsed()

public static FileParsed(string $file) : mixed
Parameters
$file : string
Return values
mixed

findValueOf()

public findValueOf(mixed $varName) : mixed
Parameters
$varName : mixed
Return values
mixed

findVarByName()

public findVarByName(mixed $var_name) : mixed
Parameters
$var_name : mixed
Return values
mixed

getCss()

Get the current css buffer

public getCss() : string
Return values
string

getVariables()

this function gets the private rules variable and returns an array of the found variables it uses a helper method getVariableValue() that contains the logic ot fetch the value from the rule object

public getVariables() : array<string|int, mixed>
Return values
array<string|int, mixed>

is_method()

Some versions of php have trouble with method_exists($a,$b) if $a is not an object

public static is_method(mixed $a, string $b) : mixed
Parameters
$a : mixed
$b : string
Return values
mixed

ModifyVars()

Allows a user to set variables values

public ModifyVars(array<string|int, mixed> $vars) : Less_Parser
Parameters
$vars : array<string|int, mixed>
Return values
Less_Parser

NewObj0()

Create Less_Tree_* objects and optionally generate a cache string

public NewObj0(mixed $class) : mixed
Parameters
$class : mixed
Return values
mixed

NewObj1()

public NewObj1(mixed $class, mixed $arg) : mixed
Parameters
$class : mixed
$arg : mixed
Return values
mixed

NewObj2()

public NewObj2(mixed $class, mixed $args) : mixed
Parameters
$class : mixed
$args : mixed
Return values
mixed

NewObj3()

public NewObj3(mixed $class, mixed $args) : mixed
Parameters
$class : mixed
$args : mixed
Return values
mixed

NewObj4()

public NewObj4(mixed $class, mixed $args) : mixed
Parameters
$class : mixed
$args : mixed
Return values
mixed

NewObj5()

public NewObj5(mixed $class, mixed $args) : mixed
Parameters
$class : mixed
$args : mixed
Return values
mixed

NewObj6()

public NewObj6(mixed $class, mixed $args) : mixed
Parameters
$class : mixed
$args : mixed
Return values
mixed

NewObj7()

public NewObj7(mixed $class, mixed $args) : mixed
Parameters
$class : mixed
$args : mixed
Return values
mixed

ObjCache()

public ObjCache(mixed $obj, mixed $class[, mixed $args = array() ]) : mixed
Parameters
$obj : mixed
$class : mixed
$args : mixed = array()
Return values
mixed

parseAnonymousValue()

public parseAnonymousValue() : mixed
Return values
mixed

parseExtend()

public parseExtend([mixed $isRule = false ]) : mixed
Parameters
$isRule : mixed = false
Return values
mixed

parseFile()

Parse a Less string from a given file

public parseFile(string $filename[, string $uri_root = '' ][, bool $returnRoot = false ]) : Less_Tree_Ruleset|Less_Parser
Parameters
$filename : string

The file to parse

$uri_root : string = ''

The url of the file

$returnRoot : bool = false

Indicates whether the return value should be a css string a root node

Tags
throws
Less_Exception_Parser
Return values
Less_Tree_Ruleset|Less_Parser

parseUnicodeDescriptor()

public parseUnicodeDescriptor() : mixed
Return values
mixed

PeekChar()

public PeekChar(string $tok) : mixed
Parameters
$tok : string
Return values
mixed

PeekReg()

Same as match(), but don't change the state of the parser, just return the match.

public PeekReg(string $tok) : int
Parameters
$tok : string
Return values
int

registerFunction()

Registers a new custom function

public registerFunction(string $name, callable $callback) : mixed
Parameters
$name : string

function name

$callback : callable

callback

Return values
mixed

Reset()

Reset the parser state completely

public Reset([mixed $options = null ]) : mixed
Parameters
$options : mixed = null
Return values
mixed

round()

Round numbers similarly to javascript eg: 1.499999 to 1 instead of 2

public static round(mixed $i, mixed $precision) : mixed
Parameters
$i : mixed
$precision : mixed
Return values
mixed

save()

public save() : mixed
Return values
mixed

serializeVars()

public static serializeVars(mixed $vars) : mixed
Parameters
$vars : mixed
Return values
mixed

SetCacheDir()

public SetCacheDir(mixed $dir) : mixed
Parameters
$dir : mixed
Tags
deprecated
1.5.1.2
Return values
mixed

SetFileInfo()

public SetFileInfo(string $filename[, mixed $uri_root = '' ]) : mixed
Parameters
$filename : string
$uri_root : mixed = ''
Return values
mixed

SetImportDirs()

Set a list of directories or callbacks the parser should use for determining import paths

public SetImportDirs(array<string|int, mixed> $dirs) : mixed
Parameters
$dirs : array<string|int, mixed>
Return values
mixed

SetInput()

Set up the input buffer

public SetInput(mixed $file_path) : mixed
Parameters
$file_path : mixed
Return values
mixed

SetOption()

Set one compiler option

public SetOption(mixed $option, mixed $value) : mixed
Parameters
$option : mixed
$value : mixed
Return values
mixed

SetOptions()

Set one or more compiler options options: import_dirs, cache_dir, cache_method

public SetOptions(mixed $options) : mixed
Parameters
$options : mixed
Return values
mixed

skipWhitespace()

public skipWhitespace(int $length) : mixed
Parameters
$length : int
Return values
mixed

unregisterFunction()

Removed an already registered function

public unregisterFunction(string $name) : mixed
Parameters
$name : string

function name

Return values
mixed

UnsetInput()

Free up some memory

public UnsetInput() : mixed
Return values
mixed

WinPath()

public static WinPath(mixed $path) : mixed
Parameters
$path : mixed
Return values
mixed

_parse()

private _parse([string $file_path = null ]) : mixed
Parameters
$file_path : string = null
Return values
mixed

forget()

private forget() : mixed
Return values
mixed

FromKeyword()

private FromKeyword(mixed $keyword) : mixed
Parameters
$keyword : mixed
Return values
mixed

GetRules()

Return the results of parsePrimary for $file_path Use cache and save cached results if possible

private GetRules(string|null $file_path) : mixed
Parameters
$file_path : string|null
Return values
mixed

getVariableValue()

This method gets the value of the less variable from the rules object.

private getVariableValue( $var) : bool|string

Since the objects vary here we add the logic for extracting the css/less value.

Parameters
$var :
Return values
bool|string

isWhitespace()

Determine if the character at the specified offset from the current position is a white space.

private isWhitespace(int $offset) : bool
Parameters
$offset : int
Return values
bool

match()

Parse from a token, regexp or string, and move forward if match

private match(array<string|int, mixed> $toks) : array<string|int, mixed>
Parameters
$toks : array<string|int, mixed>
Return values
array<string|int, mixed>

MatchChar()

private MatchChar(mixed $tok) : mixed
Parameters
$tok : mixed
Return values
mixed

MatchFuncs()

private MatchFuncs(array<string|int, string> $toks) : string
Parameters
$toks : array<string|int, string>
Return values
string

MatchQuoted()

When PCRE JIT is enabled in php, regular expressions don't work for matching quoted strings

private MatchQuoted(mixed $quote_char, mixed $i) : mixed

$regex = '/\G'((?:[^'\\\r\n]|\\.|\\\r\n|\\[\n\r\f]))'/'; $regex = '/\G"((?:[^"\\\r\n]|\\.|\\\r\n|\\[\n\r\f]))"/';

Parameters
$quote_char : mixed
$i : mixed
Return values
mixed

MatchReg()

private MatchReg(mixed $tok) : mixed
Parameters
$tok : mixed
Return values
mixed

parseAlpha()

private parseAlpha() : mixed
Return values
mixed

parseAttribute()

private parseAttribute() : mixed
Return values
mixed

parseBlock()

private parseBlock() : mixed
Return values
mixed

parseBlockRuleset()

private parseBlockRuleset() : mixed
Return values
mixed

parseCombinator()

private parseCombinator() : mixed
Return values
mixed

parseComment()

private parseComment() : mixed
Return values
mixed

parseComments()

private parseComments() : mixed
Return values
mixed

parseCondition()

private parseCondition() : mixed
Return values
mixed

parseDetachedRuleset()

private parseDetachedRuleset() : mixed
Return values
mixed

parseDirective()

private parseDirective() : mixed
Return values
mixed

parseElement()

private parseElement() : mixed
Return values
mixed

parseEnd()

private parseEnd() : mixed
Return values
mixed

parseEntitiesArguments()

Parse a list of arguments

private parseEntitiesArguments() : array<string|int, mixed>
Return values
array<string|int, mixed>

parseEntitiesAssignment()

private parseEntitiesAssignment() : mixed
Return values
mixed

parseEntitiesCall()

private parseEntitiesCall() : mixed
Return values
mixed

parseEntitiesColor()

private parseEntitiesColor() : mixed
Return values
mixed

parseEntitiesDimension()

private parseEntitiesDimension() : mixed
Return values
mixed

parseEntitiesJavascript()

private parseEntitiesJavascript() : mixed
Return values
mixed

parseEntitiesKeyword()

private parseEntitiesKeyword() : mixed
Return values
mixed

parseEntitiesLiteral()

private parseEntitiesLiteral() : mixed
Return values
mixed

parseEntitiesQuoted()

private parseEntitiesQuoted() : mixed
Return values
mixed

parseEntitiesUrl()

private parseEntitiesUrl() : mixed
Return values
mixed

parseEntitiesVariable()

private parseEntitiesVariable() : mixed
Return values
mixed

parseEntitiesVariableCurly()

private parseEntitiesVariableCurly() : mixed
Return values
mixed

parseEntity()

private parseEntity() : mixed
Return values
mixed

parseImport()

private parseImport() : mixed
Return values
mixed

parseImportant()

private parseImportant() : mixed
Return values
mixed

parseImportOption()

private parseImportOption() : mixed
Return values
mixed

parseImportOptions()

private parseImportOptions() : mixed
Return values
mixed

parseLessSelector()

private parseLessSelector() : mixed
Return values
mixed

parseMedia()

private parseMedia() : mixed
Return values
mixed

parseMediaFeature()

private parseMediaFeature() : mixed
Return values
mixed

parseMediaFeatures()

private parseMediaFeatures() : mixed
Return values
mixed

parseMixinArgs()

private parseMixinArgs(bool $isCall) : mixed
Parameters
$isCall : bool
Return values
mixed

parseMixinCall()

private parseMixinCall() : mixed
Return values
mixed

parseMixinCallElements()

private parseMixinCallElements() : mixed
Return values
mixed

parseMixinDefinition()

private parseMixinDefinition() : mixed
Return values
mixed

parseNameValue()

Custom less.php parse function for finding simple name-value css pairs ex: width:100px;

private parseNameValue() : mixed
Return values
mixed

parseOperand()

An operand is anything that can be part of an operation, such as a Color, or a Variable

private parseOperand() : mixed
Return values
mixed

parsePrimary()

private parsePrimary() : mixed
Return values
mixed

parseProperty()

Parse a property eg: 'min-width', 'orientation', etc

private parseProperty() : string
Return values
string

parseRule()

private parseRule([mixed $tryAnonymous = null ]) : mixed
Parameters
$tryAnonymous : mixed = null
Return values
mixed

parseRuleProperty()

Parse a rule property eg: 'color', 'width', 'height', etc

private parseRuleProperty() : string
Return values
string

parseRuleset()

private parseRuleset() : mixed
Return values
mixed

parseRulesetCall()

private parseRulesetCall() : mixed
Return values
mixed

parseSelector()

private parseSelector([mixed $isLess = false ]) : mixed
Parameters
$isLess : mixed = false
Return values
mixed

parseSub()

private parseSub() : mixed
Return values
mixed

parseTag()

private parseTag() : mixed
Return values
mixed

parseValue()

private parseValue() : mixed
Return values
mixed

parseVariable()

private parseVariable() : mixed
Return values
mixed

PostVisitors()

Run post-compile visitors

private PostVisitors(mixed $evaldRoot) : mixed
Parameters
$evaldRoot : mixed
Return values
mixed

PreVisitors()

Run pre-compile visitors

private PreVisitors(mixed $root) : mixed
Parameters
$root : mixed
Return values
mixed

restore()

private restore() : mixed
Return values
mixed

rgb2html()

private rgb2html(mixed $r[, mixed $g = -1 ][, mixed $b = -1 ]) : mixed
Parameters
$r : mixed
$g : mixed = -1
$b : mixed = -1
Return values
mixed

rulePropertyMatch()

private rulePropertyMatch(mixed $re, mixed &$offset, mixed &$length, mixed &$index, mixed &$name) : mixed
Parameters
$re : mixed
$offset : mixed
$length : mixed
$index : mixed
$name : mixed
Return values
mixed

Search results