Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
ScssPhp\ScssPhp\Compiler Class Reference

The scss compiler and parser. More...

Inheritance diagram for ScssPhp\ScssPhp\Compiler:
core_scss

Public Member Functions

 addFeature ($name)
 Add feature.
 
 addImportPath ($path)
 Add import path.
 
 addParsedFile ($path)
 Adds to list of parsed files.
 
 addVariables (array $variables)
 Replaces variables.
 
 assertColor ($value, $varName=null)
 Assert value is a color.
 
 assertInteger ($value, $varName=null)
 Assert value is a integer.
 
 assertList ($value)
 Assert value is a list.
 
 assertMap ($value, $varName=null)
 Assert value is a map.
 
 assertNumber ($value, $varName=null)
 Assert value is a number.
 
 assertString ($value, $varName=null)
 Assert value is a string.
 
 compile ($code, $path=null)
 Compile scss.
 
 compileString ($source, $path=null)
 Compile scss.
 
 compileValue ($value, $quote=true)
 Compiles a primitive value into a CSS property value.
 
 error ($msg,... $args)
 Build an error (exception)
 
 errorArgsNumber ($functionName, $ExpectedArgs, $nbActual)
 
 escapeNonPrintableChars ($string, $inKeyword=false)
 Escape non printable chars in strings output as in dart-sass.
 
 findImport ($url, $currentDir=null)
 Return the file path for an import url if it exists.
 
 get ($name, $shouldThrow=true, Environment $env=null, $unreduced=false)
 Get variable.
 
 getArgumentListKeywords ($value)
 Gets the keywords of an argument list.
 
 getCompileOptions ()
 Get compiler options.
 
 getParsedFiles ()
 Returns list of parsed files.
 
 getSourcePosition ()
 Get source position.
 
 getStringText (array $value)
 Gets the text of a Sass string.
 
 getVariables ()
 Returns list of variables.
 
 isTruthy ($value)
 Is truthy?
 
 normalizeValue ($value)
 Normalize value.
 
 registerFunction ($name, $callback, $argumentDeclaration=null)
 Register function.
 
 replaceVariables (array $variables)
 Replaces variables.
 
 setCharset ($charset)
 Configures the handling of non-ASCII outputs.
 
 setEncoding ($encoding)
 Set encoding.
 
 setErrorOuput ($handle)
 Set an alternative error output stream, for testing purpose only.
 
 setFormatter ($formatterName)
 Set formatter.
 
 setIgnoreErrors ($ignoreErrors)
 Ignore errors?
 
 setImportPaths ($path)
 Set import paths.
 
 setLineNumberStyle ($lineNumberStyle)
 Set line number style.
 
 setLogger (LoggerInterface $logger)
 Sets an alternative logger.
 
 setNumberPrecision ($numberPrecision)
 Set number precision.
 
 setOutputStyle ($style)
 Sets the output style.
 
 setSourceMap ($sourceMap)
 Enable/disable source maps.
 
 setSourceMapOptions ($sourceMapOptions)
 Set source map options.
 
 setVariables (array $variables)
 Set variables.
 
 throwError ($msg)
 Throw error (exception)
 
 toBool ($thing)
 Cast to boolean.
 
 toHSL ($red, $green, $blue)
 Convert RGB to HSL.
 
 toRGB ($hue, $saturation, $lightness)
 Convert HSL to RGB.
 
 unregisterFunction ($name)
 Unregister function.
 
 unsetVariable ($name)
 Unset variable.
 

Static Public Member Functions

static isCssImport ($url)
 Detects whether the import is a CSS import.
 
static isNativeFunction ($name)
 Check if a function is a native built-in scss function, for css parsing.
 
static normalizeNativeFunctionName ($name)
 Normalize native function name.
 

Public Attributes

const DEBUG_INFO = 2
 
const LINE_COMMENTS = 1
 
const SOURCE_MAP_FILE = 2
 
const SOURCE_MAP_INLINE = 1
 
const SOURCE_MAP_NONE = 0
 
const WITH_ALL = 7
 
const WITH_MEDIA = 2
 
const WITH_RULE = 1
 
const WITH_SUPPORTS = 4
 

Static Public Attributes

static $defaultValue = [Type::T_KEYWORD, '']
 
static $emptyList = [Type::T_LIST, '', []]
 
static $emptyMap = [Type::T_MAP, [], []]
 
static $emptyString = [Type::T_STRING, '"', []]
 
static $false = [Type::T_KEYWORD, 'false']
 
static $Infinity = [Type::T_KEYWORD, 'Infinity']
 
static $NaN = [Type::T_KEYWORD, 'NaN']
 
static $null = [Type::T_NULL]
 
static $nullString = [Type::T_STRING, '', []]
 
static $selfSelector = [Type::T_SELF]
 
static static static $true = [Type::T_KEYWORD, 'true']
 
static $with = [Type::T_KEYWORD, 'with']
 
static $without = [Type::T_KEYWORD, 'without']
 

Protected Member Functions

 adjustHsl ($color, $idx, $amount)
 
 alterColor (array $args, $operation, $fn)
 Helper function for adjust_color, change_color, and scale_color.
 
 appendOutputLine (OutputBlock $out, $type, $line)
 Append lines to the current output block: directly to the block or through a child if necessary.
 
 appendRootDirective ($line, $out, $allowed=[Type::T_COMMENT])
 Append a root directive like @import or @charset as near as the possible from the source code (keeping before comments, @import and @charset coming before in the source code)
 
 applyArguments ($argDef, $argValues, $storeInEnv=true, $reduce=true)
 Apply argument values per definition.
 
 backPropagateEnv ($store, $excludedVars=null)
 Propagate vars from a just poped Env (used in @each and @for)
 
 callNativeFunction ($name, $function, $prototype, $args)
 Call built-in and registered (PHP) functions.
 
 callScssFunction ($func, $argValues)
 Call SCSS @function.
 
 callStackMessage ($all=false, $limit=null)
 Beautify call stack for output.
 
 checkCompatibleTags ($tag1, $tag2)
 Check the compatibility between two tag names: if both are defined they should be identical or one has to be '*'.
 
 checkSelectorArgType ($arg, $maxDepth=2)
 Check variable type for getSelectorArg() function.
 
 coerceColor ($value, $inRGBFunction=false)
 Coerce value to color.
 
 coerceForExpression ($value)
 Coerce color for expression.
 
 coerceList ($item, $delim=',', $removeTrailingNull=false)
 Coerce something to list.
 
 coerceMap ($item)
 Coerce something to map.
 
 coercePercent ($value)
 Coerce value to a percentage.
 
 coerceString ($value)
 Coerce value to string.
 
 coerceValue ($value)
 Coerce a php value into a scss one.
 
 collapseSelectors ($selectors)
 Collapse selectors.
 
 combineSelectorSingle ($base, $other)
 Combine selector single.
 
 compactEnv (Environment $env)
 Convert env linked list to stack.
 
 compileAtRoot (Block $block)
 Compile at-root.
 
 compileBlock (Block $block)
 Recursively compiles a block.
 
 compileChild ($child, OutputBlock $out)
 Compile child; returns a value to halt execution.
 
 compileChildren ($stms, OutputBlock $out, $traceName='')
 Compile children and return result.
 
 compileChildrenNoReturn ($stms, OutputBlock $out, $selfParent=null, $traceName='')
 Compile children and throw exception if unexpected at-return.
 
 compileColorPartValue ($value, $min, $max, $isInt=true)
 
 compileComment ($block)
 Compile root level comment.
 
 compileCommentValue ($value, $pushEnv=false)
 Compile the value of a comment that can have interpolation.
 
 compileDebugValue ($value)
 
 compileDirective ($directive, OutputBlock $out)
 Compile directive.
 
 compileDirectiveName ($directiveName)
 directive names can include some interpolation
 
 compileImport ($rawPath, OutputBlock $out, $once=false)
 Compile import; returns true if the value was something that could be imported.
 
 compileImportPath ($rawPath)
 
 compileKeyframeBlock (Block $block, $selectors)
 Compile keyframe block.
 
 compileMedia (Block $media)
 Compile media.
 
 compileMediaQuery ($queryList)
 Compile media query.
 
 compileNestedBlock (Block $block, $selectors)
 Compile nested block.
 
 compileNestedPropertiesBlock (Block $block, OutputBlock $out)
 Compile nested properties lines.
 
 compileRGBAValue ($value, $isAlpha=false)
 
 compileRoot (Block $rootBlock)
 Compile root.
 
 compileSelector ($selector)
 Compile selector to string; self(&) should have been replaced by now.
 
 compileSelectorPart ($piece)
 Compile selector part.
 
 compileStringContent ($string, $quote=true)
 Compile string content.
 
 compileWith ($withCondition)
 Compile @at-root's with: inclusion / without: exclusion into 2 lists uses to filter scope/env later.
 
 completeScope ($scope, $previousScope)
 found missing selector from a at-root compilation in the previous scope (if at-root is just enclosing a property, the selector is in the parent tree)
 
 cssValidArg ($arg, $allowed_function=[], $inFunction=false)
 
 escapeImportPathString ($path)
 
 evalSelector ($selector)
 Evaluate selector.
 
 evalSelectorPart ($part)
 Evaluate selector part; replaces all the interpolates, stripping quotes.
 
 evalSelectors ($selectors)
 Evaluate selectors.
 
 evaluateMediaQuery ($queryList)
 evaluate media query : compile internal value keeping the structure unchanged
 
 expToString ($exp, $keepParens=false)
 Reduce expression to string.
 
 extendOrReplaceSelectors ($selectors, $extendee, $extender, $replace=false)
 Extend/replace in selectors used by selector-extend and selector-replace that use the same logic.
 
 extractEnv ($envs)
 Convert env stack to singly linked list.
 
 extractInterpolation ($list)
 Extract interpolation; it doesn't need to be recursive, compileValue will handle that.
 
 extractRelationshipFromFragment (array $fragment)
 Extract a relationship from the fragment.
 
 filterScopeWithWithout ($scope, $with, $without)
 Filter at-root scope depending on with/without option.
 
 filterWithWithout ($envs, $with, $without)
 Filter env stack.
 
 findScopeSelectors ($scope, $depth)
 Find a selector by the depth node in the scope.
 
 findTagName ($parts)
 Find the html tag name in a selector parts list.
 
 fixColor ($c)
 Make sure a color's components don't go out of bounds.
 
 flattenList ($list)
 Flatten list.
 
 flattenSelectors (OutputBlock $block, $parentKey=null)
 Flatten selectors.
 
 flattenSelectorSingle ($single)
 Flatten selector single; joins together .classes and ids.
 
 fncall ($functionReference, $argValues)
 Function caller.
 
 formatOutputSelector ($selectors)
 Postprocess selector to output in right format.
 
 getBuiltinFunction ($name)
 Get built-in function.
 
 getFunctionReference ($name, $safeCopy=false)
 Find a function reference.
 
 getSelectorArg ($arg, $varname=null, $allowParent=false)
 Preprocess selector args.
 
 getStoreEnv ()
 Get store environment.
 
 glueFunctionSelectors ($parts)
 Glue parts of :not( or :nth-child( ... that are in general split in selectors parts.
 
 handleImportLoop ($name)
 Handle import loop.
 
 has ($name, Environment $env=null)
 Has variable?
 
 hasSelectorPlaceholder ($selector)
 Has selector placeholder?
 
 hueToRGB ($m1, $m2, $h)
 Hue to RGB helper.
 
 importFile ($path, OutputBlock $out)
 Import file.
 
 injectVariables (array $args)
 Inject variables.
 
 inspectFormatValue ($value, $force_enclosing_display=false)
 
 isImmediateRelationshipCombinator ($value)
 Is the value a direct relationship combinator?
 
 isPseudoSelector ($part, &$matches)
 Test a part for being a pseudo selector.
 
 isSelfExtend ($target, $origin)
 Is self extend?
 
 isSuperPart ($superParts, $subParts)
 Test a part of super selector again a part of sub selector.
 
 isSuperSelector ($super, $sub)
 Test a $super selector again $sub.
 
 isWith ($block, $with, $without)
 Filter WITH rules.
 
 joinSelectors ($parent, $child, &$stillHasSelf, $selfParentSelectors=null)
 Join selectors; looks for & to replace, or append parent before child.
 
 libAbs ($args)
 
 libAdjustColor ($args)
 
 libAdjustHue ($args)
 
 libAlpha ($args)
 
 libAppend ($args)
 
 libBlue ($args)
 
 libCall ($args)
 
 libCeil ($args)
 
 libChangeColor ($args)
 
 libComparable ($args)
 
 libComplement ($args)
 
 libCounter ($args)
 Workaround IE7's content counter bug.
 
 libDarken ($args)
 
 libDesaturate ($args)
 
 libFadeIn ($args)
 
 libFadeOut ($args)
 
 libFeatureExists ($args)
 
 libFloor ($args)
 
 libFunctionExists ($args)
 
 libGetFunction ($args)
 
 libGlobalVariableExists ($args)
 
 libGrayscale ($args)
 
 libGreen ($args)
 
 libHsl ($args, $kwargs, $funcName='hsl')
 
 libHsla ($args, $kwargs)
 
 libHue ($args)
 
 libIeHexStr ($args)
 
 libIf ($args)
 
 libIndex ($args)
 
 libInspect ($args)
 
 libInvert ($args)
 
 libIsBracketed ($args)
 
 libIsSuperselector ($args)
 
 libJoin ($args)
 
 libKeywords ($args)
 
 libLength ($args)
 
 libLighten ($args)
 
 libLightness ($args)
 
 libListSeparator ($args)
 
 libMapGet ($args)
 
 libMapHasKey ($args)
 
 libMapKeys ($args)
 
 libMapMerge ($args)
 
 libMapRemove ($args)
 
 libMapValues ($args)
 
 libMax ($args)
 
 libMin ($args)
 
 libMix ($args)
 
 libMixinExists ($args)
 
 libNth ($args)
 
 libOpacify ($args)
 
 libOpacity ($args)
 
 libPercentage ($args)
 
 libQuote ($args)
 
 libRandom ($args)
 
 libRed ($args)
 
 libRgb ($args, $kwargs, $funcName='rgb')
 
 libRgba ($args, $kwargs)
 
 libRound ($args)
 
 libSaturate ($args)
 
 libSaturation ($args)
 
 libScaleColor ($args)
 
 libScssphpGlob ($args)
 
 libSelectorAppend ($args)
 
 libSelectorExtend ($args)
 
 libSelectorNest ($args)
 
 libSelectorParse ($args)
 
 libSelectorReplace ($args)
 
 libSelectorUnify ($args)
 
 libSetNth ($args)
 
 libSimpleSelectors ($args)
 
 libStrIndex ($args)
 
 libStrInsert ($args)
 
 libStrLength ($args)
 
 libStrSlice ($args)
 
 libToLowerCase ($args)
 
 libToUpperCase ($args)
 
 libTransparentize ($args)
 
 libTypeOf ($args)
 
 libUniqueId ()
 
 libUnit ($args)
 
 libUnitless ($args)
 
 libUnquote ($args)
 
 libVariableExists ($args)
 
 libZip ($args)
 
 listSeparatorForJoin ($list1, $sep)
 
 makeOutputBlock ($type, $selectors=null)
 Make output block.
 
 matchExtends ($selector, &$out, $from=0, $initial=true)
 Match extends.
 
 matchExtendsSingle ($rawSingle, &$outOrigin, $initial=true)
 Match extends single.
 
 matchPartInCompound ($part, $compound)
 Try to find a matching part in a compound:
 
 mediaParent (OutputBlock $scope)
 Media parent.
 
 mergeDirectRelationships ($selectors1, $selectors2)
 Merge direct relationships between selectors.
 
 mergeMediaTypes ($type1, $type2)
 Merge media types.
 
 mergeParts ($parts1, $parts2)
 Merge two part list taking care that.
 
 missingSelectors ()
 Report missing selectors.
 
 multiplyMedia (Environment $env=null, $childQueries=null)
 Multiply media.
 
 multiplySelectors (Environment $env, $selfParent=null)
 Find the final set of selectors.
 
 normalizeName ($name)
 Normalize name.
 
 opAdd ($left, $right)
 Add strings.
 
 opAddNumberNumber (Number $left, Number $right)
 Add numbers.
 
 opAnd ($left, $right, $shouldEval)
 Boolean and.
 
 opColorColor ($op, $left, $right)
 Compare colors.
 
 opColorNumber ($op, $left, Number $right)
 Compare color and number.
 
 opDivNumberNumber (Number $left, Number $right)
 Divide numbers.
 
 opEq ($left, $right)
 Compare number1 == number2.
 
 opEqNumberNumber (Number $left, Number $right)
 Compare number1 == number2.
 
 opGteNumberNumber (Number $left, Number $right)
 Compare number1 >= number2.
 
 opGtNumberNumber (Number $left, Number $right)
 Compare number1 > number2.
 
 opLteNumberNumber (Number $left, Number $right)
 Compare number1 <= number2.
 
 opLtNumberNumber (Number $left, Number $right)
 Compare number1 < number2.
 
 opModNumberNumber (Number $left, Number $right)
 Mod numbers.
 
 opMulNumberNumber (Number $left, Number $right)
 Multiply numbers.
 
 opNeq ($left, $right)
 Compare number1 != number2.
 
 opNeqNumberNumber (Number $left, Number $right)
 Compare number1 != number2.
 
 opNumberColor ($op, Number $left, $right)
 Compare number and color.
 
 opOr ($left, $right, $shouldEval)
 Boolean or.
 
 opSubNumberNumber (Number $left, Number $right)
 Subtract numbers.
 
 parserFactory ($path)
 Instantiate parser.
 
 popCallStack ()
 
 popEnv ()
 Pop environment.
 
 prependSelectors ($selectors, $parts)
 Prepend each selector from $selectors with $parts.
 
 pushCallStack ($name='')
 
 pushEnv (Block $block=null)
 Push environment.
 
 pushExtends ($target, $origin, $block)
 Push extends.
 
 pushOrMergeExtentedSelector (&$out, $extended)
 Push extended selector except if.
 
 reduce ($value, $inExp=false)
 Reduce value.
 
 replaceSelfSelector ($selectors, $replace=null)
 Parse down the selector and revert [self] to "&" before a reparsing.
 
 selectorAppend ($selectors)
 Append parts of the last selector in the list to the previous, recursively.
 
 set ($name, $value, $shadow=false, Environment $env=null, $valueUnreduced=null)
 Set variable.
 
 setExisting ($name, $value, Environment $env, $valueUnreduced=null)
 Set existing variable.
 
 setRaw ($name, $value, Environment $env, $valueUnreduced=null)
 Set raw variable.
 
 shouldEval ($value)
 Should $value cause its operand to eval.
 
 sortNativeFunctionArgs ($functionName, $prototypes, $args)
 Sorts keyword arguments.
 
 stringifyFncallArgs ($arg)
 Reformat fncall arguments to proper css function output.
 
 stringTransformAsciiOnly ($stringContent, $filter)
 Apply a filter on a string content, only on ascii chars let extended chars untouched.
 
 testWithWithout ($what, $with, $without)
 Test a single type of block against with/without lists.
 
 unifyCompoundSelectors ($compound1, $compound2)
 The selector-unify magic as its best (at least works as expected on test cases)
 

Protected Attributes

bool null $charsetSeen
 
array< int, $importPaths=[];protected array< string, $importCache=[];protected string[] $importedFiles=[];protected array $userFunctions=[];protected array< string, $registeredVars=[];protected array< string, $registeredFeatures=['extend-selector-pseudoclass'=> false, 'at-error'=> true, 'units-level-3'=> true, 'global-variable-shadowing'=> string null $encoding = null
 
ScssPhp ScssPhp Compiler Environment $env
 
Formatter $formatter
 
null $lineNumberStyle = null
 
OutputBlock null $rootBlock
 
Environment $rootEnv
 
OutputBlock null $scope
 
int SourceMapGenerator $sourceMap = self::SOURCE_MAP_NONE
 @phpstan-var self\SOURCE_MAP_*|SourceMapGenerator
 
array $sourceMapOptions = []
 @phpstan-var array{sourceRoot?: string, sourceMapFilename?: string|null, sourceMapURL?: string|null, sourceMapWriteTo?: string|null, outputSourceFiles?: bool, sourceMapRootpath?: string, sourceMapBasepath?: string}
 
Environment null $storeEnv
 
array< int, $importPaths=[];protected array< string, $importCache=[];protected string[] $importedFiles=[];protected array $userFunctions=[];protected array< string, $registeredVars=[];protected array< string, $registeredFeatures=['extend-selector-pseudoclass'=> false, 'at-error'=> true, 'units-level-3'=> true, 'global-variable-shadowing'=> false
 string|callable>
 
array< int, $sourceNames;protected Cache|null $cache;protected bool $cacheCheckImportResolutions=false;protected int $indentLevel;protected array[] $extends;protected array< string, $extendsMap;protected array< string, $parsedFiles=[];protected Parser|null $parser;protected int|null $sourceIndex;protected int|null $sourceLine;protected int|null $sourceColumn;protected bool|null $shouldEvaluate;protected null $ignoreErrors;protected bool $ignoreCallStackMessage=false;protected array[] $callStack=[];private array $resolvedImports=[];private string|null $currentDirectory;private string $rootDirectory;private bool $legacyCwdImportPath=true;private LoggerInterface $logger;private array< string, $warnedChildFunctions=[];public function __construct( $cacheOptions=null) { $this->sourceNames=[];if( $cacheOptions) { $this->cache=new Cache( $cacheOptions);if(!empty( $cacheOptions[ 'checkImportResolutions'])) { $this->cacheCheckImportResolutions=true;} } $this-> logger = new StreamLogger(fopen('php://stderr', 'w'), true)
 string|null>
 

Static Protected Attributes

static $libAbs = ['number']
 
static $libAdjustColor = ['color', 'kwargs...']
 
static $libAdjustHue = ['color', 'degrees']
 
static $libAlpha = ['color']
 
static $libAppend = ['list', 'val', 'separator:auto']
 
static $libBlue = ['color']
 
static $libCall = ['function', 'args...']
 
static $libCeil = ['number']
 
static $libChangeColor = ['color', 'kwargs...']
 
static $libComparable
 
static $libComplement = ['color']
 
static $libCounter = ['args...']
 
static $libDarken = ['color', 'amount']
 
static $libDesaturate = ['color', 'amount']
 
static $libFadeIn = ['color', 'amount']
 
static $libFadeOut = ['color', 'amount']
 
static $libFeatureExists = ['feature']
 
static $libFloor = ['number']
 
static $libFunctionExists = ['name']
 
static $libGetFunction
 
static $libGlobalVariableExists = ['name']
 
static $libGrayscale = ['color']
 
static $libGreen = ['color']
 
static $libHsl
 
static $libHsla
 
static $libHue = ['color']
 
static $libIeHexStr = ['color']
 
static $libIf = ['condition', 'if-true', 'if-false:']
 
static $libIndex = ['list', 'value']
 
static $libInspect = ['value']
 
static $libInvert = ['color', 'weight:100%']
 
static $libIsBracketed = ['list']
 
static $libIsSuperselector = ['super', 'sub']
 
static $libJoin = ['list1', 'list2', 'separator:auto', 'bracketed:auto']
 
static $libKeywords = ['args']
 
static $libLength = ['list']
 
static $libLighten = ['color', 'amount']
 
static $libLightness = ['color']
 
static $libListSeparator = ['list']
 
static $libMapGet = ['map', 'key', 'keys...']
 
static $libMapHasKey = ['map', 'key', 'keys...']
 
static $libMapKeys = ['map']
 
static $libMapMerge
 
static $libMapRemove
 
static $libMapValues = ['map']
 
static $libMax = ['numbers...']
 
static $libMin = ['numbers...']
 
static $libMix
 
static $libMixinExists = ['name']
 
static $libNth = ['list', 'n']
 
static $libOpacify = ['color', 'amount']
 
static $libOpacity = ['color']
 
static $libPercentage = ['number']
 
static $libQuote = ['string']
 
static $libRandom = ['limit:null']
 
static $libRed = ['color']
 
static $libRgb
 
static $libRgba
 
static $libRound = ['number']
 
static $libSaturate = [['color', 'amount'], ['amount']]
 
static $libSaturation = ['color']
 
static $libScaleColor = ['color', 'kwargs...']
 
static $libScssphpGlob = ['pattern']
 
static $libSelectorAppend = ['selector...']
 
static $libSelectorExtend
 
static $libSelectorNest = ['selector...']
 
static $libSelectorParse
 
static $libSelectorReplace
 
static $libSelectorUnify = ['selectors1', 'selectors2']
 
static $libSetNth = ['list', 'n', 'value']
 
static $libSimpleSelectors = ['selector']
 
static $libStrIndex = ['string', 'substring']
 
static $libStrInsert = ['string', 'insert', 'index']
 
static $libStrLength = ['string']
 
static $libStrSlice = ['string', 'start-at', 'end-at:-1']
 
static $libToLowerCase = ['string']
 
static $libToUpperCase = ['string']
 
static $libTransparentize = ['color', 'amount']
 
static $libTypeOf = ['value']
 
static $libUniqueId = []
 
static $libUnit = ['number']
 
static $libUnitless = ['number']
 
static $libUnquote = ['string']
 
static $libVariableExists = ['name']
 
static $libZip = ['lists...']
 
static static array< string, $namespaces=['special'=>
 string>
 
static array< string, $operatorNames=['+'=>
 string>
 

Detailed Description

The scss compiler and parser.

Converting SCSS to CSS is a three stage process. The incoming file is parsed by Parser into a syntax tree, then it is compiled into another tree representing the CSS structure by Compiler. The CSS tree is fed into a formatter, like 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 compile function of Compiler is the entry point.

In summary:

The Compiler class creates an instance of the parser, feeds it SCSS 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 Parser class is only concerned with parsing its input.

The Formatter takes a CSS tree, and dumps it to a formatted string, handling things like indentation. SCSS compiler

Author
Leaf Corcoran leafo.nosp@m.t@gm.nosp@m.ail.c.nosp@m.om

@final Extending the Compiler is deprecated

Member Function Documentation

◆ addFeature()

ScssPhp\ScssPhp\Compiler::addFeature ( $name)

Add feature.

@api

Parameters
string$name
Return values
void
Deprecated
Registering additional features is deprecated.

◆ addImportPath()

ScssPhp\ScssPhp\Compiler::addImportPath ( $path)

Add import path.

@api

Parameters
string | callable$path
Return values
void

◆ addVariables()

ScssPhp\ScssPhp\Compiler::addVariables ( array $variables)

Replaces variables.

Parameters
array<string,mixed>$variables
Return values
void

◆ adjustHsl()

ScssPhp\ScssPhp\Compiler::adjustHsl ( $color,
$idx,
$amount )
protected
Parameters
array$color
int$idx
int | float$amount
Return values
array

◆ alterColor()

ScssPhp\ScssPhp\Compiler::alterColor ( array $args,
$operation,
$fn )
protected

Helper function for adjust_color, change_color, and scale_color.

Parameters
array<array|Number>$args
string$operation
callable$fn
Return values
array

@phpstan-param callable(float|int, float|int|null, float|int): (float|int) $fn

◆ appendOutputLine()

ScssPhp\ScssPhp\Compiler::appendOutputLine ( OutputBlock $out,
$type,
$line )
protected

Append lines to the current output block: directly to the block or through a child if necessary.

Parameters
ScssPhp\ScssPhp\Formatter\OutputBlock$out
string$type
string$line
Return values
void

◆ appendRootDirective()

ScssPhp\ScssPhp\Compiler::appendRootDirective ( $line,
$out,
$allowed = [Type::T_COMMENT] )
protected

Append a root directive like @import or @charset as near as the possible from the source code (keeping before comments, @import and @charset coming before in the source code)

Parameters
string$line
ScssPhp\ScssPhp\Formatter\OutputBlock$out
array$allowed
Return values
void

◆ applyArguments()

ScssPhp\ScssPhp\Compiler::applyArguments ( $argDef,
$argValues,
$storeInEnv = true,
$reduce = true )
protected

Apply argument values per definition.

Parameters
array[]$argDef
array | null$argValues
bool$storeInEnv
bool$reduceonly used if $storeInEnv = false
Return values
array<string,array|Number>

@phpstan-param list<array{0: string, 1: array|Number|null, 2: bool}> $argDef

Exceptions
Exception

◆ assertColor()

ScssPhp\ScssPhp\Compiler::assertColor ( $value,
$varName = null )

Assert value is a color.

@api

Parameters
array | Number$value
string | null$varName
Return values
array
Exceptions
SassScriptException

◆ assertInteger()

ScssPhp\ScssPhp\Compiler::assertInteger ( $value,
$varName = null )

Assert value is a integer.

@api

Parameters
array | Number$value
string | null$varName
Return values
int
Exceptions
SassScriptException

◆ assertList()

ScssPhp\ScssPhp\Compiler::assertList ( $value)

Assert value is a list.

@api

Parameters
array | Number$value
Return values
array
Exceptions
Exception

◆ assertMap()

ScssPhp\ScssPhp\Compiler::assertMap ( $value,
$varName = null )

Assert value is a map.

@api

Parameters
array | Number$value
string | null$varName
Return values
array
Exceptions
SassScriptException

◆ assertNumber()

ScssPhp\ScssPhp\Compiler::assertNumber ( $value,
$varName = null )

Assert value is a number.

@api

Parameters
array | Number$value
string | null$varName
Return values
Number
Exceptions
SassScriptException

◆ assertString()

ScssPhp\ScssPhp\Compiler::assertString ( $value,
$varName = null )

Assert value is a string.

This method deals with internal implementation details of the value representation where unquoted strings can sometimes be stored under other types. The returned value is always using the T_STRING type.

@api

Parameters
array | Number$value
string | null$varName
Return values
array
Exceptions
SassScriptException

◆ backPropagateEnv()

ScssPhp\ScssPhp\Compiler::backPropagateEnv ( $store,
$excludedVars = null )
protected

Propagate vars from a just poped Env (used in @each and @for)

Parameters
array$store
null | string[]$excludedVars
Return values
void

◆ callNativeFunction()

ScssPhp\ScssPhp\Compiler::callNativeFunction ( $name,
$function,
$prototype,
$args )
protected

Call built-in and registered (PHP) functions.

Parameters
string$name
callable$function
array$prototype
array$args
Return values
array|Number|null

◆ callScssFunction()

ScssPhp\ScssPhp\Compiler::callScssFunction ( $func,
$argValues )
protected

Call SCSS @function.

Parameters
CallableBlock | null$func
array$argValues
Return values
array|Number

◆ callStackMessage()

ScssPhp\ScssPhp\Compiler::callStackMessage ( $all = false,
$limit = null )
protected

Beautify call stack for output.

Parameters
bool$all
int | null$limit
Return values
string

◆ checkCompatibleTags()

ScssPhp\ScssPhp\Compiler::checkCompatibleTags ( $tag1,
$tag2 )
protected

Check the compatibility between two tag names: if both are defined they should be identical or one has to be '*'.

Parameters
string$tag1
string$tag2
Return values
array|false

◆ checkSelectorArgType()

ScssPhp\ScssPhp\Compiler::checkSelectorArgType ( $arg,
$maxDepth = 2 )
protected

Check variable type for getSelectorArg() function.

Parameters
array$arg
int$maxDepth
Return values
bool

◆ coerceColor()

ScssPhp\ScssPhp\Compiler::coerceColor ( $value,
$inRGBFunction = false )
protected

Coerce value to color.

Parameters
array | Number$value
bool$inRGBFunction
Return values
array|null

◆ coerceForExpression()

ScssPhp\ScssPhp\Compiler::coerceForExpression ( $value)
protected

Coerce color for expression.

Parameters
array | Number$value
Return values
array|Number

◆ coerceList()

ScssPhp\ScssPhp\Compiler::coerceList ( $item,
$delim = ',',
$removeTrailingNull = false )
protected

Coerce something to list.

Parameters
array | Number$item
string$delim
bool$removeTrailingNull
Return values
array

◆ coerceMap()

ScssPhp\ScssPhp\Compiler::coerceMap ( $item)
protected

Coerce something to map.

Parameters
array | Number$item
Return values
array|Number

◆ coercePercent()

ScssPhp\ScssPhp\Compiler::coercePercent ( $value)
protected

Coerce value to a percentage.

Parameters
array | Number$value
Return values
int|float
Deprecated

◆ coerceString()

ScssPhp\ScssPhp\Compiler::coerceString ( $value)
protected

Coerce value to string.

Parameters
array | Number$value
Return values
array

◆ coerceValue()

ScssPhp\ScssPhp\Compiler::coerceValue ( $value)
protected

Coerce a php value into a scss one.

Parameters
mixed$value
Return values
array|Number

◆ collapseSelectors()

ScssPhp\ScssPhp\Compiler::collapseSelectors ( $selectors)
protected

Collapse selectors.

Parameters
array$selectors
Return values
string

◆ combineSelectorSingle()

ScssPhp\ScssPhp\Compiler::combineSelectorSingle ( $base,
$other )
protected

Combine selector single.

Parameters
array$base
array$other
Return values
array

◆ compactEnv()

ScssPhp\ScssPhp\Compiler::compactEnv ( Environment $env)
protected

Convert env linked list to stack.

Parameters
Environment$env
Return values
Environment[]

@phpstan-return non-empty-array<Environment>

◆ compile()

ScssPhp\ScssPhp\Compiler::compile ( $code,
$path = null )

Compile scss.

Parameters
string$code
string | null$path
Return values
string
Exceptions
SassExceptionwhen the source fails to compile
Deprecated
Use {
See also
compileString} instead.

Reimplemented in core_scss.

◆ compileAtRoot()

ScssPhp\ScssPhp\Compiler::compileAtRoot ( Block $block)
protected

Compile at-root.

Parameters
ScssPhp\ScssPhp\Block$block
Return values
void

◆ compileBlock()

ScssPhp\ScssPhp\Compiler::compileBlock ( Block $block)
protected

Recursively compiles a block.

A block is analogous to a CSS block in most cases. A single SCSS document is encapsulated in a block when parsed, but it does not have parent tags so all of its children appear on the root level when compiled.

Blocks are made up of selectors and children.

The children of a block are just all the blocks that are defined within.

Compiling the block involves pushing a fresh environment on the stack, and iterating through the props, compiling each one.

See also
Compiler\compileChild()
Parameters
ScssPhp\ScssPhp\Block$block
Return values
void

◆ compileChild()

ScssPhp\ScssPhp\Compiler::compileChild ( $child,
OutputBlock $out )
protected

Compile child; returns a value to halt execution.

Parameters
array$child
ScssPhp\ScssPhp\Formatter\OutputBlock$out
Return values
array|Number|null

Reimplemented in core_scss.

◆ compileChildren()

ScssPhp\ScssPhp\Compiler::compileChildren ( $stms,
OutputBlock $out,
$traceName = '' )
protected

Compile children and return result.

Parameters
array$stms
ScssPhp\ScssPhp\Formatter\OutputBlock$out
string$traceName
Return values
array|Number|null

◆ compileChildrenNoReturn()

ScssPhp\ScssPhp\Compiler::compileChildrenNoReturn ( $stms,
OutputBlock $out,
$selfParent = null,
$traceName = '' )
protected

Compile children and throw exception if unexpected at-return.

Parameters
array[]$stms
ScssPhp\ScssPhp\Formatter\OutputBlock$out
ScssPhp\ScssPhp\Block$selfParent
string$traceName
Return values
void
Exceptions
Exception

◆ compileColorPartValue()

ScssPhp\ScssPhp\Compiler::compileColorPartValue ( $value,
$min,
$max,
$isInt = true )
protected
Parameters
mixed$value
int | float$min
int | float$max
bool$isInt
Return values
int|mixed

◆ compileComment()

ScssPhp\ScssPhp\Compiler::compileComment ( $block)
protected

Compile root level comment.

Parameters
array$block
Return values
void

◆ compileCommentValue()

ScssPhp\ScssPhp\Compiler::compileCommentValue ( $value,
$pushEnv = false )
protected

Compile the value of a comment that can have interpolation.

Parameters
array$value
bool$pushEnv
Return values
string

◆ compileDebugValue()

ScssPhp\ScssPhp\Compiler::compileDebugValue ( $value)
protected
Parameters
array | Number$value
Return values
string

◆ compileDirective()

ScssPhp\ScssPhp\Compiler::compileDirective ( $directive,
OutputBlock $out )
protected

Compile directive.

Parameters
DirectiveBlock | array$directive
ScssPhp\ScssPhp\Formatter\OutputBlock$out
Return values
void

◆ compileDirectiveName()

ScssPhp\ScssPhp\Compiler::compileDirectiveName ( $directiveName)
protected

directive names can include some interpolation

Parameters
string | array$directiveName
Return values
string
Exceptions
CompilerException

◆ compileImport()

ScssPhp\ScssPhp\Compiler::compileImport ( $rawPath,
OutputBlock $out,
$once = false )
protected

Compile import; returns true if the value was something that could be imported.

Parameters
array$rawPath
ScssPhp\ScssPhp\Formatter\OutputBlock$out
bool$once
Return values
bool

◆ compileImportPath()

ScssPhp\ScssPhp\Compiler::compileImportPath ( $rawPath)
protected
Parameters
array$rawPath
Return values
string
Exceptions
CompilerException

◆ compileKeyframeBlock()

ScssPhp\ScssPhp\Compiler::compileKeyframeBlock ( Block $block,
$selectors )
protected

Compile keyframe block.

Parameters
ScssPhp\ScssPhp\Block$block
string[]$selectors
Return values
void

◆ compileMedia()

ScssPhp\ScssPhp\Compiler::compileMedia ( Block $media)
protected

Compile media.

Parameters
ScssPhp\ScssPhp\Block$media
Return values
void

◆ compileMediaQuery()

ScssPhp\ScssPhp\Compiler::compileMediaQuery ( $queryList)
protected

Compile media query.

Parameters
array$queryList
Return values
string[]

◆ compileNestedBlock()

ScssPhp\ScssPhp\Compiler::compileNestedBlock ( Block $block,
$selectors )
protected

Compile nested block.

Parameters
ScssPhp\ScssPhp\Block$block
string[]$selectors
Return values
void

◆ compileNestedPropertiesBlock()

ScssPhp\ScssPhp\Compiler::compileNestedPropertiesBlock ( Block $block,
OutputBlock $out )
protected

Compile nested properties lines.

Parameters
ScssPhp\ScssPhp\Block$block
ScssPhp\ScssPhp\Formatter\OutputBlock$out
Return values
void

◆ compileRGBAValue()

ScssPhp\ScssPhp\Compiler::compileRGBAValue ( $value,
$isAlpha = false )
protected
Parameters
int | Number$value
bool$isAlpha
Return values
int|mixed

◆ compileRoot()

ScssPhp\ScssPhp\Compiler::compileRoot ( Block $rootBlock)
protected

Compile root.

Parameters
ScssPhp\ScssPhp\Block$rootBlock
Return values
void

◆ compileSelector()

ScssPhp\ScssPhp\Compiler::compileSelector ( $selector)
protected

Compile selector to string; self(&) should have been replaced by now.

Parameters
string | array$selector
Return values
string

◆ compileSelectorPart()

ScssPhp\ScssPhp\Compiler::compileSelectorPart ( $piece)
protected

Compile selector part.

Parameters
array$piece
Return values
string

◆ compileString()

ScssPhp\ScssPhp\Compiler::compileString ( $source,
$path = null )

Compile scss.

Parameters
string$source
string | null$path
Return values
CompilationResult
Exceptions
SassExceptionwhen the source fails to compile

◆ compileStringContent()

ScssPhp\ScssPhp\Compiler::compileStringContent ( $string,
$quote = true )
protected

Compile string content.

Parameters
array$string
bool$quote
Return values
string

◆ compileValue()

ScssPhp\ScssPhp\Compiler::compileValue ( $value,
$quote = true )

Compiles a primitive value into a CSS property value.

Values in scssphp 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.

@api

Parameters
array | Number$value
bool$quote
Return values
string

◆ compileWith()

ScssPhp\ScssPhp\Compiler::compileWith ( $withCondition)
protected

Compile @at-root's with: inclusion / without: exclusion into 2 lists uses to filter scope/env later.

Parameters
array | null$withCondition
Return values
array

@phpstan-return array{array<string, bool>, array<string, bool>}

◆ completeScope()

ScssPhp\ScssPhp\Compiler::completeScope ( $scope,
$previousScope )
protected

found missing selector from a at-root compilation in the previous scope (if at-root is just enclosing a property, the selector is in the parent tree)

Parameters
ScssPhp\ScssPhp\Formatter\OutputBlock$scope
ScssPhp\ScssPhp\Formatter\OutputBlock$previousScope
Return values
OutputBlock

◆ cssValidArg()

ScssPhp\ScssPhp\Compiler::cssValidArg ( $arg,
$allowed_function = [],
$inFunction = false )
protected
Parameters
array | Number$arg
string[]$allowed_function
bool$inFunction
Return values
array|Number|false

◆ errorArgsNumber()

ScssPhp\ScssPhp\Compiler::errorArgsNumber ( $functionName,
$ExpectedArgs,
$nbActual )
Parameters
string$functionName
array$ExpectedArgs
int$nbActual
Return values
CompilerException
Deprecated

◆ escapeImportPathString()

ScssPhp\ScssPhp\Compiler::escapeImportPathString ( $path)
protected
Parameters
array$path
Return values
array
Exceptions
CompilerException

◆ evalSelector()

ScssPhp\ScssPhp\Compiler::evalSelector ( $selector)
protected

Evaluate selector.

Parameters
array$selector
Return values
array

@phpstan-impure

◆ evalSelectorPart()

ScssPhp\ScssPhp\Compiler::evalSelectorPart ( $part)
protected

Evaluate selector part; replaces all the interpolates, stripping quotes.

Parameters
array$part
Return values
array

@phpstan-impure

◆ evalSelectors()

ScssPhp\ScssPhp\Compiler::evalSelectors ( $selectors)
protected

Evaluate selectors.

Parameters
array$selectors
Return values
array

◆ evaluateMediaQuery()

ScssPhp\ScssPhp\Compiler::evaluateMediaQuery ( $queryList)
protected

evaluate media query : compile internal value keeping the structure unchanged

Parameters
array$queryList
Return values
array

◆ expToString()

ScssPhp\ScssPhp\Compiler::expToString ( $exp,
$keepParens = false )
protected

Reduce expression to string.

Parameters
array$exp
bool$keepParens
Return values
array

◆ extendOrReplaceSelectors()

ScssPhp\ScssPhp\Compiler::extendOrReplaceSelectors ( $selectors,
$extendee,
$extender,
$replace = false )
protected

Extend/replace in selectors used by selector-extend and selector-replace that use the same logic.

Parameters
array$selectors
array$extendee
array$extender
bool$replace
Return values
array

◆ extractEnv()

ScssPhp\ScssPhp\Compiler::extractEnv ( $envs)
protected

Convert env stack to singly linked list.

Parameters
Environment[]$envs
Return values
Environment

@phpstan-param non-empty-array<Environment> $envs

◆ extractInterpolation()

ScssPhp\ScssPhp\Compiler::extractInterpolation ( $list)
protected

Extract interpolation; it doesn't need to be recursive, compileValue will handle that.

Parameters
array$list
Return values
array

◆ extractRelationshipFromFragment()

ScssPhp\ScssPhp\Compiler::extractRelationshipFromFragment ( array $fragment)
protected

Extract a relationship from the fragment.

When extracting the last portion of a selector we will be left with a fragment which may end with a direction relationship combinator. This method will extract the relationship fragment and return it along side the rest.

Parameters
array$fragmentThe selector fragment maybe ending with a direction relationship combinator.
Return values
arrayThe selector without the relationship fragment if any, the relationship fragment.

◆ filterScopeWithWithout()

ScssPhp\ScssPhp\Compiler::filterScopeWithWithout ( $scope,
$with,
$without )
protected

Filter at-root scope depending on with/without option.

Parameters
ScssPhp\ScssPhp\Formatter\OutputBlock$scope
array$with
array$without
Return values
OutputBlock

◆ filterWithWithout()

ScssPhp\ScssPhp\Compiler::filterWithWithout ( $envs,
$with,
$without )
protected

Filter env stack.

Parameters
Environment[]$envs
array$with
array$without
Return values
Environment

@phpstan-param non-empty-array<Environment> $envs

◆ findScopeSelectors()

ScssPhp\ScssPhp\Compiler::findScopeSelectors ( $scope,
$depth )
protected

Find a selector by the depth node in the scope.

Parameters
ScssPhp\ScssPhp\Formatter\OutputBlock$scope
int$depth
Return values
array

◆ findTagName()

ScssPhp\ScssPhp\Compiler::findTagName ( $parts)
protected

Find the html tag name in a selector parts list.

Parameters
string[]$parts
Return values
string

◆ fixColor()

ScssPhp\ScssPhp\Compiler::fixColor ( $c)
protected

Make sure a color's components don't go out of bounds.

Parameters
array$c
Return values
array

◆ flattenList()

ScssPhp\ScssPhp\Compiler::flattenList ( $list)
protected

Flatten list.

Parameters
array$list
Return values
string
Deprecated

◆ flattenSelectors()

ScssPhp\ScssPhp\Compiler::flattenSelectors ( OutputBlock $block,
$parentKey = null )
protected

Flatten selectors.

Parameters
ScssPhp\ScssPhp\Formatter\OutputBlock$block
string$parentKey
Return values
void

◆ flattenSelectorSingle()

ScssPhp\ScssPhp\Compiler::flattenSelectorSingle ( $single)
protected

Flatten selector single; joins together .classes and ids.

Parameters
array$single
Return values
array

◆ fncall()

ScssPhp\ScssPhp\Compiler::fncall ( $functionReference,
$argValues )
protected

Function caller.

Parameters
string | array$functionReference
array$argValues
Return values
array|Number

◆ formatOutputSelector()

ScssPhp\ScssPhp\Compiler::formatOutputSelector ( $selectors)
protected

Postprocess selector to output in right format.

Parameters
array$selectors
Return values
array

◆ getArgumentListKeywords()

ScssPhp\ScssPhp\Compiler::getArgumentListKeywords ( $value)

Gets the keywords of an argument list.

Keys in the returned array are normalized names (underscores are replaced with dashes) without the leading $. Calling this helper with anything that an argument list received for a rest argument of the function argument declaration is not supported.

Parameters
array | Number$value
Return values
array<string,array|Number>

◆ getBuiltinFunction()

ScssPhp\ScssPhp\Compiler::getBuiltinFunction ( $name)
protected

Get built-in function.

Parameters
string$nameNormalized name
Return values
array

◆ getCompileOptions()

ScssPhp\ScssPhp\Compiler::getCompileOptions ( )

Get compiler options.

Return values
array<string,mixed>

◆ getFunctionReference()

ScssPhp\ScssPhp\Compiler::getFunctionReference ( $name,
$safeCopy = false )
protected

Find a function reference.

Parameters
string$name
bool$safeCopy
Return values
array

◆ getParsedFiles()

ScssPhp\ScssPhp\Compiler::getParsedFiles ( )

Returns list of parsed files.

Deprecated
Return values
array<string,int>

◆ getSelectorArg()

ScssPhp\ScssPhp\Compiler::getSelectorArg ( $arg,
$varname = null,
$allowParent = false )
protected

Preprocess selector args.

Parameters
array$arg
string | null$varname
bool$allowParent
Return values
array

◆ getSourcePosition()

ScssPhp\ScssPhp\Compiler::getSourcePosition ( )

Get source position.

@api

Return values
array
Deprecated

◆ getStoreEnv()

ScssPhp\ScssPhp\Compiler::getStoreEnv ( )
protected

Get store environment.

Return values
ScssPhp\ScssPhp\Compiler\Environment

◆ getStringText()

ScssPhp\ScssPhp\Compiler::getStringText ( array $value)

Gets the text of a Sass string.

Calling this method on anything else than a SassString is unsupported. Use {

See also
assertString} first to ensure that the value is indeed a string.
Parameters
array$value
Return values
string

◆ getVariables()

ScssPhp\ScssPhp\Compiler::getVariables ( )

Returns list of variables.

@api

Return values
array

◆ glueFunctionSelectors()

ScssPhp\ScssPhp\Compiler::glueFunctionSelectors ( $parts)
protected

Glue parts of :not( or :nth-child( ... that are in general split in selectors parts.

Parameters
array$parts
Return values
array

◆ handleImportLoop()

ScssPhp\ScssPhp\Compiler::handleImportLoop ( $name)
protected

Handle import loop.

Parameters
string$name
Return values
void
Exceptions
Exception

◆ has()

ScssPhp\ScssPhp\Compiler::has ( $name,
Environment $env = null )
protected

Has variable?

Parameters
string$name
ScssPhp\ScssPhp\Compiler\Environment$env
Return values
bool

◆ hasSelectorPlaceholder()

ScssPhp\ScssPhp\Compiler::hasSelectorPlaceholder ( $selector)
protected

Has selector placeholder?

Parameters
array$selector
Return values
bool

◆ hueToRGB()

ScssPhp\ScssPhp\Compiler::hueToRGB ( $m1,
$m2,
$h )
protected

Hue to RGB helper.

Parameters
float$m1
float$m2
float$h
Return values
float

◆ importFile()

ScssPhp\ScssPhp\Compiler::importFile ( $path,
OutputBlock $out )
protected

Import file.

Parameters
string$path
ScssPhp\ScssPhp\Formatter\OutputBlock$out
Return values
void

◆ injectVariables()

ScssPhp\ScssPhp\Compiler::injectVariables ( array $args)
protected

Inject variables.

Parameters
array$args
Return values
void

◆ inspectFormatValue()

ScssPhp\ScssPhp\Compiler::inspectFormatValue ( $value,
$force_enclosing_display = false )
protected
Parameters
array | Number$value
bool$force_enclosing_display
Return values
array

◆ isCssImport()

static ScssPhp\ScssPhp\Compiler::isCssImport ( $url)
static

Detects whether the import is a CSS import.

For legacy reasons, custom importers are called for those, allowing them to replace them with an actual Sass import. However this behavior is deprecated. Custom importers are expected to return null when they receive a CSS import.

Parameters
string$url
Return values
bool

◆ isImmediateRelationshipCombinator()

ScssPhp\ScssPhp\Compiler::isImmediateRelationshipCombinator ( $value)
protected

Is the value a direct relationship combinator?

Parameters
string$value
Return values
bool

◆ isPseudoSelector()

ScssPhp\ScssPhp\Compiler::isPseudoSelector ( $part,
& $matches )
protected

Test a part for being a pseudo selector.

Parameters
string$part
array$matches
Return values
bool

◆ isSelfExtend()

ScssPhp\ScssPhp\Compiler::isSelfExtend ( $target,
$origin )
protected

Is self extend?

Parameters
array$target
array$origin
Return values
bool

◆ isSuperPart()

ScssPhp\ScssPhp\Compiler::isSuperPart ( $superParts,
$subParts )
protected

Test a part of super selector again a part of sub selector.

Parameters
array$superParts
array$subParts
Return values
bool

◆ isSuperSelector()

ScssPhp\ScssPhp\Compiler::isSuperSelector ( $super,
$sub )
protected

Test a $super selector again $sub.

Parameters
array$super
array$sub
Return values
bool

◆ isTruthy()

ScssPhp\ScssPhp\Compiler::isTruthy ( $value)

Is truthy?

Parameters
array | Number$value
Return values
bool

◆ isWith()

ScssPhp\ScssPhp\Compiler::isWith ( $block,
$with,
$without )
protected

Filter WITH rules.

Parameters
ScssPhp\ScssPhp\Block | ScssPhp\ScssPhp\Formatter\OutputBlock$block
array$with
array$without
Return values
bool

◆ joinSelectors()

ScssPhp\ScssPhp\Compiler::joinSelectors ( $parent,
$child,
& $stillHasSelf,
$selfParentSelectors = null )
protected

Join selectors; looks for & to replace, or append parent before child.

Parameters
array$parent
array$child
bool$stillHasSelf
array$selfParentSelectors
Return values
array

◆ libCounter()

ScssPhp\ScssPhp\Compiler::libCounter ( $args)
protected

Workaround IE7's content counter bug.

Parameters
array$args
Return values
array

◆ libHsl()

ScssPhp\ScssPhp\Compiler::libHsl ( $args,
$kwargs,
$funcName = 'hsl' )
protected
Parameters
array$args
array$kwargs
string$funcName
Return values
array|null

◆ libRgb()

ScssPhp\ScssPhp\Compiler::libRgb ( $args,
$kwargs,
$funcName = 'rgb' )
protected
Parameters
array$args
array$kwargs
string$funcName
Return values
array

◆ listSeparatorForJoin()

ScssPhp\ScssPhp\Compiler::listSeparatorForJoin ( $list1,
$sep )
protected
Parameters
array$list1
array | Number | null$sep
Return values
string
Exceptions
CompilerException
Deprecated

◆ makeOutputBlock()

ScssPhp\ScssPhp\Compiler::makeOutputBlock ( $type,
$selectors = null )
protected

Make output block.

Parameters
string | null$type
string[] | null$selectors
Return values
ScssPhp\ScssPhp\Formatter\OutputBlock

◆ matchExtends()

ScssPhp\ScssPhp\Compiler::matchExtends ( $selector,
& $out,
$from = 0,
$initial = true )
protected

Match extends.

Parameters
array$selector
array$out
int$from
bool$initial
Return values
void

◆ matchExtendsSingle()

ScssPhp\ScssPhp\Compiler::matchExtendsSingle ( $rawSingle,
& $outOrigin,
$initial = true )
protected

Match extends single.

Parameters
array$rawSingle
array$outOrigin
bool$initial
Return values
bool

◆ matchPartInCompound()

ScssPhp\ScssPhp\Compiler::matchPartInCompound ( $part,
$compound )
protected

Try to find a matching part in a compound:

  • with same html tag name
  • with some class or id or something in common
Parameters
array$part
array$compound
Return values
array|false

◆ mediaParent()

ScssPhp\ScssPhp\Compiler::mediaParent ( OutputBlock $scope)
protected

◆ mergeDirectRelationships()

ScssPhp\ScssPhp\Compiler::mergeDirectRelationships ( $selectors1,
$selectors2 )
protected

Merge direct relationships between selectors.

Parameters
array$selectors1
array$selectors2
Return values
array

◆ mergeMediaTypes()

ScssPhp\ScssPhp\Compiler::mergeMediaTypes ( $type1,
$type2 )
protected

Merge media types.

Parameters
array$type1
array$type2
Return values
array|null

◆ mergeParts()

ScssPhp\ScssPhp\Compiler::mergeParts ( $parts1,
$parts2 )
protected

Merge two part list taking care that.

  • the html tag is coming first - if any
  • the :something are coming last
Parameters
array$parts1
array$parts2
Return values
array

◆ missingSelectors()

ScssPhp\ScssPhp\Compiler::missingSelectors ( )
protected

Report missing selectors.

Return values
void

◆ multiplyMedia()

ScssPhp\ScssPhp\Compiler::multiplyMedia ( Environment $env = null,
$childQueries = null )
protected

Multiply media.

Parameters
ScssPhp\ScssPhp\Compiler\Environment$env
array$childQueries
Return values
array

◆ multiplySelectors()

ScssPhp\ScssPhp\Compiler::multiplySelectors ( Environment $env,
$selfParent = null )
protected

Find the final set of selectors.

Parameters
ScssPhp\ScssPhp\Compiler\Environment$env
ScssPhp\ScssPhp\Block$selfParent
Return values
array

◆ normalizeName()

ScssPhp\ScssPhp\Compiler::normalizeName ( $name)
protected

Normalize name.

Parameters
string$name
Return values
string

◆ opAdd()

ScssPhp\ScssPhp\Compiler::opAdd ( $left,
$right )
protected

Add strings.

Parameters
array$left
array$right
Return values
array|null

◆ opAddNumberNumber()

ScssPhp\ScssPhp\Compiler::opAddNumberNumber ( Number $left,
Number $right )
protected

Add numbers.

Parameters
Number$left
Number$right
Return values
Number

◆ opAnd()

ScssPhp\ScssPhp\Compiler::opAnd ( $left,
$right,
$shouldEval )
protected

Boolean and.

Parameters
array | Number$left
array | Number$right
bool$shouldEval
Return values
array|Number|null

◆ opColorColor()

ScssPhp\ScssPhp\Compiler::opColorColor ( $op,
$left,
$right )
protected

Compare colors.

Parameters
string$op
array$left
array$right
Return values
array

◆ opColorNumber()

ScssPhp\ScssPhp\Compiler::opColorNumber ( $op,
$left,
Number $right )
protected

Compare color and number.

Parameters
string$op
array$left
Number$right
Return values
array

◆ opDivNumberNumber()

ScssPhp\ScssPhp\Compiler::opDivNumberNumber ( Number $left,
Number $right )
protected

Divide numbers.

Parameters
Number$left
Number$right
Return values
Number

◆ opEq()

ScssPhp\ScssPhp\Compiler::opEq ( $left,
$right )
protected

Compare number1 == number2.

Parameters
array | Number$left
array | Number$right
Return values
array

◆ opEqNumberNumber()

ScssPhp\ScssPhp\Compiler::opEqNumberNumber ( Number $left,
Number $right )
protected

Compare number1 == number2.

Parameters
Number$left
Number$right
Return values
array

◆ opGteNumberNumber()

ScssPhp\ScssPhp\Compiler::opGteNumberNumber ( Number $left,
Number $right )
protected

Compare number1 >= number2.

Parameters
Number$left
Number$right
Return values
array

◆ opGtNumberNumber()

ScssPhp\ScssPhp\Compiler::opGtNumberNumber ( Number $left,
Number $right )
protected

Compare number1 > number2.

Parameters
Number$left
Number$right
Return values
array

◆ opLteNumberNumber()

ScssPhp\ScssPhp\Compiler::opLteNumberNumber ( Number $left,
Number $right )
protected

Compare number1 <= number2.

Parameters
Number$left
Number$right
Return values
array

◆ opLtNumberNumber()

ScssPhp\ScssPhp\Compiler::opLtNumberNumber ( Number $left,
Number $right )
protected

Compare number1 < number2.

Parameters
Number$left
Number$right
Return values
array

◆ opModNumberNumber()

ScssPhp\ScssPhp\Compiler::opModNumberNumber ( Number $left,
Number $right )
protected

Mod numbers.

Parameters
Number$left
Number$right
Return values
Number

◆ opMulNumberNumber()

ScssPhp\ScssPhp\Compiler::opMulNumberNumber ( Number $left,
Number $right )
protected

Multiply numbers.

Parameters
Number$left
Number$right
Return values
Number

◆ opNeq()

ScssPhp\ScssPhp\Compiler::opNeq ( $left,
$right )
protected

Compare number1 != number2.

Parameters
array | Number$left
array | Number$right
Return values
array

◆ opNeqNumberNumber()

ScssPhp\ScssPhp\Compiler::opNeqNumberNumber ( Number $left,
Number $right )
protected

Compare number1 != number2.

Parameters
Number$left
Number$right
Return values
array

◆ opNumberColor()

ScssPhp\ScssPhp\Compiler::opNumberColor ( $op,
Number $left,
$right )
protected

Compare number and color.

Parameters
string$op
Number$left
array$right
Return values
array

◆ opOr()

ScssPhp\ScssPhp\Compiler::opOr ( $left,
$right,
$shouldEval )
protected

Boolean or.

Parameters
array | Number$left
array | Number$right
bool$shouldEval
Return values
array|Number|null

◆ opSubNumberNumber()

ScssPhp\ScssPhp\Compiler::opSubNumberNumber ( Number $left,
Number $right )
protected

Subtract numbers.

Parameters
Number$left
Number$right
Return values
Number

◆ parserFactory()

ScssPhp\ScssPhp\Compiler::parserFactory ( $path)
protected

Instantiate parser.

Parameters
string | null$path
Return values
ScssPhp\ScssPhp\Parser

◆ popCallStack()

ScssPhp\ScssPhp\Compiler::popCallStack ( )
protected
Return values
void

◆ popEnv()

ScssPhp\ScssPhp\Compiler::popEnv ( )
protected

Pop environment.

Return values
void

◆ prependSelectors()

ScssPhp\ScssPhp\Compiler::prependSelectors ( $selectors,
$parts )
protected

Prepend each selector from $selectors with $parts.

Parameters
array$selectors
array$parts
Return values
array

◆ pushCallStack()

ScssPhp\ScssPhp\Compiler::pushCallStack ( $name = '')
protected
Parameters
string$name
Return values
void

◆ pushEnv()

ScssPhp\ScssPhp\Compiler::pushEnv ( Block $block = null)
protected

Push environment.

Parameters
ScssPhp\ScssPhp\Block$block
Return values
ScssPhp\ScssPhp\Compiler\Environment

◆ pushExtends()

ScssPhp\ScssPhp\Compiler::pushExtends ( $target,
$origin,
$block )
protected

Push extends.

Parameters
string[]$target
array$origin
array | null$block
Return values
void

◆ pushOrMergeExtentedSelector()

ScssPhp\ScssPhp\Compiler::pushOrMergeExtentedSelector ( & $out,
$extended )
protected

Push extended selector except if.

  • this is a pseudo selector
  • same as previous
  • in a white list in this case we merge the pseudo selector content
Parameters
array$out
array$extended
Return values
void

◆ reduce()

ScssPhp\ScssPhp\Compiler::reduce ( $value,
$inExp = false )
protected

Reduce value.

Parameters
array | Number$value
bool$inExp
Return values
array|Number

◆ registerFunction()

ScssPhp\ScssPhp\Compiler::registerFunction ( $name,
$callback,
$argumentDeclaration = null )

Register function.

@api

Parameters
string$name
callable$callback
string[] | null$argumentDeclaration
Return values
void

◆ replaceSelfSelector()

ScssPhp\ScssPhp\Compiler::replaceSelfSelector ( $selectors,
$replace = null )
protected

Parse down the selector and revert [self] to "&" before a reparsing.

Parameters
array$selectors
string | null$replace
Return values
array

◆ replaceVariables()

ScssPhp\ScssPhp\Compiler::replaceVariables ( array $variables)

Replaces variables.

Parameters
array<string,mixed>$variables
Return values
void

◆ selectorAppend()

ScssPhp\ScssPhp\Compiler::selectorAppend ( $selectors)
protected

Append parts of the last selector in the list to the previous, recursively.

Parameters
array$selectors
Return values
array
Exceptions
ScssPhp\ScssPhp\Exception\CompilerException

◆ set()

ScssPhp\ScssPhp\Compiler::set ( $name,
$value,
$shadow = false,
Environment $env = null,
$valueUnreduced = null )
protected

Set variable.

Parameters
string$name
mixed$value
bool$shadow
ScssPhp\ScssPhp\Compiler\Environment$env
mixed$valueUnreduced
Return values
void

◆ setCharset()

ScssPhp\ScssPhp\Compiler::setCharset ( $charset)

Configures the handling of non-ASCII outputs.

If $charset is true, this will include a @charset declaration or a UTF-8 byte-order mark if the stylesheet contains any non-ASCII characters. Otherwise, it will never include a @charset declaration or a byte-order mark.

Parameters
bool$charset
Return values
void

◆ setEncoding()

ScssPhp\ScssPhp\Compiler::setEncoding ( $encoding)

Set encoding.

@api

Parameters
string | null$encoding
Return values
void
Deprecated
Non-compliant support for other encodings than UTF-8 is deprecated.

◆ setErrorOuput()

ScssPhp\ScssPhp\Compiler::setErrorOuput ( $handle)

Set an alternative error output stream, for testing purpose only.

Parameters
resource$handle
Return values
void
Deprecated
Use {
See also
setLogger} instead

◆ setExisting()

ScssPhp\ScssPhp\Compiler::setExisting ( $name,
$value,
Environment $env,
$valueUnreduced = null )
protected

Set existing variable.

Parameters
string$name
mixed$value
ScssPhp\ScssPhp\Compiler\Environment$env
mixed$valueUnreduced
Return values
void

◆ setFormatter()

ScssPhp\ScssPhp\Compiler::setFormatter ( $formatterName)

Set formatter.

@api

Parameters
string$formatterName
Return values
void
Deprecated
Use {
See also
setOutputStyle} instead.

@phpstan-param class-string<Formatter> $formatterName

◆ setIgnoreErrors()

ScssPhp\ScssPhp\Compiler::setIgnoreErrors ( $ignoreErrors)

Ignore errors?

@api

Parameters
bool$ignoreErrors
Return values
ScssPhp\ScssPhp\Compiler
Deprecated
Ignoring Sass errors is not longer supported.

◆ setImportPaths()

ScssPhp\ScssPhp\Compiler::setImportPaths ( $path)

Set import paths.

@api

Parameters
string|array<string|callable>$path
Return values
void

◆ setLineNumberStyle()

ScssPhp\ScssPhp\Compiler::setLineNumberStyle ( $lineNumberStyle)

Set line number style.

@api

Parameters
string$lineNumberStyle
Return values
void
Deprecated
The line number output is not supported anymore. Use source maps instead.

◆ setLogger()

ScssPhp\ScssPhp\Compiler::setLogger ( LoggerInterface $logger)

Sets an alternative logger.

Changing the logger in the middle of the compilation is not supported and will result in an undefined behavior.

Parameters
LoggerInterface$logger
Return values
void

◆ setNumberPrecision()

ScssPhp\ScssPhp\Compiler::setNumberPrecision ( $numberPrecision)

Set number precision.

@api

Parameters
int$numberPrecision
Return values
void
Deprecated
The number precision is not configurable anymore. The default is enough for all browsers.

◆ setOutputStyle()

ScssPhp\ScssPhp\Compiler::setOutputStyle ( $style)

Sets the output style.

@api

Parameters
string$styleOne of the OutputStyle constants
Return values
void

@phpstan-param OutputStyle::* $style

◆ setRaw()

ScssPhp\ScssPhp\Compiler::setRaw ( $name,
$value,
Environment $env,
$valueUnreduced = null )
protected

Set raw variable.

Parameters
string$name
mixed$value
ScssPhp\ScssPhp\Compiler\Environment$env
mixed$valueUnreduced
Return values
void

◆ setSourceMap()

ScssPhp\ScssPhp\Compiler::setSourceMap ( $sourceMap)

Enable/disable source maps.

@api

Parameters
int$sourceMap
Return values
void

@phpstan-param self\SOURCE_MAP_* $sourceMap

◆ setSourceMapOptions()

ScssPhp\ScssPhp\Compiler::setSourceMapOptions ( $sourceMapOptions)

Set source map options.

@api

Parameters
array$sourceMapOptions

@phpstan-param array{sourceRoot?: string, sourceMapFilename?: string|null, sourceMapURL?: string|null, sourceMapWriteTo?: string|null, outputSourceFiles?: bool, sourceMapRootpath?: string, sourceMapBasepath?: string} $sourceMapOptions

Return values
void

◆ setVariables()

ScssPhp\ScssPhp\Compiler::setVariables ( array $variables)

Set variables.

@api

Parameters
array$variables
Return values
void
Deprecated
Use "addVariables" or "replaceVariables" instead.

◆ shouldEval()

ScssPhp\ScssPhp\Compiler::shouldEval ( $value)
protected

Should $value cause its operand to eval.

Parameters
array$value
Return values
bool

◆ sortNativeFunctionArgs()

ScssPhp\ScssPhp\Compiler::sortNativeFunctionArgs ( $functionName,
$prototypes,
$args )
protected

Sorts keyword arguments.

Parameters
string$functionName
array | null$prototypes
array$args
Return values
array|null

◆ stringifyFncallArgs()

ScssPhp\ScssPhp\Compiler::stringifyFncallArgs ( $arg)
protected

Reformat fncall arguments to proper css function output.

Parameters
array | Number$arg
Return values
array|Number

◆ stringTransformAsciiOnly()

ScssPhp\ScssPhp\Compiler::stringTransformAsciiOnly ( $stringContent,
$filter )
protected

Apply a filter on a string content, only on ascii chars let extended chars untouched.

Parameters
string$stringContent
callable$filter
Return values
string

◆ testWithWithout()

ScssPhp\ScssPhp\Compiler::testWithWithout ( $what,
$with,
$without )
protected

Test a single type of block against with/without lists.

Parameters
string$what
array$with
array$without
Return values
booltrue if the block should be kept, false to reject

◆ throwError()

ScssPhp\ScssPhp\Compiler::throwError ( $msg)

Throw error (exception)

@api

Parameters
string$msgMessage with optional sprintf()-style vararg parameters
Return values
never
Exceptions
ScssPhp\ScssPhp\Exception\CompilerException
Deprecated
use "error" and throw the exception in the caller instead.

◆ toBool()

ScssPhp\ScssPhp\Compiler::toBool ( $thing)

Cast to boolean.

@api

Parameters
bool$thing
Return values
array

◆ unifyCompoundSelectors()

ScssPhp\ScssPhp\Compiler::unifyCompoundSelectors ( $compound1,
$compound2 )
protected

The selector-unify magic as its best (at least works as expected on test cases)

Parameters
array$compound1
array$compound2
Return values
array

◆ unregisterFunction()

ScssPhp\ScssPhp\Compiler::unregisterFunction ( $name)

Unregister function.

@api

Parameters
string$name
Return values
void

◆ unsetVariable()

ScssPhp\ScssPhp\Compiler::unsetVariable ( $name)

Unset variable.

@api

Parameters
string$name
Return values
void

Member Data Documentation

◆ $charsetSeen

bool null ScssPhp\ScssPhp\Compiler::$charsetSeen
protected

◆ $Infinity

ScssPhp\ScssPhp\Compiler::$Infinity = [Type::T_KEYWORD, 'Infinity']
static

◆ $libComparable

ScssPhp\ScssPhp\Compiler::$libComparable
staticprotected
Initial value:
= [
['number1', 'number2'],
['number-1', 'number-2']
]

◆ $libGetFunction

ScssPhp\ScssPhp\Compiler::$libGetFunction
staticprotected
Initial value:
= [
['name'],
['name', 'css']
]

◆ $libHsl

ScssPhp\ScssPhp\Compiler::$libHsl
staticprotected
Initial value:
= [
['channels'],
['hue', 'saturation'],
['hue', 'saturation', 'lightness'],
['hue', 'saturation', 'lightness', 'alpha'] ]

◆ $libHsla

ScssPhp\ScssPhp\Compiler::$libHsla
staticprotected
Initial value:
= [
['channels'],
['hue', 'saturation'],
['hue', 'saturation', 'lightness'],
['hue', 'saturation', 'lightness', 'alpha']]

◆ $libMapMerge

ScssPhp\ScssPhp\Compiler::$libMapMerge
staticprotected
Initial value:
= [
['map1', 'map2'],
['map-1', 'map-2'],
['map1', 'args...']
]

◆ $libMapRemove

ScssPhp\ScssPhp\Compiler::$libMapRemove
staticprotected
Initial value:
= [
['map'],
['map', 'key', 'keys...'],
]

◆ $libMix

ScssPhp\ScssPhp\Compiler::$libMix
staticprotected
Initial value:
= [
['color1', 'color2', 'weight:50%'],
['color-1', 'color-2', 'weight:50%']
]

◆ $libRgb

ScssPhp\ScssPhp\Compiler::$libRgb
staticprotected
Initial value:
= [
['color'],
['color', 'alpha'],
['channels'],
['red', 'green', 'blue'],
['red', 'green', 'blue', 'alpha'] ]

◆ $libRgba

ScssPhp\ScssPhp\Compiler::$libRgba
staticprotected
Initial value:
= [
['color'],
['color', 'alpha'],
['channels'],
['red', 'green', 'blue'],
['red', 'green', 'blue', 'alpha'] ]

◆ $libSelectorExtend

ScssPhp\ScssPhp\Compiler::$libSelectorExtend
staticprotected
Initial value:
= [
['selector', 'extendee', 'extender'],
['selectors', 'extendee', 'extender']
]

◆ $libSelectorParse

ScssPhp\ScssPhp\Compiler::$libSelectorParse
staticprotected
Initial value:
= [
['selector'],
['selectors']
]

◆ $libSelectorReplace

ScssPhp\ScssPhp\Compiler::$libSelectorReplace
staticprotected
Initial value:
= [
['selector', 'original', 'replacement'],
['selectors', 'original', 'replacement']
]

◆ $lineNumberStyle

null ScssPhp\ScssPhp\Compiler::$lineNumberStyle = null
protected

◆ $NaN

ScssPhp\ScssPhp\Compiler::$NaN = [Type::T_KEYWORD, 'NaN']
static

◆ array< string, $namespaces=['special'=>

static ScssPhp\ScssPhp\Compiler::array< string, $namespaces=[ 'special'=>
staticprotected
Initial value:
=> 'sub',
'*' => 'mul',
'/' => 'div',
'%' => 'mod',
'==' => 'eq',
'!=' => 'neq',
'<' => 'lt',
'>' => 'gt',
'<=' => 'lte',
'>=' => 'gte',
]

string>

◆ DEBUG_INFO

const ScssPhp\ScssPhp\Compiler::DEBUG_INFO = 2

◆ LINE_COMMENTS

const ScssPhp\ScssPhp\Compiler::LINE_COMMENTS = 1

◆ WITH_ALL

const ScssPhp\ScssPhp\Compiler::WITH_ALL = 7

◆ WITH_MEDIA

const ScssPhp\ScssPhp\Compiler::WITH_MEDIA = 2

◆ WITH_RULE

const ScssPhp\ScssPhp\Compiler::WITH_RULE = 1

◆ WITH_SUPPORTS

const ScssPhp\ScssPhp\Compiler::WITH_SUPPORTS = 4

The documentation for this class was generated from the following file: