PHP Class Beans_Lessc, Beans

Converting LESS to CSS is a three stage process. The incoming file is parsed by lessc_parser into a syntax tree, then it is compiled into another tree representing the CSS structure by lessc. The CSS tree is fed into a formatter, like lessc_formatter which then outputs CSS as a string. During the first compile, all values are *reduced*, which means that their types are brought to the lowest form before being dump as strings. This handles math equations, variable dereferences, and the like. The parse function of lessc is the entry point. In summary: The lessc class creates an intstance of the parser, feeds it LESS code, then transforms the resulting tree to a CSS tree. This class also holds the evaluation context, such as all available mixins and variables at any given time. The lessc_parser class is only concerned with parsing its input. The lessc_formatter takes a CSS tree, and dumps it to a formatted string, handling things like indentation.
Afficher le fichier Open project: Getbeans/Beans Class Usage Examples

Méthodes publiques

Свойство Type Description
$VERSION
$defaultValue
$importDir
$importDisabled
$mPrefix prefix of abstract properties
$parentSelector prefix of abstract blocks
$vPrefix

Protected Properties

Свойство Type Description
$FALSE
$TRUE
$allParsedFiles
$cssColors
$libFunctions
$nextImportId
$numberPrecision
$preserveComments
$registeredVars
$sourceLoc
$sourceParser so we know how to create error messages

Méthodes publiques

Méthode Description
__construct ( $fname = null ) Initialize any static state, can initialize parser for a file $opts isn't used yet
addImportDir ( $dir )
allParsedFiles ( )
cachedCompile ( mixed $in, boolean $force = false ) : array Execute lessphp on a .less file or a lessphp cache structure
ccompile ( $in, $out, $less = null ) returns true when it compiles, false otherwise
cexecute ( $in, $force = false, $less = null )
checkedCompile ( $in, $out ) compile only if changed input has changed or output doesn't exist
compile ( $string, $name = null )
compileFile ( $fname, $outFname = null )
compressList ( $items, $delim )
lib_blue ( $color )
lib_green ( $color )
lib_red ( $color )
parse ( $str = null, $initialVariables = null ) This is deprecated
preg_quote ( $what )
registerFunction ( $name, $func )
setFormatter ( $name )
setImportDir ( $dirs )
setPreserveComments ( $preserve )
setVariables ( $variables )
unregisterFunction ( $name )
unsetVariable ( $name )

Méthodes protégées

Méthode Description
addParsedFile ( $file )
assertArgs ( $value, $expectedArgs, $name = "" )
assertColor ( $value, $error = "expected color value" )
assertNumber ( $value, $error = "expecting number" )
clamp ( $v, $max = 1, $min )
coerceColor ( $value ) coerce a value for use in color operation
coerceString ( $value ) make something string like into a string
colorArgs ( $args ) Helper function to get arguments for color manipulation functions.
compileBlock ( $block ) Recursively compiles a block.
compileCSSBlock ( $block )
compileImportedProps ( $props, $block, $out, $sourceParser, $importDir )
compileMedia ( $media )
compileMediaQuery ( $queries )
compileNestedBlock ( $block, $selectors )
compileProp ( $prop, $block, $out ) compile a prop and update $lines or $blocks appropriately
compileProps ( $block, $out )
compileRoot ( $root )
compileSelectors ( $selectors ) reduces selector expressions
compileValue ( $value ) Compiles a primitive value into a CSS property value.
eq ( $left, $right )
evaluate ( $exp ) evaluate an expression
expandParentSelectors ( &$tag, $replace )
fileExists ( $name )
findBlocks ( $searchIn, $path, $orderedArgs, $keywordArgs, $seen = [] ) attempt to find blocks matched by path and args
findClosestSelectors ( )
findImport ( $url ) attempts to find the path of an import url, returns null for css files
fixColor ( $c ) make sure a color's components don't go out of bounds
flattenList ( $value ) turn list of length 1 into value type
funcToColor ( $func ) Convert the rgb, rgba, hsl color literals of function type as returned by the parser into values of color type.
get ( $name, $default = null ) get the highest occurrence entry for a name
injectVariables ( $args ) inject array of unparsed strings into environment as variables
lib__sprintf ( $args )
lib_acos ( $num )
lib_alpha ( $value ) defaults to 1 for non-colors or colors without an alpha
lib_argb ( $color )
lib_asin ( $num )
lib_atan ( $num )
lib_ceil ( $arg )
lib_contrast ( $args )
lib_cos ( $num )
lib_darken ( $args )
lib_desaturate ( $args )
lib_e ( ) use func_get_arg to prevent Theme Checker triggering unrelated translation warning.
lib_extract ( $value )
lib_fade ( $args ) set the alpha of the color
lib_fadein ( $args )
lib_fadeout ( $args )
lib_floor ( $arg )
lib_hue ( $color )
lib_iscolor ( $value )
lib_isem ( $value )
lib_iskeyword ( $value )
lib_isnumber ( $value )
lib_ispercentage ( $value )
lib_ispixel ( $value )
lib_isrem ( $value )
lib_isstring ( $value )
lib_lighten ( $args )
lib_lightness ( $color )
lib_mix ( $args ) http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#mix-instance_method
lib_mod ( $args )
lib_percentage ( $arg )
lib_pi ( )
lib_pow ( $args )
lib_rgbahex ( $color )
lib_round ( $arg )
lib_saturate ( $args )
lib_saturation ( $color )
lib_sin ( $num )
lib_spin ( $args )
lib_sqrt ( $num )
lib_tan ( $num )
lib_unit ( $arg )
lib_unquote ( $arg ) use func_get_arg to prevent Theme Checker triggering unrelated translation warning.
makeOutputBlock ( $type, $selectors = null ) * environment functions
makeParser ( $name )
mediaParent ( $scope )
multiplyMedia ( $env, $childQueries = null )
multiplySelectors ( $selectors ) multiply $selectors against the nearest selectors in env
newFormatter ( )
op_color_color ( $op, $left, $right )
op_color_number ( $op, $lft, $rgt )
op_number_color ( $op, $lft, $rgt )
op_number_number ( $op, $left, $right ) operator on two numbers
patternMatch ( $block, $orderedArgs, $keywordArgs )
patternMatchAll ( $blocks, $orderedArgs, $keywordArgs, $skip = [] )
popEnv ( ) pop something off the stack
pushEnv ( $block = null ) the state of execution
reduce ( $value, $forExpression = false )
set ( $name, $value ) set something in the current env
sortProps ( $props, $split = false )
stringConcatenate ( $left, $right )
throwError ( $msg = null ) Uses the current value of $this->count to show line and line number
toBool ( $a )
toHSL ( $color )
toRGB ( $color ) Converts a hsl array into a color value in rgb.
toRGB_helper ( $comp, $temp1, $temp2 )
tryImport ( $importPath, $parentBlock, $out )
zipSetArgs ( $args, $orderedValues, $keywordValues ) or the one passed in through $values

Method Details

__construct() public méthode

Initialize any static state, can initialize parser for a file $opts isn't used yet
public __construct ( $fname = null )

addImportDir() public méthode

public addImportDir ( $dir )

addParsedFile() protected méthode

protected addParsedFile ( $file )

allParsedFiles() public méthode

public allParsedFiles ( )

assertArgs() protected méthode

protected assertArgs ( $value, $expectedArgs, $name = "" )

assertColor() protected méthode

protected assertColor ( $value, $error = "expected color value" )

assertNumber() protected méthode

protected assertNumber ( $value, $error = "expecting number" )

cachedCompile() public méthode

The lessphp cache structure contains information about a specific less file having been parsed. It can be used as a hint for future calls to determine whether or not a rebuild is required. The cache structure contains two important keys that may be used externally: compiled: The final compiled CSS updated: The time (in seconds) the CSS was last compiled The cache structure is a plain-ol' PHP associative array and can be serialized and unserialized without a hitch.
public cachedCompile ( mixed $in, boolean $force = false ) : array
$in mixed Input
$force boolean Force rebuild?
Résultat array lessphp cache structure

ccompile() public static méthode

returns true when it compiles, false otherwise
public static ccompile ( $in, $out, $less = null )

cexecute() public static méthode

public static cexecute ( $in, $force = false, $less = null )

checkedCompile() public méthode

compile only if changed input has changed or output doesn't exist
public checkedCompile ( $in, $out )

clamp() protected méthode

protected clamp ( $v, $max = 1, $min )

coerceColor() protected méthode

coerce a value for use in color operation
protected coerceColor ( $value )

coerceString() protected méthode

make something string like into a string
protected coerceString ( $value )

colorArgs() protected méthode

takes a list that contains a color like thing and a percentage
protected colorArgs ( $args )

compile() public méthode

public compile ( $string, $name = null )

compileBlock() protected méthode

A block is analogous to a CSS block in most cases. A single LESS document is encapsulated in a block when parsed, but it does not have parent tags so all of it's children appear on the root level when compiled. Blocks are made up of props and children. Props are property instructions, array tuples which describe an action to be taken, eg. write a property, set a variable, mixin a block. The children of a block are just all the blocks that are defined within. This is used to look up mixins when performing a mixin. Compiling the block involves pushing a fresh environment on the stack, and iterating through the props, compiling each one. See lessc::compileProp()
protected compileBlock ( $block )

compileCSSBlock() protected méthode

protected compileCSSBlock ( $block )

compileFile() public méthode

public compileFile ( $fname, $outFname = null )

compileImportedProps() protected méthode

protected compileImportedProps ( $props, $block, $out, $sourceParser, $importDir )

compileMedia() protected méthode

protected compileMedia ( $media )

compileMediaQuery() protected méthode

protected compileMediaQuery ( $queries )

compileNestedBlock() protected méthode

protected compileNestedBlock ( $block, $selectors )

compileProp() protected méthode

compile a prop and update $lines or $blocks appropriately
protected compileProp ( $prop, $block, $out )

compileProps() protected méthode

protected compileProps ( $block, $out )

compileRoot() protected méthode

protected compileRoot ( $root )

compileSelectors() protected méthode

reduces selector expressions
protected compileSelectors ( $selectors )

compileValue() protected méthode

Values in lessphp are typed by being wrapped in arrays, their format is typically: array(type, contents [, additional_contents]*) The input is expected to be reduced. This function will not work on things like expressions and variables.
protected compileValue ( $value )

compressList() public static méthode

public static compressList ( $items, $delim )

eq() protected méthode

protected eq ( $left, $right )

evaluate() protected méthode

evaluate an expression
protected evaluate ( $exp )

expandParentSelectors() protected méthode

protected expandParentSelectors ( &$tag, $replace )

fileExists() protected méthode

protected fileExists ( $name )

findBlocks() protected méthode

attempt to find blocks matched by path and args
protected findBlocks ( $searchIn, $path, $orderedArgs, $keywordArgs, $seen = [] )

findClosestSelectors() protected méthode

protected findClosestSelectors ( )

findImport() protected méthode

attempts to find the path of an import url, returns null for css files
protected findImport ( $url )

fixColor() protected méthode

make sure a color's components don't go out of bounds
protected fixColor ( $c )

flattenList() protected méthode

turn list of length 1 into value type
protected flattenList ( $value )

funcToColor() protected méthode

Convert the rgb, rgba, hsl color literals of function type as returned by the parser into values of color type.
protected funcToColor ( $func )

get() protected méthode

get the highest occurrence entry for a name
protected get ( $name, $default = null )

injectVariables() protected méthode

inject array of unparsed strings into environment as variables
protected injectVariables ( $args )

lib__sprintf() protected méthode

protected lib__sprintf ( $args )

lib_acos() protected méthode

protected lib_acos ( $num )

lib_alpha() protected méthode

defaults to 1 for non-colors or colors without an alpha
protected lib_alpha ( $value )

lib_argb() protected méthode

protected lib_argb ( $color )

lib_asin() protected méthode

protected lib_asin ( $num )

lib_atan() protected méthode

protected lib_atan ( $num )

lib_blue() public méthode

public lib_blue ( $color )

lib_ceil() protected méthode

protected lib_ceil ( $arg )

lib_contrast() protected méthode

protected lib_contrast ( $args )

lib_cos() protected méthode

protected lib_cos ( $num )

lib_darken() protected méthode

protected lib_darken ( $args )

lib_desaturate() protected méthode

protected lib_desaturate ( $args )

lib_e() protected méthode

use func_get_arg to prevent Theme Checker triggering unrelated translation warning.
protected lib_e ( )

lib_extract() protected méthode

protected lib_extract ( $value )

lib_fade() protected méthode

set the alpha of the color
protected lib_fade ( $args )

lib_fadein() protected méthode

protected lib_fadein ( $args )

lib_fadeout() protected méthode

protected lib_fadeout ( $args )

lib_floor() protected méthode

protected lib_floor ( $arg )

lib_green() public méthode

public lib_green ( $color )

lib_hue() protected méthode

protected lib_hue ( $color )

lib_iscolor() protected méthode

protected lib_iscolor ( $value )

lib_isem() protected méthode

protected lib_isem ( $value )

lib_iskeyword() protected méthode

protected lib_iskeyword ( $value )

lib_isnumber() protected méthode

protected lib_isnumber ( $value )

lib_ispercentage() protected méthode

protected lib_ispercentage ( $value )

lib_ispixel() protected méthode

protected lib_ispixel ( $value )

lib_isrem() protected méthode

protected lib_isrem ( $value )

lib_isstring() protected méthode

protected lib_isstring ( $value )

lib_lighten() protected méthode

protected lib_lighten ( $args )

lib_lightness() protected méthode

protected lib_lightness ( $color )

lib_mix() protected méthode

http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#mix-instance_method
protected lib_mix ( $args )

lib_mod() protected méthode

protected lib_mod ( $args )

lib_percentage() protected méthode

protected lib_percentage ( $arg )

lib_pi() protected méthode

protected lib_pi ( )

lib_pow() protected méthode

protected lib_pow ( $args )

lib_red() public méthode

public lib_red ( $color )

lib_rgbahex() protected méthode

protected lib_rgbahex ( $color )

lib_round() protected méthode

protected lib_round ( $arg )

lib_saturate() protected méthode

protected lib_saturate ( $args )

lib_saturation() protected méthode

protected lib_saturation ( $color )

lib_sin() protected méthode

protected lib_sin ( $num )

lib_spin() protected méthode

protected lib_spin ( $args )

lib_sqrt() protected méthode

protected lib_sqrt ( $num )

lib_tan() protected méthode

protected lib_tan ( $num )

lib_unit() protected méthode

protected lib_unit ( $arg )

lib_unquote() protected méthode

use func_get_arg to prevent Theme Checker triggering unrelated translation warning.
protected lib_unquote ( $arg )

makeOutputBlock() protected méthode

* environment functions
protected makeOutputBlock ( $type, $selectors = null )

makeParser() protected méthode

protected makeParser ( $name )

mediaParent() protected méthode

protected mediaParent ( $scope )

multiplyMedia() protected méthode

protected multiplyMedia ( $env, $childQueries = null )

multiplySelectors() protected méthode

multiply $selectors against the nearest selectors in env
protected multiplySelectors ( $selectors )

newFormatter() protected méthode

protected newFormatter ( )

op_color_color() protected méthode

protected op_color_color ( $op, $left, $right )

op_color_number() protected méthode

protected op_color_number ( $op, $lft, $rgt )

op_number_color() protected méthode

protected op_number_color ( $op, $lft, $rgt )

op_number_number() protected méthode

operator on two numbers
protected op_number_number ( $op, $left, $right )

parse() public méthode

This is deprecated
public parse ( $str = null, $initialVariables = null )

patternMatch() protected méthode

protected patternMatch ( $block, $orderedArgs, $keywordArgs )

patternMatchAll() protected méthode

protected patternMatchAll ( $blocks, $orderedArgs, $keywordArgs, $skip = [] )

popEnv() protected méthode

pop something off the stack
protected popEnv ( )

preg_quote() public static méthode

public static preg_quote ( $what )

pushEnv() protected méthode

the state of execution
protected pushEnv ( $block = null )

reduce() protected méthode

protected reduce ( $value, $forExpression = false )

registerFunction() public méthode

public registerFunction ( $name, $func )

set() protected méthode

set something in the current env
protected set ( $name, $value )

setFormatter() public méthode

public setFormatter ( $name )

setImportDir() public méthode

public setImportDir ( $dirs )

setPreserveComments() public méthode

public setPreserveComments ( $preserve )

setVariables() public méthode

public setVariables ( $variables )

sortProps() protected méthode

protected sortProps ( $props, $split = false )

stringConcatenate() protected méthode

protected stringConcatenate ( $left, $right )

throwError() protected méthode

Uses the current value of $this->count to show line and line number
protected throwError ( $msg = null )

toBool() protected méthode

protected toBool ( $a )

toHSL() protected méthode

protected toHSL ( $color )

toRGB() protected méthode

Expects H to be in range of 0 to 360, S and L in 0 to 100
protected toRGB ( $color )

toRGB_helper() protected méthode

protected toRGB_helper ( $comp, $temp1, $temp2 )

tryImport() protected méthode

protected tryImport ( $importPath, $parentBlock, $out )

unregisterFunction() public méthode

public unregisterFunction ( $name )

unsetVariable() public méthode

public unsetVariable ( $name )

zipSetArgs() protected méthode

or the one passed in through $values
protected zipSetArgs ( $args, $orderedValues, $keywordValues )

Property Details

$FALSE protected_oe static_oe property

protected static $FALSE

$TRUE protected_oe static_oe property

protected static $TRUE

$VERSION public_oe static_oe property

public static $VERSION

$allParsedFiles protected_oe property

protected $allParsedFiles

$cssColors protected_oe static_oe property

protected static $cssColors

$defaultValue public_oe static_oe property

public static $defaultValue

$importDir public_oe property

public $importDir

$importDisabled public_oe property

public $importDisabled

$libFunctions protected_oe property

protected $libFunctions

$mPrefix public_oe property

prefix of abstract properties
public $mPrefix

$nextImportId protected_oe static_oe property

protected static $nextImportId

$numberPrecision protected_oe property

protected $numberPrecision

$parentSelector public_oe property

prefix of abstract blocks
public $parentSelector

$preserveComments protected_oe property

protected $preserveComments

$registeredVars protected_oe property

protected $registeredVars

$sourceLoc protected_oe property

protected $sourceLoc

$sourceParser protected_oe property

so we know how to create error messages
protected $sourceParser

$vPrefix public_oe property

public $vPrefix