PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / sabberworm / php-css-parser / src / Value / CalcFunction.php
ameliabooking / vendor / sabberworm / php-css-parser / src / Value Last commit date
CSSFunction.php 6 months ago CSSString.php 6 months ago CalcFunction.php 6 months ago CalcRuleValueList.php 6 months ago Color.php 6 months ago LineName.php 6 months ago PrimitiveValue.php 6 months ago RuleValueList.php 6 months ago Size.php 6 months ago URL.php 6 months ago Value.php 6 months ago ValueList.php 6 months ago
CalcFunction.php
116 lines
1 <?php
2
3 namespace AmeliaVendor\Sabberworm\CSS\Value;
4
5 use AmeliaVendor\Sabberworm\CSS\Parsing\ParserState;
6 use AmeliaVendor\Sabberworm\CSS\Parsing\UnexpectedEOFException;
7 use AmeliaVendor\Sabberworm\CSS\Parsing\UnexpectedTokenException;
8
9 /**
10 * Support for `-webkit-calc` and `-moz-calc` is deprecated in version 8.8.0, and will be removed in version 9.0.0.
11 */
12 class CalcFunction extends CSSFunction
13 {
14 /**
15 * @var int
16 *
17 * @internal
18 */
19 const T_OPERAND = 1;
20
21 /**
22 * @var int
23 *
24 * @internal
25 */
26 const T_OPERATOR = 2;
27
28 /**
29 * @param ParserState $oParserState
30 * @param bool $bIgnoreCase
31 *
32 * @return CalcFunction
33 *
34 * @throws UnexpectedTokenException
35 * @throws UnexpectedEOFException
36 *
37 * @internal since V8.8.0
38 */
39 public static function parse(ParserState $oParserState, $bIgnoreCase = false)
40 {
41 $aOperators = ['+', '-', '*', '/'];
42 $sFunction = $oParserState->parseIdentifier();
43 if ($oParserState->peek() != '(') {
44 // Found ; or end of line before an opening bracket
45 throw new UnexpectedTokenException('(', $oParserState->peek(), 'literal', $oParserState->currentLine());
46 } elseif (!in_array($sFunction, ['calc', '-moz-calc', '-webkit-calc'])) {
47 // Found invalid calc definition. Example calc (...
48 throw new UnexpectedTokenException('calc', $sFunction, 'literal', $oParserState->currentLine());
49 }
50 $oParserState->consume('(');
51 $oCalcList = new CalcRuleValueList($oParserState->currentLine());
52 $oList = new RuleValueList(',', $oParserState->currentLine());
53 $iNestingLevel = 0;
54 $iLastComponentType = null;
55 while (!$oParserState->comes(')') || $iNestingLevel > 0) {
56 if ($oParserState->isEnd() && $iNestingLevel === 0) {
57 break;
58 }
59
60 $oParserState->consumeWhiteSpace();
61 if ($oParserState->comes('(')) {
62 $iNestingLevel++;
63 $oCalcList->addListComponent($oParserState->consume(1));
64 $oParserState->consumeWhiteSpace();
65 continue;
66 } elseif ($oParserState->comes(')')) {
67 $iNestingLevel--;
68 $oCalcList->addListComponent($oParserState->consume(1));
69 $oParserState->consumeWhiteSpace();
70 continue;
71 }
72 if ($iLastComponentType != CalcFunction::T_OPERAND) {
73 $oVal = Value::parsePrimitiveValue($oParserState);
74 $oCalcList->addListComponent($oVal);
75 $iLastComponentType = CalcFunction::T_OPERAND;
76 } else {
77 if (in_array($oParserState->peek(), $aOperators)) {
78 if (($oParserState->comes('-') || $oParserState->comes('+'))) {
79 if (
80 $oParserState->peek(1, -1) != ' '
81 || !($oParserState->comes('- ')
82 || $oParserState->comes('+ '))
83 ) {
84 throw new UnexpectedTokenException(
85 " {$oParserState->peek()} ",
86 $oParserState->peek(1, -1) . $oParserState->peek(2),
87 'literal',
88 $oParserState->currentLine()
89 );
90 }
91 }
92 $oCalcList->addListComponent($oParserState->consume(1));
93 $iLastComponentType = CalcFunction::T_OPERATOR;
94 } else {
95 throw new UnexpectedTokenException(
96 sprintf(
97 'Next token was expected to be an operand of type %s. Instead "%s" was found.',
98 implode(', ', $aOperators),
99 $oParserState->peek()
100 ),
101 '',
102 'custom',
103 $oParserState->currentLine()
104 );
105 }
106 }
107 $oParserState->consumeWhiteSpace();
108 }
109 $oList->addListComponent($oCalcList);
110 if (!$oParserState->isEnd()) {
111 $oParserState->consume(')');
112 }
113 return new CalcFunction($sFunction, $oList, ',', $oParserState->currentLine());
114 }
115 }
116