Passed
Push — GENERAL_BUG_REVIEW_240911 ( 6dbc7d...fb375d )
by Rafael
53:50
created
Dolibarr/Code/Core/Classes/lessc_parser.php 1 patch
Indentation   +1646 added lines, -1646 removed lines patch added patch discarded remove patch
@@ -61,1650 +61,1650 @@
 block discarded – undo
61 61
 // syntax tree
62 62
 class lessc_parser
63 63
 {
64
-	protected static $nextBlockId = 0; // used to uniquely identify blocks
65
-
66
-	protected static $precedence = array(
67
-		'=<' => 0,
68
-		'>=' => 0,
69
-		'=' => 0,
70
-		'<' => 0,
71
-		'>' => 0,
72
-
73
-		'+' => 1,
74
-		'-' => 1,
75
-		'*' => 2,
76
-		'/' => 2,
77
-		'%' => 2,
78
-	);
79
-
80
-	protected static $whitePattern;
81
-	protected static $commentMulti;
82
-
83
-	protected static $commentSingle = "//";
84
-	protected static $commentMultiLeft = "/*";
85
-	protected static $commentMultiRight = "*/";
86
-
87
-	// regex string to match any of the operators
88
-	protected static $operatorString;
89
-
90
-	// these properties will supress division unless it's inside parenthases
91
-	protected static $supressDivisionProps =
92
-		array('/border-radius$/i', '/^font$/i');
93
-
94
-	protected $blockDirectives = array("font-face", "keyframes", "page", "-moz-document", "viewport", "-moz-viewport", "-o-viewport", "-ms-viewport");
95
-	protected $lineDirectives = array("charset");
96
-
97
-	/**
98
-	 * if we are in parens we can be more liberal with whitespace around
99
-	 * operators because it must evaluate to a single value and thus is less
100
-	 * ambiguous.
101
-	 *
102
-	 * Consider:
103
-	 *     property1: 10 -5; // is two numbers, 10 and -5
104
-	 *     property2: (10 -5); // should evaluate to 5
105
-	 */
106
-	protected $inParens = false;
107
-
108
-	// caches preg escaped literals
109
-	protected static $literalCache = array();
110
-
111
-	public $env;
112
-	public $buffer;
113
-	public $count;
114
-	public $line;
115
-	public $eatWhiteDefault;
116
-	public $lessc;
117
-	public $sourceName;
118
-	public $writeComments;
119
-	public $seenComments;
120
-	public $currentProperty;
121
-	public $inExp;
122
-
123
-
124
-	public function __construct($lessc, $sourceName = null)
125
-	{
126
-		$this->eatWhiteDefault = true;
127
-		// reference to less needed for vPrefix, mPrefix, and parentSelector
128
-		$this->lessc = $lessc;
129
-
130
-		$this->sourceName = $sourceName; // name used for error messages
131
-
132
-		$this->writeComments = false;
133
-
134
-		if (!self::$operatorString) {
135
-			self::$operatorString =
136
-				'('.implode('|', array_map(
137
-					array('lessc', 'preg_quote'),
138
-					array_keys(self::$precedence)
139
-				)).')';
140
-
141
-			$commentSingle = Lessc::preg_quote(self::$commentSingle);
142
-			$commentMultiLeft = Lessc::preg_quote(self::$commentMultiLeft);
143
-			$commentMultiRight = Lessc::preg_quote(self::$commentMultiRight);
144
-
145
-			self::$commentMulti = $commentMultiLeft.'.*?'.$commentMultiRight;
146
-			self::$whitePattern = '/'.$commentSingle.'[^\n]*\s*|('.self::$commentMulti.')\s*|\s+/Ais';
147
-		}
148
-	}
149
-
150
-	/**
151
-	 * Parse a string
152
-	 *
153
-	 * @param       string  $buffer         String to parse
154
-	 * @throws exception
155
-	 * @return NULL|stdclass
156
-	 */
157
-	public function parse($buffer)
158
-	{
159
-		$this->count = 0;
160
-		$this->line = 1;
161
-
162
-		$this->env = null; // block stack
163
-		$this->buffer = $this->writeComments ? $buffer : $this->removeComments($buffer);
164
-		$this->pushSpecialBlock("root");
165
-		$this->eatWhiteDefault = true;
166
-		$this->seenComments = array();
167
-
168
-		// trim whitespace on head
169
-		// if (preg_match('/^\s+/', $this->buffer, $m)) {
170
-		//  $this->line += substr_count($m[0], "\n");
171
-		//  $this->buffer = ltrim($this->buffer);
172
-		// }
173
-		$this->whitespace();
174
-
175
-		// parse the entire file
176
-		while (false !== $this->parseChunk());
177
-
178
-		if ($this->count != strlen($this->buffer)) {
179
-			$this->throwError('parse error count '.$this->count.' != len buffer '.strlen($this->buffer));
180
-
181
-		}
182
-
183
-		// TODO report where the block was opened
184
-		if (!property_exists($this->env, 'parent') || !is_null($this->env->parent)) {
185
-			throw new exception('parse error: unclosed block');
186
-		}
187
-
188
-		return $this->env;
189
-	}
190
-
191
-	/**
192
-	 * Parse a single chunk off the head of the buffer and append it to the
193
-	 * current parse environment.
194
-	 * Returns false when the buffer is empty, or when there is an error.
195
-	 *
196
-	 * This function is called repeatedly until the entire document is
197
-	 * parsed.
198
-	 *
199
-	 * This parser is most similar to a recursive descent parser. Single
200
-	 * functions represent discrete grammatical rules for the language, and
201
-	 * they are able to capture the text that represents those rules.
202
-	 *
203
-	 * Consider the function Lessc::keyword(). (all parse functions are
204
-	 * structured the same)
205
-	 *
206
-	 * The function takes a single reference argument. When calling the
207
-	 * function it will attempt to match a keyword on the head of the buffer.
208
-	 * If it is successful, it will place the keyword in the referenced
209
-	 * argument, advance the position in the buffer, and return true. If it
210
-	 * fails then it won't advance the buffer and it will return false.
211
-	 *
212
-	 * All of these parse functions are powered by Lessc::match(), which behaves
213
-	 * the same way, but takes a literal regular expression. Sometimes it is
214
-	 * more convenient to use match instead of creating a new function.
215
-	 *
216
-	 * Because of the format of the functions, to parse an entire string of
217
-	 * grammatical rules, you can chain them together using &&.
218
-	 *
219
-	 * But, if some of the rules in the chain succeed before one fails, then
220
-	 * the buffer position will be left at an invalid state. In order to
221
-	 * avoid this, Lessc::seek() is used to remember and set buffer positions.
222
-	 *
223
-	 * Before parsing a chain, use $s = $this->seek() to remember the current
224
-	 * position into $s. Then if a chain fails, use $this->seek($s) to
225
-	 * go back where we started.
226
-	 */
227
-	protected function parseChunk()
228
-	{
229
-		if (empty($this->buffer)) {
230
-			return false;
231
-		}
232
-		$s = $this->seek();
233
-
234
-		if ($this->whitespace()) {
235
-			return true;
236
-		}
237
-
238
-		$key = null;
239
-		$value = null;
240
-		$mediaQueries = null;
241
-		$dirName = null;
242
-		$dirValue = null;
243
-		$importValue = null;
244
-		$guards = null;
245
-		$tag = null;
246
-		$args = null;
247
-		$isVararg = null;
248
-		$argv = null;
249
-		$suffix = null;
250
-		$var = null;
251
-		$tags = null;
252
-
253
-		// setting a property
254
-		if ($this->keyword($key) && $this->assign() &&
255
-			$this->propertyValue($value, $key) && $this->end()
256
-		) {
257
-			$this->append(array('assign', $key, $value), $s);
258
-			return true;
259
-		} else {
260
-			$this->seek($s);
261
-		}
262
-
263
-
264
-		// look for special css blocks
265
-		if ($this->literal('@', false)) {
266
-			$this->count--;
267
-
268
-			// media
269
-			if ($this->literal('@media')) {
270
-				if ($this->mediaQueryList($mediaQueries)
271
-					&& $this->literal('{')
272
-				) {
273
-					$media = $this->pushSpecialBlock("media");
274
-					$media->queries = is_null($mediaQueries) ? array() : $mediaQueries;
275
-					return true;
276
-				} else {
277
-					$this->seek($s);
278
-					return false;
279
-				}
280
-			}
281
-
282
-			if ($this->literal("@", false) && $this->keyword($dirName)) {
283
-				if ($this->isDirective($dirName, $this->blockDirectives)) {
284
-					if ($this->openString("{", $dirValue, null, array(";")) &&
285
-						$this->literal("{")
286
-					) {
287
-						$dir = $this->pushSpecialBlock("directive");
288
-						$dir->name = $dirName;
289
-						if (isset($dirValue)) {
290
-							$dir->value = $dirValue;
291
-						}
292
-						return true;
293
-					}
294
-				} elseif ($this->isDirective($dirName, $this->lineDirectives)) {
295
-					if ($this->propertyValue($dirValue) && $this->end()) {
296
-						$this->append(array("directive", $dirName, $dirValue));
297
-						return true;
298
-					}
299
-				}
300
-			}
301
-
302
-			$this->seek($s);
303
-		}
304
-
305
-		// setting a variable
306
-		if ($this->variable($var) && $this->assign() &&
307
-			$this->propertyValue($value) && $this->end()
308
-		) {
309
-			$this->append(array('assign', $var, $value), $s);
310
-			return true;
311
-		} else {
312
-			$this->seek($s);
313
-		}
314
-
315
-		if ($this->import($importValue)) {
316
-			$this->append($importValue, $s);
317
-			return true;
318
-		}
319
-
320
-		// opening parametric mixin
321
-		if ($this->tag($tag, true) && $this->argumentDef($args, $isVararg) &&
322
-			$this->guards($guards) &&
323
-			$this->literal('{')
324
-		) {
325
-			$block = $this->pushBlock($this->fixTags(array($tag)));
326
-			$block->args = $args;
327
-			$block->isVararg = $isVararg;
328
-			if (!empty($guards)) {
329
-				$block->guards = $guards;
330
-			}
331
-			return true;
332
-		} else {
333
-			$this->seek($s);
334
-		}
335
-
336
-		// opening a simple block
337
-		if ($this->tags($tags) && $this->literal('{', false)) {
338
-			$tags = $this->fixTags($tags);
339
-			$this->pushBlock($tags);
340
-			return true;
341
-		} else {
342
-			$this->seek($s);
343
-		}
344
-
345
-		// closing a block
346
-		if ($this->literal('}', false)) {
347
-			try {
348
-				$block = $this->pop();
349
-			} catch (exception $e) {
350
-				$this->seek($s);
351
-				$this->throwError($e->getMessage());
352
-			}
353
-
354
-			$hidden = false;
355
-			if (is_null($block->type)) {
356
-				$hidden = true;
357
-				if (!isset($block->args)) {
358
-					foreach ($block->tags as $tag) {
359
-						if (!is_string($tag) || $tag[0] != $this->lessc->mPrefix) {
360
-							$hidden = false;
361
-							break;
362
-						}
363
-					}
364
-				}
365
-
366
-				foreach ($block->tags as $tag) {
367
-					if (is_string($tag)) {
368
-						$this->env->children[$tag][] = $block;
369
-					}
370
-				}
371
-			}
372
-
373
-			if (!$hidden) {
374
-				$this->append(array('block', $block), $s);
375
-			}
376
-
377
-			// this is done here so comments aren't bundled into he block that
378
-			// was just closed
379
-			$this->whitespace();
380
-			return true;
381
-		}
382
-
383
-		// mixin
384
-		if ($this->mixinTags($tags) &&
385
-			$this->argumentDef($argv, $isVararg) &&
386
-			$this->keyword($suffix)  && $this->end()
387
-		) {
388
-			$tags = $this->fixTags($tags);
389
-			$this->append(array('mixin', $tags, $argv, $suffix), $s);
390
-			return true;
391
-		} else {
392
-			$this->seek($s);
393
-		}
394
-
395
-		// spare ;
396
-		if ($this->literal(';')) {
397
-			return true;
398
-		}
399
-
400
-		return false; // got nothing, throw error
401
-	}
402
-
403
-	protected function isDirective($dirname, $directives)
404
-	{
405
-		// TODO: cache pattern in parser
406
-		$pattern = implode(
407
-			"|",
408
-			array_map(array("lessc", "preg_quote"), $directives)
409
-		);
410
-		$pattern = '/^(-[a-z-]+-)?('.$pattern.')$/i';
411
-
412
-		return preg_match($pattern, $dirname);
413
-	}
414
-
415
-	protected function fixTags($tags)
416
-	{
417
-		// move @ tags out of variable namespace
418
-		foreach ($tags as &$tag) {
419
-			if ($tag[0] == $this->lessc->vPrefix) {
420
-				$tag[0] = $this->lessc->mPrefix;
421
-			}
422
-		}
423
-		return $tags;
424
-	}
425
-
426
-	// a list of expressions
427
-	protected function expressionList(&$exps)
428
-	{
429
-		$exp = null;
430
-
431
-		$values = array();
432
-
433
-		while ($this->expression($exp)) {
434
-			$values[] = $exp;
435
-		}
436
-
437
-		if (count($values) == 0) {
438
-			return false;
439
-		}
440
-
441
-		$exps = Lessc::compressList($values, ' ');
442
-		return true;
443
-	}
444
-
445
-	/**
446
-	 * Attempt to consume an expression.
447
-	 * @link http://en.wikipedia.org/wiki/Operator-precedence_parser#Pseudo-code
448
-	 */
449
-	protected function expression(&$out)
450
-	{
451
-		$lhs = null;
452
-		$rhs = null;
453
-
454
-		if ($this->value($lhs)) {
455
-			$out = $this->expHelper($lhs, 0);
456
-
457
-			// look for / shorthand
458
-			if (!empty($this->env->supressedDivision)) {
459
-				unset($this->env->supressedDivision);
460
-				$s = $this->seek();
461
-				if ($this->literal("/") && $this->value($rhs)) {
462
-					$out = array("list", "",
463
-						array($out, array("keyword", "/"), $rhs));
464
-				} else {
465
-					$this->seek($s);
466
-				}
467
-			}
468
-
469
-			return true;
470
-		}
471
-		return false;
472
-	}
473
-
474
-	/**
475
-	 * recursively parse infix equation with $lhs at precedence $minP
476
-	 */
477
-	protected function expHelper($lhs, $minP)
478
-	{
479
-		$next = null;
480
-		$rhs = null;
481
-
482
-		$this->inExp = true;
483
-		$ss = $this->seek();
484
-
485
-		while (true) {
486
-			$whiteBefore = isset($this->buffer[$this->count - 1]) &&
487
-				ctype_space($this->buffer[$this->count - 1]);
488
-
489
-			// If there is whitespace before the operator, then we require
490
-			// whitespace after the operator for it to be an expression
491
-			$needWhite = $whiteBefore && !$this->inParens;
492
-
493
-			$m = array();
494
-			if ($this->match(self::$operatorString.($needWhite ? '\s' : ''), $m) && self::$precedence[$m[1]] >= $minP) {
495
-				if (!$this->inParens && isset($this->env->currentProperty) && $m[1] == "/" && empty($this->env->supressedDivision)) {
496
-					foreach (self::$supressDivisionProps as $pattern) {
497
-						if (preg_match($pattern, $this->env->currentProperty)) {
498
-							$this->env->supressedDivision = true;
499
-							break 2;
500
-						}
501
-					}
502
-				}
503
-
504
-
505
-				$whiteAfter = isset($this->buffer[$this->count - 1]) &&
506
-					ctype_space($this->buffer[$this->count - 1]);
507
-
508
-				if (!$this->value($rhs)) {
509
-					break;
510
-				}
511
-
512
-				// peek for next operator to see what to do with rhs
513
-				if ($this->peek(self::$operatorString, $next) && self::$precedence[$next[1]] > self::$precedence[$m[1]]) {
514
-					$rhs = $this->expHelper($rhs, self::$precedence[$next[1]]);
515
-				}
516
-
517
-				$lhs = array('expression', $m[1], $lhs, $rhs, $whiteBefore, $whiteAfter);
518
-				$ss = $this->seek();
519
-
520
-				continue;
521
-			}
522
-
523
-			break;
524
-		}
525
-
526
-		$this->seek($ss);
527
-
528
-		return $lhs;
529
-	}
530
-
531
-	// consume a list of values for a property
532
-	public function propertyValue(&$value, $keyName = null)
533
-	{
534
-		$v = null;
535
-		$values = array();
536
-
537
-		if ($keyName !== null) {
538
-			$this->env->currentProperty = $keyName;
539
-		}
540
-
541
-		$s = null;
542
-		while ($this->expressionList($v)) {
543
-			$values[] = $v;
544
-			$s = $this->seek();
545
-			if (!$this->literal(',')) {
546
-				break;
547
-			}
548
-		}
549
-
550
-		if ($s) {
551
-			$this->seek($s);
552
-		}
553
-
554
-		if ($keyName !== null) {
555
-			unset($this->env->currentProperty);
556
-		}
557
-
558
-		if (count($values) == 0) {
559
-			return false;
560
-		}
561
-
562
-		$value = Lessc::compressList($values, ', ');
563
-		return true;
564
-	}
565
-
566
-	protected function parenValue(&$out)
567
-	{
568
-		$exp = null;
569
-
570
-		$s = $this->seek();
571
-
572
-		// speed shortcut
573
-		if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] != "(") {
574
-			return false;
575
-		}
576
-
577
-		$inParens = $this->inParens;
578
-		if ($this->literal("(") &&
579
-			($this->inParens = true) && $this->expression($exp) &&
580
-			$this->literal(")")
581
-		) {
582
-			$out = $exp;
583
-			$this->inParens = $inParens;
584
-			return true;
585
-		} else {
586
-			$this->inParens = $inParens;
587
-			$this->seek($s);
588
-		}
589
-
590
-		return false;
591
-	}
592
-
593
-	// a single value
594
-	protected function value(&$value)
595
-	{
596
-		$inner = null;
597
-		$word = null;
598
-		$str = null;
599
-		$var = null;
600
-
601
-		$s = $this->seek();
602
-
603
-		// speed shortcut
604
-		if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] == "-") {
605
-			// negation
606
-			if ($this->literal("-", false) &&
607
-				(($this->variable($inner) && $inner = array("variable", $inner)) ||
608
-				$this->unit($inner) ||
609
-				$this->parenValue($inner))
610
-			) {
611
-				$value = array("unary", "-", $inner);
612
-				return true;
613
-			} else {
614
-				$this->seek($s);
615
-			}
616
-		}
617
-
618
-		if ($this->parenValue($value)) {
619
-			return true;
620
-		}
621
-		if ($this->unit($value)) {
622
-			return true;
623
-		}
624
-		if ($this->color($value)) {
625
-			return true;
626
-		}
627
-		if ($this->func($value)) {
628
-			return true;
629
-		}
630
-		if ($this->string($value)) {
631
-			return true;
632
-		}
633
-
634
-		if ($this->keyword($word)) {
635
-			$value = array('keyword', $word);
636
-			return true;
637
-		}
638
-
639
-		// try a variable
640
-		if ($this->variable($var)) {
641
-			$value = array('variable', $var);
642
-			return true;
643
-		}
644
-
645
-		// unquote string (should this work on any type?
646
-		if ($this->literal("~") && $this->string($str)) {
647
-			$value = array("escape", $str);
648
-			return true;
649
-		} else {
650
-			$this->seek($s);
651
-		}
652
-
653
-		// css hack: \0
654
-		$m = array();
655
-		if ($this->literal('\\') && $this->match('([0-9]+)', $m)) {
656
-			$value = array('keyword', '\\'.$m[1]);
657
-			return true;
658
-		} else {
659
-			$this->seek($s);
660
-		}
661
-
662
-		return false;
663
-	}
664
-
665
-	// an import statement
666
-	protected function import(&$out, $value = '')
667
-	{
668
-		if (!$this->literal('@import')) {
669
-			return false;
670
-		}
671
-
672
-		// @import "something.css" media;
673
-		// @import url("something.css") media;
674
-		// @import url(something.css) media;
675
-
676
-		if ($this->propertyValue($value)) {
677
-			$out = array("import", $value);
678
-			return true;
679
-		}
680
-
681
-		return false;
682
-	}
683
-
684
-	protected function mediaQueryList(&$out)
685
-	{
686
-		$list = null;
687
-
688
-		if ($this->genericList($list, "mediaQuery", ",", false)) {
689
-			$out = $list[2];
690
-			return true;
691
-		}
692
-		return false;
693
-	}
694
-
695
-	protected function mediaQuery(&$out)
696
-	{
697
-		$mediaType = null;
698
-
699
-		$s = $this->seek();
700
-
701
-		$expressions = null;
702
-		$parts = array();
703
-
704
-		if ((($this->literal("only") && ($only = true)) || ($this->literal("not") && ($not = true))) && $this->keyword($mediaType)) {
705
-			$prop = array("mediaType");
706
-			if (isset($only)) {
707
-				$prop[] = "only";
708
-			}
709
-			if (isset($not)) {
710
-				$prop[] = "not";
711
-			}
712
-			$prop[] = $mediaType;
713
-			$parts[] = $prop;
714
-		} else {
715
-			$this->seek($s);
716
-		}
717
-
718
-
719
-		if (!empty($mediaType) && !$this->literal("and")) {
720
-			// ~
721
-		} else {
722
-			$this->genericList($expressions, "mediaExpression", "and", false);
723
-			if (is_array($expressions)) {
724
-				$parts = array_merge($parts, $expressions[2]);
725
-			}
726
-		}
727
-
728
-		if (count($parts) == 0) {
729
-			$this->seek($s);
730
-			return false;
731
-		}
732
-
733
-		$out = $parts;
734
-		return true;
735
-	}
736
-
737
-	protected function mediaExpression(&$out)
738
-	{
739
-		$feature = null;
740
-		$variable = null;
741
-
742
-		$s = $this->seek();
743
-		$value = null;
744
-		if ($this->literal("(") &&
745
-			$this->keyword($feature) &&
746
-			($this->literal(":") && $this->expression($value)) &&
747
-			$this->literal(")")
748
-		) {
749
-			$out = array("mediaExp", $feature);
750
-			if ($value) {
751
-				$out[] = $value;
752
-			}
753
-			return true;
754
-		} elseif ($this->variable($variable)) {
755
-			$out = array('variable', $variable);
756
-			return true;
757
-		}
758
-
759
-		$this->seek($s);
760
-		return false;
761
-	}
762
-
763
-	// an unbounded string stopped by $end
764
-	protected function openString($end, &$out, $nestingOpen = null, $rejectStrs = null)
765
-	{
766
-		$str = null;
767
-		$inter = null;
768
-
769
-		$oldWhite = $this->eatWhiteDefault;
770
-		$this->eatWhiteDefault = false;
771
-
772
-		$stop = array("'", '"', "@{", $end);
773
-		$stop = array_map(array("lessc", "preg_quote"), $stop);
774
-		// $stop[] = self::$commentMulti;
775
-
776
-		if (!is_null($rejectStrs)) {
777
-			$stop = array_merge($stop, $rejectStrs);
778
-		}
779
-
780
-		$patt = '(.*?)('.implode("|", $stop).')';
781
-
782
-		$nestingLevel = 0;
783
-
784
-		$content = array();
785
-		$m = array();
786
-		while ($this->match($patt, $m, false)) {
787
-			if (!empty($m[1])) {
788
-				$content[] = $m[1];
789
-				if ($nestingOpen) {
790
-					$nestingLevel += substr_count($m[1], $nestingOpen);
791
-				}
792
-			}
793
-
794
-			$tok = $m[2];
795
-
796
-			$this->count -= strlen($tok);
797
-			if ($tok == $end) {
798
-				if ($nestingLevel == 0) {
799
-					break;
800
-				} else {
801
-					$nestingLevel--;
802
-				}
803
-			}
804
-
805
-			if (($tok == "'" || $tok == '"') && $this->string($str)) {
806
-				$content[] = $str;
807
-				continue;
808
-			}
809
-
810
-			if ($tok == "@{" && $this->interpolation($inter)) {
811
-				$content[] = $inter;
812
-				continue;
813
-			}
814
-
815
-			if (!empty($rejectStrs) && in_array($tok, $rejectStrs)) {
816
-				break;
817
-			}
818
-
819
-			$content[] = $tok;
820
-			$this->count += strlen($tok);
821
-		}
822
-
823
-		$this->eatWhiteDefault = $oldWhite;
824
-
825
-		if (count($content) == 0) {
826
-			return false;
827
-		}
828
-
829
-		// trim the end
830
-		if (is_string(end($content))) {
831
-			$content[count($content) - 1] = rtrim(end($content));
832
-		}
833
-
834
-		$out = array("string", "", $content);
835
-		return true;
836
-	}
837
-
838
-	protected function string(&$out)
839
-	{
840
-		$inter = null;
841
-
842
-		$s = $this->seek();
843
-		if ($this->literal('"', false)) {
844
-			$delim = '"';
845
-		} elseif ($this->literal("'", false)) {
846
-			$delim = "'";
847
-		} else {
848
-			return false;
849
-		}
850
-
851
-		$content = array();
852
-
853
-		// look for either ending delim , escape, or string interpolation
854
-		$patt = '([^\n]*?)(@\{|\\\\|'.
855
-			Lessc::preg_quote($delim).')';
856
-
857
-		$oldWhite = $this->eatWhiteDefault;
858
-		$this->eatWhiteDefault = false;
859
-
860
-		$m = array();
861
-		while ($this->match($patt, $m, false)) {
862
-			$content[] = $m[1];
863
-			if ($m[2] == "@{") {
864
-				$this->count -= strlen($m[2]);
865
-				if ($this->interpolation($inter)) {
866
-					$content[] = $inter;
867
-				} else {
868
-					$this->count += strlen($m[2]);
869
-					$content[] = "@{"; // ignore it
870
-				}
871
-			} elseif ($m[2] == '\\') {
872
-				$content[] = $m[2];
873
-				if ($this->literal($delim, false)) {
874
-					$content[] = $delim;
875
-				}
876
-			} else {
877
-				$this->count -= strlen($delim);
878
-				break; // delim
879
-			}
880
-		}
881
-
882
-		$this->eatWhiteDefault = $oldWhite;
883
-
884
-		if ($this->literal($delim)) {
885
-			$out = array("string", $delim, $content);
886
-			return true;
887
-		}
888
-
889
-		$this->seek($s);
890
-		return false;
891
-	}
892
-
893
-	protected function interpolation(&$out)
894
-	{
895
-		$interp = array();
896
-
897
-		$oldWhite = $this->eatWhiteDefault;
898
-		$this->eatWhiteDefault = true;
899
-
900
-		$s = $this->seek();
901
-		if ($this->literal("@{") &&
902
-			$this->openString("}", $interp, null, array("'", '"', ";")) &&
903
-			$this->literal("}", false)
904
-		) {
905
-			$out = array("interpolate", $interp);
906
-			$this->eatWhiteDefault = $oldWhite;
907
-			if ($this->eatWhiteDefault) {
908
-				$this->whitespace();
909
-			}
910
-			return true;
911
-		}
912
-
913
-		$this->eatWhiteDefault = $oldWhite;
914
-		$this->seek($s);
915
-		return false;
916
-	}
917
-
918
-	protected function unit(&$unit)
919
-	{
920
-		$m = array();
921
-
922
-		// speed shortcut
923
-		if (isset($this->buffer[$this->count])) {
924
-			$char = $this->buffer[$this->count];
925
-			if (!ctype_digit($char) && $char != ".") {
926
-				return false;
927
-			}
928
-		}
929
-
930
-		if ($this->match('([0-9]+(?:\.[0-9]*)?|\.[0-9]+)([%a-zA-Z]+)?', $m)) {
931
-			$unit = array("number", $m[1], empty($m[2]) ? "" : $m[2]);
932
-			return true;
933
-		}
934
-		return false;
935
-	}
936
-
937
-	// a # color
938
-	protected function color(&$out)
939
-	{
940
-		$m = array();
941
-
942
-		if ($this->match('(#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3}))', $m)) {
943
-			if (strlen($m[1]) > 7) {
944
-				$out = array("string", "", array($m[1]));
945
-			} else {
946
-				$out = array("raw_color", $m[1]);
947
-			}
948
-			return true;
949
-		}
950
-
951
-		return false;
952
-	}
953
-
954
-	// consume an argument definition list surrounded by ()
955
-	// each argument is a variable name with optional value
956
-	// or at the end a ... or a variable named followed by ...
957
-	// arguments are separated by , unless a ; is in the list, then ; is the
958
-	// delimiter.
959
-	protected function argumentDef(&$args, &$isVararg)
960
-	{
961
-		$value = array();
962
-		$rhs = null;
963
-
964
-		$s = $this->seek();
965
-		if (!$this->literal('(')) {
966
-			return false;
967
-		}
968
-
969
-		$values = array();
970
-		$delim = ",";
971
-		$method = "expressionList";
972
-
973
-		$isVararg = false;
974
-		while (true) {
975
-			if ($this->literal("...")) {
976
-				$isVararg = true;
977
-				break;
978
-			}
979
-
980
-			if ($this->$method($value)) {
981
-				if ($value[0] == "variable") {
982
-					$arg = array("arg", $value[1]);
983
-					$ss = $this->seek();
984
-
985
-					if ($this->assign() && $this->$method($rhs)) {
986
-						$arg[] = $rhs;
987
-					} else {
988
-						$this->seek($ss);
989
-						if ($this->literal("...")) {
990
-							$arg[0] = "rest";
991
-							$isVararg = true;
992
-						}
993
-					}
994
-
995
-					$values[] = $arg;
996
-					if ($isVararg) {
997
-						break;
998
-					}
999
-					continue;
1000
-				} else {
1001
-					$values[] = array("lit", $value);
1002
-				}
1003
-			}
1004
-
1005
-
1006
-			if (!$this->literal($delim)) {
1007
-				if ($delim == "," && $this->literal(";")) {
1008
-					// found new delim, convert existing args
1009
-					$delim = ";";
1010
-					$method = "propertyValue";
1011
-
1012
-					// transform arg list
1013
-					if (isset($values[1])) { // 2 items
1014
-						$newList = array();
1015
-						foreach ($values as $i => $arg) {
1016
-							switch ($arg[0]) {
1017
-								case "arg":
1018
-									if ($i) {
1019
-										$this->throwError("Cannot mix ; and , as delimiter types");
1020
-									}
1021
-									$newList[] = $arg[2];
1022
-									break;
1023
-								case "lit":
1024
-									$newList[] = $arg[1];
1025
-									break;
1026
-								case "rest":
1027
-									$this->throwError("Unexpected rest before semicolon");
1028
-							}
1029
-						}
1030
-
1031
-						$newList = array("list", ", ", $newList);
1032
-
1033
-						switch ($values[0][0]) {
1034
-							case "arg":
1035
-								$newArg = array("arg", $values[0][1], $newList);
1036
-								break;
1037
-							case "lit":
1038
-								$newArg = array("lit", $newList);
1039
-								break;
1040
-						}
1041
-
1042
-					} elseif ($values) { // 1 item
1043
-						$newArg = $values[0];
1044
-					}
1045
-
1046
-					if ($newArg) {
1047
-						$values = array($newArg);
1048
-					}
1049
-				} else {
1050
-					break;
1051
-				}
1052
-			}
1053
-		}
1054
-
1055
-		if (!$this->literal(')')) {
1056
-			$this->seek($s);
1057
-			return false;
1058
-		}
1059
-
1060
-		$args = $values;
1061
-
1062
-		return true;
1063
-	}
1064
-
1065
-	// consume a list of tags
1066
-	// this accepts a hanging delimiter
1067
-	protected function tags(&$tags, $simple = false, $delim = ',')
1068
-	{
1069
-		$tt = array();
1070
-
1071
-		$tags = array();
1072
-		while ($this->tag($tt, $simple)) {
1073
-			$tags[] = $tt;
1074
-			if (!$this->literal($delim)) {
1075
-				break;
1076
-			}
1077
-		}
1078
-		if (count($tags) == 0) {
1079
-			return false;
1080
-		}
1081
-
1082
-		return true;
1083
-	}
1084
-
1085
-	// list of tags of specifying mixin path
1086
-	// optionally separated by > (lazy, accepts extra >)
1087
-	protected function mixinTags(&$tags)
1088
-	{
1089
-		$tt = array();
1090
-
1091
-		$tags = array();
1092
-		while ($this->tag($tt, true)) {
1093
-			$tags[] = $tt;
1094
-			$this->literal(">");
1095
-		}
1096
-
1097
-		if (!$tags) {
1098
-			return false;
1099
-		}
1100
-
1101
-		return true;
1102
-	}
1103
-
1104
-	// a bracketed value (contained within in a tag definition)
1105
-	protected function tagBracket(&$parts, &$hasExpression)
1106
-	{
1107
-		$str = null;
1108
-		$inter = null;
1109
-		$word = null;
1110
-
1111
-		// speed shortcut
1112
-		if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] != "[") {
1113
-			return false;
1114
-		}
1115
-
1116
-		$s = $this->seek();
1117
-
1118
-		$hasInterpolation = false;
1119
-
1120
-		if ($this->literal("[", false)) {
1121
-			$attrParts = array("[");
1122
-			// keyword, string, operator
1123
-			while (true) {
1124
-				if ($this->literal("]", false)) {
1125
-					$this->count--;
1126
-					break; // get out early
1127
-				}
1128
-
1129
-				$m = array();
1130
-				if ($this->match('\s+', $m)) {
1131
-					$attrParts[] = " ";
1132
-					continue;
1133
-				}
1134
-				if ($this->string($str)) {
1135
-					// escape parent selector, (yuck)
1136
-					foreach ($str[2] as &$chunk) {
1137
-						$chunk = str_replace($this->lessc->parentSelector, "$&$", $chunk);
1138
-					}
1139
-
1140
-					$attrParts[] = $str;
1141
-					$hasInterpolation = true;
1142
-					continue;
1143
-				}
1144
-
1145
-				if ($this->keyword($word)) {
1146
-					$attrParts[] = $word;
1147
-					continue;
1148
-				}
1149
-
1150
-				if ($this->interpolation($inter)) {
1151
-					$attrParts[] = $inter;
1152
-					$hasInterpolation = true;
1153
-					continue;
1154
-				}
1155
-
1156
-				// operator, handles attr namespace too
1157
-				if ($this->match('[|-~\$\*\^=]+', $m)) {
1158
-					$attrParts[] = $m[0];
1159
-					continue;
1160
-				}
1161
-
1162
-				break;
1163
-			}
1164
-
1165
-			if ($this->literal("]", false)) {
1166
-				$attrParts[] = "]";
1167
-				foreach ($attrParts as $part) {
1168
-					$parts[] = $part;
1169
-				}
1170
-				$hasExpression = $hasExpression || $hasInterpolation;
1171
-				return true;
1172
-			}
1173
-			$this->seek($s);
1174
-		}
1175
-
1176
-		$this->seek($s);
1177
-		return false;
1178
-	}
1179
-
1180
-	// a space separated list of selectors
1181
-	protected function tag(&$tag, $simple = false)
1182
-	{
1183
-		$interp = null;
1184
-		$unit = null;
1185
-
1186
-		if ($simple) {
1187
-			$chars = '^@,:;{}\][>\(\) "\'';
1188
-		} else {
1189
-			$chars = '^@,;{}["\'';
1190
-		}
1191
-		$s = $this->seek();
1192
-
1193
-		$hasExpression = false;
1194
-		$parts = array();
1195
-		while ($this->tagBracket($parts, $hasExpression));
1196
-
1197
-		$oldWhite = $this->eatWhiteDefault;
1198
-		$this->eatWhiteDefault = false;
1199
-
1200
-		while (true) {
1201
-			$m = array();
1202
-			if ($this->match('(['.$chars.'0-9]['.$chars.']*)', $m)) {
1203
-				$parts[] = $m[1];
1204
-				if ($simple) {
1205
-					break;
1206
-				}
1207
-
1208
-				while ($this->tagBracket($parts, $hasExpression));
1209
-				continue;
1210
-			}
1211
-
1212
-			if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] == "@") {
1213
-				if ($this->interpolation($interp)) {
1214
-					$hasExpression = true;
1215
-					$interp[2] = true; // don't unescape
1216
-					$parts[] = $interp;
1217
-					continue;
1218
-				}
1219
-
1220
-				if ($this->literal("@")) {
1221
-					$parts[] = "@";
1222
-					continue;
1223
-				}
1224
-			}
1225
-
1226
-			if ($this->unit($unit)) { // for keyframes
1227
-				$parts[] = $unit[1];
1228
-				$parts[] = $unit[2];
1229
-				continue;
1230
-			}
1231
-
1232
-			break;
1233
-		}
1234
-
1235
-		$this->eatWhiteDefault = $oldWhite;
1236
-		if (!$parts) {
1237
-			$this->seek($s);
1238
-			return false;
1239
-		}
1240
-
1241
-		if ($hasExpression) {
1242
-			$tag = array("exp", array("string", "", $parts));
1243
-		} else {
1244
-			$tag = trim(implode($parts));
1245
-		}
1246
-
1247
-		$this->whitespace();
1248
-		return true;
1249
-	}
1250
-
1251
-	// a css function
1252
-	protected function func(&$func)
1253
-	{
1254
-		$s = $this->seek();
1255
-
1256
-		$m = array();
1257
-		$value = array();
1258
-		$string = array();
1259
-		$name = null;
1260
-
1261
-		if ($this->match('(%|[\w\-_][\w\-_:\.]+|[\w_])', $m) && $this->literal('(')) {
1262
-			$fname = $m[1];
1263
-
1264
-			$sPreArgs = $this->seek();
1265
-
1266
-			$args = array();
1267
-			while (true) {
1268
-				$ss = $this->seek();
1269
-				// this ugly nonsense is for ie filter properties
1270
-				if ($this->keyword($name) && $this->literal('=') && $this->expressionList($value)) {
1271
-					$args[] = array("string", "", array($name, "=", $value));
1272
-				} else {
1273
-					$this->seek($ss);
1274
-					if ($this->expressionList($value)) {
1275
-						$args[] = $value;
1276
-					}
1277
-				}
1278
-
1279
-				if (!$this->literal(',')) {
1280
-					break;
1281
-				}
1282
-			}
1283
-			$args = array('list', ',', $args);
1284
-
1285
-			if ($this->literal(')')) {
1286
-				$func = array('function', $fname, $args);
1287
-				return true;
1288
-			} elseif ($fname == 'url') {
1289
-				// couldn't parse and in url? treat as string
1290
-				$this->seek($sPreArgs);
1291
-				if ($this->openString(")", $string) && $this->literal(")")) {
1292
-					$func = array('function', $fname, $string);
1293
-					return true;
1294
-				}
1295
-			}
1296
-		}
1297
-
1298
-		$this->seek($s);
1299
-		return false;
1300
-	}
1301
-
1302
-	// consume a less variable
1303
-	protected function variable(&$name)
1304
-	{
1305
-		$sub = null;
1306
-		$name = null;
1307
-
1308
-		$s = $this->seek();
1309
-		if ($this->literal($this->lessc->vPrefix, false) &&
1310
-			($this->variable($sub) || $this->keyword($name))
1311
-		) {
1312
-			if (!empty($sub)) {
1313
-				$name = array('variable', $sub);
1314
-			} else {
1315
-				$name = $this->lessc->vPrefix.$name;
1316
-			}
1317
-			return true;
1318
-		}
1319
-
1320
-		$name = null;
1321
-		$this->seek($s);
1322
-		return false;
1323
-	}
1324
-
1325
-	/**
1326
-	 * Consume an assignment operator
1327
-	 * Can optionally take a name that will be set to the current property name
1328
-	 */
1329
-	protected function assign($name = null)
1330
-	{
1331
-		if ($name) {
1332
-			$this->currentProperty = $name;
1333
-		}
1334
-		return $this->literal(':') || $this->literal('=');
1335
-	}
1336
-
1337
-	// consume a keyword
1338
-	protected function keyword(&$word)
1339
-	{
1340
-		$m = array();
1341
-		if ($this->match('([\w_\-\*!"][\w\-_"]*)', $m)) {
1342
-			$word = $m[1];
1343
-			return true;
1344
-		}
1345
-		return false;
1346
-	}
1347
-
1348
-	// consume an end of statement delimiter
1349
-	protected function end()
1350
-	{
1351
-		if ($this->literal(';', false)) {
1352
-			return true;
1353
-		} elseif ($this->count == strlen($this->buffer) || $this->buffer[$this->count] == '}') {
1354
-			// if there is end of file or a closing block next then we don't need a ;
1355
-			return true;
1356
-		}
1357
-		return false;
1358
-	}
1359
-
1360
-	protected function guards(&$guards)
1361
-	{
1362
-		$g = null;
1363
-
1364
-		$s = $this->seek();
1365
-
1366
-		if (!$this->literal("when")) {
1367
-			$this->seek($s);
1368
-			return false;
1369
-		}
1370
-
1371
-		$guards = array();
1372
-
1373
-		while ($this->guardGroup($g)) {
1374
-			$guards[] = $g;
1375
-			if (!$this->literal(",")) {
1376
-				break;
1377
-			}
1378
-		}
1379
-
1380
-		if (count($guards) == 0) {
1381
-			$guards = null;
1382
-			$this->seek($s);
1383
-			return false;
1384
-		}
1385
-
1386
-		return true;
1387
-	}
1388
-
1389
-	// a bunch of guards that are and'd together
1390
-	// TODO rename to guardGroup
1391
-	protected function guardGroup(&$guardGroup)
1392
-	{
1393
-		$guard = null;
1394
-
1395
-		$s = $this->seek();
1396
-		$guardGroup = array();
1397
-		while ($this->guard($guard)) {
1398
-			$guardGroup[] = $guard;
1399
-			if (!$this->literal("and")) {
1400
-				break;
1401
-			}
1402
-		}
1403
-
1404
-		if (count($guardGroup) == 0) {
1405
-			$guardGroup = null;
1406
-			$this->seek($s);
1407
-			return false;
1408
-		}
1409
-
1410
-		return true;
1411
-	}
1412
-
1413
-	protected function guard(&$guard)
1414
-	{
1415
-		$exp = null;
1416
-
1417
-		$s = $this->seek();
1418
-		$negate = $this->literal("not");
1419
-
1420
-		if ($this->literal("(") && $this->expression($exp) && $this->literal(")")) {
1421
-			$guard = $exp;
1422
-			if ($negate) {
1423
-				$guard = array("negate", $guard);
1424
-			}
1425
-			return true;
1426
-		}
1427
-
1428
-		$this->seek($s);
1429
-		return false;
1430
-	}
1431
-
1432
-	/* raw parsing functions */
1433
-
1434
-	protected function literal($what, $eatWhitespace = null)
1435
-	{
1436
-		if ($eatWhitespace === null) {
1437
-			$eatWhitespace = $this->eatWhiteDefault;
1438
-		}
1439
-
1440
-		// shortcut on single letter
1441
-		if (!isset($what[1]) && isset($this->buffer[$this->count])) {
1442
-			if ($this->buffer[$this->count] == $what) {
1443
-				if (!$eatWhitespace) {
1444
-					$this->count++;
1445
-					return true;
1446
-				}
1447
-			// goes below...
1448
-			} else {
1449
-				return false;
1450
-			}
1451
-		}
1452
-
1453
-		if (!isset(self::$literalCache[$what])) {
1454
-			self::$literalCache[$what] = Lessc::preg_quote($what);
1455
-		}
1456
-
1457
-		$m = array();
1458
-		return $this->match(self::$literalCache[$what], $m, $eatWhitespace);
1459
-	}
1460
-
1461
-	protected function genericList(&$out, $parseItem, $delim = "", $flatten = true)
1462
-	{
1463
-		$value = null;
1464
-
1465
-		$s = $this->seek();
1466
-		$items = array();
1467
-		while ($this->$parseItem($value)) {
1468
-			$items[] = $value;
1469
-			if ($delim) {
1470
-				if (!$this->literal($delim)) {
1471
-					break;
1472
-				}
1473
-			}
1474
-		}
1475
-
1476
-		if (count($items) == 0) {
1477
-			$this->seek($s);
1478
-			return false;
1479
-		}
1480
-
1481
-		if ($flatten && count($items) == 1) {
1482
-			$out = $items[0];
1483
-		} else {
1484
-			$out = array("list", $delim, $items);
1485
-		}
1486
-
1487
-		return true;
1488
-	}
1489
-
1490
-
1491
-	// advance counter to next occurrence of $what
1492
-	// $until - don't include $what in advance
1493
-	// $allowNewline, if string, will be used as valid char set
1494
-	protected function to($what, &$out, $until = false, $allowNewline = false)
1495
-	{
1496
-		if (is_string($allowNewline)) {
1497
-			$validChars = $allowNewline;
1498
-		} else {
1499
-			$validChars = $allowNewline ? "." : "[^\n]";
1500
-		}
1501
-		$m = array();
1502
-		if (!$this->match('('.$validChars.'*?)'.Lessc::preg_quote($what), $m, !$until)) {
1503
-			return false;
1504
-		}
1505
-		if ($until) {
1506
-			$this->count -= strlen($what); // give back $what
1507
-		}
1508
-		$out = $m[1];
1509
-		return true;
1510
-	}
1511
-
1512
-	// try to match something on head of buffer
1513
-	protected function match($regex, &$out, $eatWhitespace = null)
1514
-	{
1515
-		if ($eatWhitespace === null) {
1516
-			$eatWhitespace = $this->eatWhiteDefault;
1517
-		}
1518
-
1519
-		$r = '/'.$regex.($eatWhitespace && !$this->writeComments ? '\s*' : '').'/Ais';
1520
-		if (preg_match($r, $this->buffer, $out, 0, $this->count)) {
1521
-			$this->count += strlen($out[0]);
1522
-			if ($eatWhitespace && $this->writeComments) {
1523
-				$this->whitespace();
1524
-			}
1525
-			return true;
1526
-		}
1527
-		return false;
1528
-	}
1529
-
1530
-	// match some whitespace
1531
-	protected function whitespace()
1532
-	{
1533
-		if ($this->writeComments) {
1534
-			$gotWhite = false;
1535
-			$m = array();
1536
-			while (preg_match(self::$whitePattern, $this->buffer, $m, 0, $this->count)) {
1537
-				if (isset($m[1]) && empty($this->seenComments[$this->count])) {
1538
-					$this->append(array("comment", $m[1]));
1539
-					$this->seenComments[$this->count] = true;
1540
-				}
1541
-				$this->count += strlen($m[0]);
1542
-				$gotWhite = true;
1543
-			}
1544
-			return $gotWhite;
1545
-		} else {
1546
-			$this->match("", $m);
1547
-			return strlen($m[0]) > 0;
1548
-		}
1549
-	}
1550
-
1551
-	// match something without consuming it
1552
-	protected function peek($regex, &$out = null, $from = null)
1553
-	{
1554
-		if (is_null($from)) {
1555
-			$from = $this->count;
1556
-		}
1557
-		$r = '/'.$regex.'/Ais';
1558
-		$result = preg_match($r, $this->buffer, $out, 0, $from);
1559
-
1560
-		return $result;
1561
-	}
1562
-
1563
-	// seek to a spot in the buffer or return where we are on no argument
1564
-	protected function seek($where = null)
1565
-	{
1566
-		if ($where === null) {
1567
-			return $this->count;
1568
-		} else {
1569
-			$this->count = $where;
1570
-		}
1571
-		return true;
1572
-	}
1573
-
1574
-	/* misc functions */
1575
-
1576
-	public function throwError($msg = "parse error", $count = null)
1577
-	{
1578
-		$count = is_null($count) ? $this->count : $count;
1579
-
1580
-		$line = $this->line +
1581
-			substr_count(substr($this->buffer, 0, $count), "\n");
1582
-
1583
-		if (!empty($this->sourceName)) {
1584
-			$loc = "$this->sourceName on line $line";
1585
-		} else {
1586
-			$loc = "line: $line";
1587
-		}
1588
-
1589
-		// TODO this depends on $this->count
1590
-		$m = array();
1591
-		if ($this->peek("(.*?)(\n|$)", $m, $count)) {
1592
-			throw new exception("$msg: failed at `$m[1]` $loc");
1593
-		} else {
1594
-			throw new exception("$msg: $loc");
1595
-		}
1596
-	}
1597
-
1598
-	protected function pushBlock($selectors = null, $type = null)
1599
-	{
1600
-		$b = new stdclass();
1601
-		$b->parent = $this->env;
1602
-
1603
-		$b->type = $type;
1604
-		$b->id = self::$nextBlockId++;
1605
-
1606
-		$b->isVararg = false; // TODO: kill me from here
1607
-		$b->tags = $selectors;
1608
-
1609
-		$b->props = array();
1610
-		$b->children = array();
1611
-
1612
-		$this->env = $b;
1613
-		return $b;
1614
-	}
1615
-
1616
-	// push a block that doesn't multiply tags
1617
-	protected function pushSpecialBlock($type)
1618
-	{
1619
-		return $this->pushBlock(null, $type);
1620
-	}
1621
-
1622
-	// append a property to the current block
1623
-	protected function append($prop, $pos = null)
1624
-	{
1625
-		if ($pos !== null) {
1626
-			$prop[-1] = $pos;
1627
-		}
1628
-		$this->env->props[] = $prop;
1629
-	}
1630
-
1631
-	// pop something off the stack
1632
-	protected function pop()
1633
-	{
1634
-		$old = $this->env;
1635
-		$this->env = $this->env->parent;
1636
-		return $old;
1637
-	}
1638
-
1639
-	// remove comments from $text
1640
-	// todo: make it work for all functions, not just url
1641
-	protected function removeComments($text)
1642
-	{
1643
-		$look = array(
1644
-			'url(', '//', '/*', '"', "'"
1645
-		);
1646
-
1647
-		$out = '';
1648
-		$min = null;
1649
-		while (true) {
1650
-			// find the next item
1651
-			foreach ($look as $token) {
1652
-				$pos = strpos($text, $token);
1653
-				if ($pos !== false) {
1654
-					if (!isset($min) || $pos < $min[1]) {
1655
-						$min = array($token, $pos);
1656
-					}
1657
-				}
1658
-			}
1659
-
1660
-			if (is_null($min)) {
1661
-				break;
1662
-			}
1663
-
1664
-			$count = $min[1];
1665
-			$skip = 0;
1666
-			$newlines = 0;
1667
-			switch ($min[0]) {
1668
-				case 'url(':
1669
-					$m = array();
1670
-					if (preg_match('/url\(.*?\)/', $text, $m, 0, $count)) {
1671
-						$count += strlen($m[0]) - strlen($min[0]);
1672
-					}
1673
-					break;
1674
-				case '"':
1675
-				case "'":
1676
-					$m = array();
1677
-					if (preg_match('/'.$min[0].'.*?(?<!\\\\)'.$min[0].'/', $text, $m, 0, $count)) {
1678
-						$count += strlen($m[0]) - 1;
1679
-					}
1680
-					break;
1681
-				case '//':
1682
-					$skip = strpos($text, "\n", $count);
1683
-					if ($skip === false) {
1684
-						$skip = strlen($text) - $count;
1685
-					} else {
1686
-						$skip -= $count;
1687
-					}
1688
-					break;
1689
-				case '/*':
1690
-					$m = array();
1691
-					if (preg_match('/\/\*.*?\*\//s', $text, $m, 0, $count)) {
1692
-						$skip = strlen($m[0]);
1693
-						$newlines = substr_count($m[0], "\n");
1694
-					}
1695
-					break;
1696
-			}
1697
-
1698
-			if ($skip == 0) {
1699
-				$count += strlen($min[0]);
1700
-			}
1701
-
1702
-			$out .= substr($text, 0, $count).str_repeat("\n", $newlines);
1703
-			$text = substr($text, $count + $skip);
1704
-
1705
-			$min = null;
1706
-		}
1707
-
1708
-		return $out.$text;
1709
-	}
64
+    protected static $nextBlockId = 0; // used to uniquely identify blocks
65
+
66
+    protected static $precedence = array(
67
+        '=<' => 0,
68
+        '>=' => 0,
69
+        '=' => 0,
70
+        '<' => 0,
71
+        '>' => 0,
72
+
73
+        '+' => 1,
74
+        '-' => 1,
75
+        '*' => 2,
76
+        '/' => 2,
77
+        '%' => 2,
78
+    );
79
+
80
+    protected static $whitePattern;
81
+    protected static $commentMulti;
82
+
83
+    protected static $commentSingle = "//";
84
+    protected static $commentMultiLeft = "/*";
85
+    protected static $commentMultiRight = "*/";
86
+
87
+    // regex string to match any of the operators
88
+    protected static $operatorString;
89
+
90
+    // these properties will supress division unless it's inside parenthases
91
+    protected static $supressDivisionProps =
92
+        array('/border-radius$/i', '/^font$/i');
93
+
94
+    protected $blockDirectives = array("font-face", "keyframes", "page", "-moz-document", "viewport", "-moz-viewport", "-o-viewport", "-ms-viewport");
95
+    protected $lineDirectives = array("charset");
96
+
97
+    /**
98
+     * if we are in parens we can be more liberal with whitespace around
99
+     * operators because it must evaluate to a single value and thus is less
100
+     * ambiguous.
101
+     *
102
+     * Consider:
103
+     *     property1: 10 -5; // is two numbers, 10 and -5
104
+     *     property2: (10 -5); // should evaluate to 5
105
+     */
106
+    protected $inParens = false;
107
+
108
+    // caches preg escaped literals
109
+    protected static $literalCache = array();
110
+
111
+    public $env;
112
+    public $buffer;
113
+    public $count;
114
+    public $line;
115
+    public $eatWhiteDefault;
116
+    public $lessc;
117
+    public $sourceName;
118
+    public $writeComments;
119
+    public $seenComments;
120
+    public $currentProperty;
121
+    public $inExp;
122
+
123
+
124
+    public function __construct($lessc, $sourceName = null)
125
+    {
126
+        $this->eatWhiteDefault = true;
127
+        // reference to less needed for vPrefix, mPrefix, and parentSelector
128
+        $this->lessc = $lessc;
129
+
130
+        $this->sourceName = $sourceName; // name used for error messages
131
+
132
+        $this->writeComments = false;
133
+
134
+        if (!self::$operatorString) {
135
+            self::$operatorString =
136
+                '('.implode('|', array_map(
137
+                    array('lessc', 'preg_quote'),
138
+                    array_keys(self::$precedence)
139
+                )).')';
140
+
141
+            $commentSingle = Lessc::preg_quote(self::$commentSingle);
142
+            $commentMultiLeft = Lessc::preg_quote(self::$commentMultiLeft);
143
+            $commentMultiRight = Lessc::preg_quote(self::$commentMultiRight);
144
+
145
+            self::$commentMulti = $commentMultiLeft.'.*?'.$commentMultiRight;
146
+            self::$whitePattern = '/'.$commentSingle.'[^\n]*\s*|('.self::$commentMulti.')\s*|\s+/Ais';
147
+        }
148
+    }
149
+
150
+    /**
151
+     * Parse a string
152
+     *
153
+     * @param       string  $buffer         String to parse
154
+     * @throws exception
155
+     * @return NULL|stdclass
156
+     */
157
+    public function parse($buffer)
158
+    {
159
+        $this->count = 0;
160
+        $this->line = 1;
161
+
162
+        $this->env = null; // block stack
163
+        $this->buffer = $this->writeComments ? $buffer : $this->removeComments($buffer);
164
+        $this->pushSpecialBlock("root");
165
+        $this->eatWhiteDefault = true;
166
+        $this->seenComments = array();
167
+
168
+        // trim whitespace on head
169
+        // if (preg_match('/^\s+/', $this->buffer, $m)) {
170
+        //  $this->line += substr_count($m[0], "\n");
171
+        //  $this->buffer = ltrim($this->buffer);
172
+        // }
173
+        $this->whitespace();
174
+
175
+        // parse the entire file
176
+        while (false !== $this->parseChunk());
177
+
178
+        if ($this->count != strlen($this->buffer)) {
179
+            $this->throwError('parse error count '.$this->count.' != len buffer '.strlen($this->buffer));
180
+
181
+        }
182
+
183
+        // TODO report where the block was opened
184
+        if (!property_exists($this->env, 'parent') || !is_null($this->env->parent)) {
185
+            throw new exception('parse error: unclosed block');
186
+        }
187
+
188
+        return $this->env;
189
+    }
190
+
191
+    /**
192
+     * Parse a single chunk off the head of the buffer and append it to the
193
+     * current parse environment.
194
+     * Returns false when the buffer is empty, or when there is an error.
195
+     *
196
+     * This function is called repeatedly until the entire document is
197
+     * parsed.
198
+     *
199
+     * This parser is most similar to a recursive descent parser. Single
200
+     * functions represent discrete grammatical rules for the language, and
201
+     * they are able to capture the text that represents those rules.
202
+     *
203
+     * Consider the function Lessc::keyword(). (all parse functions are
204
+     * structured the same)
205
+     *
206
+     * The function takes a single reference argument. When calling the
207
+     * function it will attempt to match a keyword on the head of the buffer.
208
+     * If it is successful, it will place the keyword in the referenced
209
+     * argument, advance the position in the buffer, and return true. If it
210
+     * fails then it won't advance the buffer and it will return false.
211
+     *
212
+     * All of these parse functions are powered by Lessc::match(), which behaves
213
+     * the same way, but takes a literal regular expression. Sometimes it is
214
+     * more convenient to use match instead of creating a new function.
215
+     *
216
+     * Because of the format of the functions, to parse an entire string of
217
+     * grammatical rules, you can chain them together using &&.
218
+     *
219
+     * But, if some of the rules in the chain succeed before one fails, then
220
+     * the buffer position will be left at an invalid state. In order to
221
+     * avoid this, Lessc::seek() is used to remember and set buffer positions.
222
+     *
223
+     * Before parsing a chain, use $s = $this->seek() to remember the current
224
+     * position into $s. Then if a chain fails, use $this->seek($s) to
225
+     * go back where we started.
226
+     */
227
+    protected function parseChunk()
228
+    {
229
+        if (empty($this->buffer)) {
230
+            return false;
231
+        }
232
+        $s = $this->seek();
233
+
234
+        if ($this->whitespace()) {
235
+            return true;
236
+        }
237
+
238
+        $key = null;
239
+        $value = null;
240
+        $mediaQueries = null;
241
+        $dirName = null;
242
+        $dirValue = null;
243
+        $importValue = null;
244
+        $guards = null;
245
+        $tag = null;
246
+        $args = null;
247
+        $isVararg = null;
248
+        $argv = null;
249
+        $suffix = null;
250
+        $var = null;
251
+        $tags = null;
252
+
253
+        // setting a property
254
+        if ($this->keyword($key) && $this->assign() &&
255
+            $this->propertyValue($value, $key) && $this->end()
256
+        ) {
257
+            $this->append(array('assign', $key, $value), $s);
258
+            return true;
259
+        } else {
260
+            $this->seek($s);
261
+        }
262
+
263
+
264
+        // look for special css blocks
265
+        if ($this->literal('@', false)) {
266
+            $this->count--;
267
+
268
+            // media
269
+            if ($this->literal('@media')) {
270
+                if ($this->mediaQueryList($mediaQueries)
271
+                    && $this->literal('{')
272
+                ) {
273
+                    $media = $this->pushSpecialBlock("media");
274
+                    $media->queries = is_null($mediaQueries) ? array() : $mediaQueries;
275
+                    return true;
276
+                } else {
277
+                    $this->seek($s);
278
+                    return false;
279
+                }
280
+            }
281
+
282
+            if ($this->literal("@", false) && $this->keyword($dirName)) {
283
+                if ($this->isDirective($dirName, $this->blockDirectives)) {
284
+                    if ($this->openString("{", $dirValue, null, array(";")) &&
285
+                        $this->literal("{")
286
+                    ) {
287
+                        $dir = $this->pushSpecialBlock("directive");
288
+                        $dir->name = $dirName;
289
+                        if (isset($dirValue)) {
290
+                            $dir->value = $dirValue;
291
+                        }
292
+                        return true;
293
+                    }
294
+                } elseif ($this->isDirective($dirName, $this->lineDirectives)) {
295
+                    if ($this->propertyValue($dirValue) && $this->end()) {
296
+                        $this->append(array("directive", $dirName, $dirValue));
297
+                        return true;
298
+                    }
299
+                }
300
+            }
301
+
302
+            $this->seek($s);
303
+        }
304
+
305
+        // setting a variable
306
+        if ($this->variable($var) && $this->assign() &&
307
+            $this->propertyValue($value) && $this->end()
308
+        ) {
309
+            $this->append(array('assign', $var, $value), $s);
310
+            return true;
311
+        } else {
312
+            $this->seek($s);
313
+        }
314
+
315
+        if ($this->import($importValue)) {
316
+            $this->append($importValue, $s);
317
+            return true;
318
+        }
319
+
320
+        // opening parametric mixin
321
+        if ($this->tag($tag, true) && $this->argumentDef($args, $isVararg) &&
322
+            $this->guards($guards) &&
323
+            $this->literal('{')
324
+        ) {
325
+            $block = $this->pushBlock($this->fixTags(array($tag)));
326
+            $block->args = $args;
327
+            $block->isVararg = $isVararg;
328
+            if (!empty($guards)) {
329
+                $block->guards = $guards;
330
+            }
331
+            return true;
332
+        } else {
333
+            $this->seek($s);
334
+        }
335
+
336
+        // opening a simple block
337
+        if ($this->tags($tags) && $this->literal('{', false)) {
338
+            $tags = $this->fixTags($tags);
339
+            $this->pushBlock($tags);
340
+            return true;
341
+        } else {
342
+            $this->seek($s);
343
+        }
344
+
345
+        // closing a block
346
+        if ($this->literal('}', false)) {
347
+            try {
348
+                $block = $this->pop();
349
+            } catch (exception $e) {
350
+                $this->seek($s);
351
+                $this->throwError($e->getMessage());
352
+            }
353
+
354
+            $hidden = false;
355
+            if (is_null($block->type)) {
356
+                $hidden = true;
357
+                if (!isset($block->args)) {
358
+                    foreach ($block->tags as $tag) {
359
+                        if (!is_string($tag) || $tag[0] != $this->lessc->mPrefix) {
360
+                            $hidden = false;
361
+                            break;
362
+                        }
363
+                    }
364
+                }
365
+
366
+                foreach ($block->tags as $tag) {
367
+                    if (is_string($tag)) {
368
+                        $this->env->children[$tag][] = $block;
369
+                    }
370
+                }
371
+            }
372
+
373
+            if (!$hidden) {
374
+                $this->append(array('block', $block), $s);
375
+            }
376
+
377
+            // this is done here so comments aren't bundled into he block that
378
+            // was just closed
379
+            $this->whitespace();
380
+            return true;
381
+        }
382
+
383
+        // mixin
384
+        if ($this->mixinTags($tags) &&
385
+            $this->argumentDef($argv, $isVararg) &&
386
+            $this->keyword($suffix)  && $this->end()
387
+        ) {
388
+            $tags = $this->fixTags($tags);
389
+            $this->append(array('mixin', $tags, $argv, $suffix), $s);
390
+            return true;
391
+        } else {
392
+            $this->seek($s);
393
+        }
394
+
395
+        // spare ;
396
+        if ($this->literal(';')) {
397
+            return true;
398
+        }
399
+
400
+        return false; // got nothing, throw error
401
+    }
402
+
403
+    protected function isDirective($dirname, $directives)
404
+    {
405
+        // TODO: cache pattern in parser
406
+        $pattern = implode(
407
+            "|",
408
+            array_map(array("lessc", "preg_quote"), $directives)
409
+        );
410
+        $pattern = '/^(-[a-z-]+-)?('.$pattern.')$/i';
411
+
412
+        return preg_match($pattern, $dirname);
413
+    }
414
+
415
+    protected function fixTags($tags)
416
+    {
417
+        // move @ tags out of variable namespace
418
+        foreach ($tags as &$tag) {
419
+            if ($tag[0] == $this->lessc->vPrefix) {
420
+                $tag[0] = $this->lessc->mPrefix;
421
+            }
422
+        }
423
+        return $tags;
424
+    }
425
+
426
+    // a list of expressions
427
+    protected function expressionList(&$exps)
428
+    {
429
+        $exp = null;
430
+
431
+        $values = array();
432
+
433
+        while ($this->expression($exp)) {
434
+            $values[] = $exp;
435
+        }
436
+
437
+        if (count($values) == 0) {
438
+            return false;
439
+        }
440
+
441
+        $exps = Lessc::compressList($values, ' ');
442
+        return true;
443
+    }
444
+
445
+    /**
446
+     * Attempt to consume an expression.
447
+     * @link http://en.wikipedia.org/wiki/Operator-precedence_parser#Pseudo-code
448
+     */
449
+    protected function expression(&$out)
450
+    {
451
+        $lhs = null;
452
+        $rhs = null;
453
+
454
+        if ($this->value($lhs)) {
455
+            $out = $this->expHelper($lhs, 0);
456
+
457
+            // look for / shorthand
458
+            if (!empty($this->env->supressedDivision)) {
459
+                unset($this->env->supressedDivision);
460
+                $s = $this->seek();
461
+                if ($this->literal("/") && $this->value($rhs)) {
462
+                    $out = array("list", "",
463
+                        array($out, array("keyword", "/"), $rhs));
464
+                } else {
465
+                    $this->seek($s);
466
+                }
467
+            }
468
+
469
+            return true;
470
+        }
471
+        return false;
472
+    }
473
+
474
+    /**
475
+     * recursively parse infix equation with $lhs at precedence $minP
476
+     */
477
+    protected function expHelper($lhs, $minP)
478
+    {
479
+        $next = null;
480
+        $rhs = null;
481
+
482
+        $this->inExp = true;
483
+        $ss = $this->seek();
484
+
485
+        while (true) {
486
+            $whiteBefore = isset($this->buffer[$this->count - 1]) &&
487
+                ctype_space($this->buffer[$this->count - 1]);
488
+
489
+            // If there is whitespace before the operator, then we require
490
+            // whitespace after the operator for it to be an expression
491
+            $needWhite = $whiteBefore && !$this->inParens;
492
+
493
+            $m = array();
494
+            if ($this->match(self::$operatorString.($needWhite ? '\s' : ''), $m) && self::$precedence[$m[1]] >= $minP) {
495
+                if (!$this->inParens && isset($this->env->currentProperty) && $m[1] == "/" && empty($this->env->supressedDivision)) {
496
+                    foreach (self::$supressDivisionProps as $pattern) {
497
+                        if (preg_match($pattern, $this->env->currentProperty)) {
498
+                            $this->env->supressedDivision = true;
499
+                            break 2;
500
+                        }
501
+                    }
502
+                }
503
+
504
+
505
+                $whiteAfter = isset($this->buffer[$this->count - 1]) &&
506
+                    ctype_space($this->buffer[$this->count - 1]);
507
+
508
+                if (!$this->value($rhs)) {
509
+                    break;
510
+                }
511
+
512
+                // peek for next operator to see what to do with rhs
513
+                if ($this->peek(self::$operatorString, $next) && self::$precedence[$next[1]] > self::$precedence[$m[1]]) {
514
+                    $rhs = $this->expHelper($rhs, self::$precedence[$next[1]]);
515
+                }
516
+
517
+                $lhs = array('expression', $m[1], $lhs, $rhs, $whiteBefore, $whiteAfter);
518
+                $ss = $this->seek();
519
+
520
+                continue;
521
+            }
522
+
523
+            break;
524
+        }
525
+
526
+        $this->seek($ss);
527
+
528
+        return $lhs;
529
+    }
530
+
531
+    // consume a list of values for a property
532
+    public function propertyValue(&$value, $keyName = null)
533
+    {
534
+        $v = null;
535
+        $values = array();
536
+
537
+        if ($keyName !== null) {
538
+            $this->env->currentProperty = $keyName;
539
+        }
540
+
541
+        $s = null;
542
+        while ($this->expressionList($v)) {
543
+            $values[] = $v;
544
+            $s = $this->seek();
545
+            if (!$this->literal(',')) {
546
+                break;
547
+            }
548
+        }
549
+
550
+        if ($s) {
551
+            $this->seek($s);
552
+        }
553
+
554
+        if ($keyName !== null) {
555
+            unset($this->env->currentProperty);
556
+        }
557
+
558
+        if (count($values) == 0) {
559
+            return false;
560
+        }
561
+
562
+        $value = Lessc::compressList($values, ', ');
563
+        return true;
564
+    }
565
+
566
+    protected function parenValue(&$out)
567
+    {
568
+        $exp = null;
569
+
570
+        $s = $this->seek();
571
+
572
+        // speed shortcut
573
+        if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] != "(") {
574
+            return false;
575
+        }
576
+
577
+        $inParens = $this->inParens;
578
+        if ($this->literal("(") &&
579
+            ($this->inParens = true) && $this->expression($exp) &&
580
+            $this->literal(")")
581
+        ) {
582
+            $out = $exp;
583
+            $this->inParens = $inParens;
584
+            return true;
585
+        } else {
586
+            $this->inParens = $inParens;
587
+            $this->seek($s);
588
+        }
589
+
590
+        return false;
591
+    }
592
+
593
+    // a single value
594
+    protected function value(&$value)
595
+    {
596
+        $inner = null;
597
+        $word = null;
598
+        $str = null;
599
+        $var = null;
600
+
601
+        $s = $this->seek();
602
+
603
+        // speed shortcut
604
+        if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] == "-") {
605
+            // negation
606
+            if ($this->literal("-", false) &&
607
+                (($this->variable($inner) && $inner = array("variable", $inner)) ||
608
+                $this->unit($inner) ||
609
+                $this->parenValue($inner))
610
+            ) {
611
+                $value = array("unary", "-", $inner);
612
+                return true;
613
+            } else {
614
+                $this->seek($s);
615
+            }
616
+        }
617
+
618
+        if ($this->parenValue($value)) {
619
+            return true;
620
+        }
621
+        if ($this->unit($value)) {
622
+            return true;
623
+        }
624
+        if ($this->color($value)) {
625
+            return true;
626
+        }
627
+        if ($this->func($value)) {
628
+            return true;
629
+        }
630
+        if ($this->string($value)) {
631
+            return true;
632
+        }
633
+
634
+        if ($this->keyword($word)) {
635
+            $value = array('keyword', $word);
636
+            return true;
637
+        }
638
+
639
+        // try a variable
640
+        if ($this->variable($var)) {
641
+            $value = array('variable', $var);
642
+            return true;
643
+        }
644
+
645
+        // unquote string (should this work on any type?
646
+        if ($this->literal("~") && $this->string($str)) {
647
+            $value = array("escape", $str);
648
+            return true;
649
+        } else {
650
+            $this->seek($s);
651
+        }
652
+
653
+        // css hack: \0
654
+        $m = array();
655
+        if ($this->literal('\\') && $this->match('([0-9]+)', $m)) {
656
+            $value = array('keyword', '\\'.$m[1]);
657
+            return true;
658
+        } else {
659
+            $this->seek($s);
660
+        }
661
+
662
+        return false;
663
+    }
664
+
665
+    // an import statement
666
+    protected function import(&$out, $value = '')
667
+    {
668
+        if (!$this->literal('@import')) {
669
+            return false;
670
+        }
671
+
672
+        // @import "something.css" media;
673
+        // @import url("something.css") media;
674
+        // @import url(something.css) media;
675
+
676
+        if ($this->propertyValue($value)) {
677
+            $out = array("import", $value);
678
+            return true;
679
+        }
680
+
681
+        return false;
682
+    }
683
+
684
+    protected function mediaQueryList(&$out)
685
+    {
686
+        $list = null;
687
+
688
+        if ($this->genericList($list, "mediaQuery", ",", false)) {
689
+            $out = $list[2];
690
+            return true;
691
+        }
692
+        return false;
693
+    }
694
+
695
+    protected function mediaQuery(&$out)
696
+    {
697
+        $mediaType = null;
698
+
699
+        $s = $this->seek();
700
+
701
+        $expressions = null;
702
+        $parts = array();
703
+
704
+        if ((($this->literal("only") && ($only = true)) || ($this->literal("not") && ($not = true))) && $this->keyword($mediaType)) {
705
+            $prop = array("mediaType");
706
+            if (isset($only)) {
707
+                $prop[] = "only";
708
+            }
709
+            if (isset($not)) {
710
+                $prop[] = "not";
711
+            }
712
+            $prop[] = $mediaType;
713
+            $parts[] = $prop;
714
+        } else {
715
+            $this->seek($s);
716
+        }
717
+
718
+
719
+        if (!empty($mediaType) && !$this->literal("and")) {
720
+            // ~
721
+        } else {
722
+            $this->genericList($expressions, "mediaExpression", "and", false);
723
+            if (is_array($expressions)) {
724
+                $parts = array_merge($parts, $expressions[2]);
725
+            }
726
+        }
727
+
728
+        if (count($parts) == 0) {
729
+            $this->seek($s);
730
+            return false;
731
+        }
732
+
733
+        $out = $parts;
734
+        return true;
735
+    }
736
+
737
+    protected function mediaExpression(&$out)
738
+    {
739
+        $feature = null;
740
+        $variable = null;
741
+
742
+        $s = $this->seek();
743
+        $value = null;
744
+        if ($this->literal("(") &&
745
+            $this->keyword($feature) &&
746
+            ($this->literal(":") && $this->expression($value)) &&
747
+            $this->literal(")")
748
+        ) {
749
+            $out = array("mediaExp", $feature);
750
+            if ($value) {
751
+                $out[] = $value;
752
+            }
753
+            return true;
754
+        } elseif ($this->variable($variable)) {
755
+            $out = array('variable', $variable);
756
+            return true;
757
+        }
758
+
759
+        $this->seek($s);
760
+        return false;
761
+    }
762
+
763
+    // an unbounded string stopped by $end
764
+    protected function openString($end, &$out, $nestingOpen = null, $rejectStrs = null)
765
+    {
766
+        $str = null;
767
+        $inter = null;
768
+
769
+        $oldWhite = $this->eatWhiteDefault;
770
+        $this->eatWhiteDefault = false;
771
+
772
+        $stop = array("'", '"', "@{", $end);
773
+        $stop = array_map(array("lessc", "preg_quote"), $stop);
774
+        // $stop[] = self::$commentMulti;
775
+
776
+        if (!is_null($rejectStrs)) {
777
+            $stop = array_merge($stop, $rejectStrs);
778
+        }
779
+
780
+        $patt = '(.*?)('.implode("|", $stop).')';
781
+
782
+        $nestingLevel = 0;
783
+
784
+        $content = array();
785
+        $m = array();
786
+        while ($this->match($patt, $m, false)) {
787
+            if (!empty($m[1])) {
788
+                $content[] = $m[1];
789
+                if ($nestingOpen) {
790
+                    $nestingLevel += substr_count($m[1], $nestingOpen);
791
+                }
792
+            }
793
+
794
+            $tok = $m[2];
795
+
796
+            $this->count -= strlen($tok);
797
+            if ($tok == $end) {
798
+                if ($nestingLevel == 0) {
799
+                    break;
800
+                } else {
801
+                    $nestingLevel--;
802
+                }
803
+            }
804
+
805
+            if (($tok == "'" || $tok == '"') && $this->string($str)) {
806
+                $content[] = $str;
807
+                continue;
808
+            }
809
+
810
+            if ($tok == "@{" && $this->interpolation($inter)) {
811
+                $content[] = $inter;
812
+                continue;
813
+            }
814
+
815
+            if (!empty($rejectStrs) && in_array($tok, $rejectStrs)) {
816
+                break;
817
+            }
818
+
819
+            $content[] = $tok;
820
+            $this->count += strlen($tok);
821
+        }
822
+
823
+        $this->eatWhiteDefault = $oldWhite;
824
+
825
+        if (count($content) == 0) {
826
+            return false;
827
+        }
828
+
829
+        // trim the end
830
+        if (is_string(end($content))) {
831
+            $content[count($content) - 1] = rtrim(end($content));
832
+        }
833
+
834
+        $out = array("string", "", $content);
835
+        return true;
836
+    }
837
+
838
+    protected function string(&$out)
839
+    {
840
+        $inter = null;
841
+
842
+        $s = $this->seek();
843
+        if ($this->literal('"', false)) {
844
+            $delim = '"';
845
+        } elseif ($this->literal("'", false)) {
846
+            $delim = "'";
847
+        } else {
848
+            return false;
849
+        }
850
+
851
+        $content = array();
852
+
853
+        // look for either ending delim , escape, or string interpolation
854
+        $patt = '([^\n]*?)(@\{|\\\\|'.
855
+            Lessc::preg_quote($delim).')';
856
+
857
+        $oldWhite = $this->eatWhiteDefault;
858
+        $this->eatWhiteDefault = false;
859
+
860
+        $m = array();
861
+        while ($this->match($patt, $m, false)) {
862
+            $content[] = $m[1];
863
+            if ($m[2] == "@{") {
864
+                $this->count -= strlen($m[2]);
865
+                if ($this->interpolation($inter)) {
866
+                    $content[] = $inter;
867
+                } else {
868
+                    $this->count += strlen($m[2]);
869
+                    $content[] = "@{"; // ignore it
870
+                }
871
+            } elseif ($m[2] == '\\') {
872
+                $content[] = $m[2];
873
+                if ($this->literal($delim, false)) {
874
+                    $content[] = $delim;
875
+                }
876
+            } else {
877
+                $this->count -= strlen($delim);
878
+                break; // delim
879
+            }
880
+        }
881
+
882
+        $this->eatWhiteDefault = $oldWhite;
883
+
884
+        if ($this->literal($delim)) {
885
+            $out = array("string", $delim, $content);
886
+            return true;
887
+        }
888
+
889
+        $this->seek($s);
890
+        return false;
891
+    }
892
+
893
+    protected function interpolation(&$out)
894
+    {
895
+        $interp = array();
896
+
897
+        $oldWhite = $this->eatWhiteDefault;
898
+        $this->eatWhiteDefault = true;
899
+
900
+        $s = $this->seek();
901
+        if ($this->literal("@{") &&
902
+            $this->openString("}", $interp, null, array("'", '"', ";")) &&
903
+            $this->literal("}", false)
904
+        ) {
905
+            $out = array("interpolate", $interp);
906
+            $this->eatWhiteDefault = $oldWhite;
907
+            if ($this->eatWhiteDefault) {
908
+                $this->whitespace();
909
+            }
910
+            return true;
911
+        }
912
+
913
+        $this->eatWhiteDefault = $oldWhite;
914
+        $this->seek($s);
915
+        return false;
916
+    }
917
+
918
+    protected function unit(&$unit)
919
+    {
920
+        $m = array();
921
+
922
+        // speed shortcut
923
+        if (isset($this->buffer[$this->count])) {
924
+            $char = $this->buffer[$this->count];
925
+            if (!ctype_digit($char) && $char != ".") {
926
+                return false;
927
+            }
928
+        }
929
+
930
+        if ($this->match('([0-9]+(?:\.[0-9]*)?|\.[0-9]+)([%a-zA-Z]+)?', $m)) {
931
+            $unit = array("number", $m[1], empty($m[2]) ? "" : $m[2]);
932
+            return true;
933
+        }
934
+        return false;
935
+    }
936
+
937
+    // a # color
938
+    protected function color(&$out)
939
+    {
940
+        $m = array();
941
+
942
+        if ($this->match('(#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3}))', $m)) {
943
+            if (strlen($m[1]) > 7) {
944
+                $out = array("string", "", array($m[1]));
945
+            } else {
946
+                $out = array("raw_color", $m[1]);
947
+            }
948
+            return true;
949
+        }
950
+
951
+        return false;
952
+    }
953
+
954
+    // consume an argument definition list surrounded by ()
955
+    // each argument is a variable name with optional value
956
+    // or at the end a ... or a variable named followed by ...
957
+    // arguments are separated by , unless a ; is in the list, then ; is the
958
+    // delimiter.
959
+    protected function argumentDef(&$args, &$isVararg)
960
+    {
961
+        $value = array();
962
+        $rhs = null;
963
+
964
+        $s = $this->seek();
965
+        if (!$this->literal('(')) {
966
+            return false;
967
+        }
968
+
969
+        $values = array();
970
+        $delim = ",";
971
+        $method = "expressionList";
972
+
973
+        $isVararg = false;
974
+        while (true) {
975
+            if ($this->literal("...")) {
976
+                $isVararg = true;
977
+                break;
978
+            }
979
+
980
+            if ($this->$method($value)) {
981
+                if ($value[0] == "variable") {
982
+                    $arg = array("arg", $value[1]);
983
+                    $ss = $this->seek();
984
+
985
+                    if ($this->assign() && $this->$method($rhs)) {
986
+                        $arg[] = $rhs;
987
+                    } else {
988
+                        $this->seek($ss);
989
+                        if ($this->literal("...")) {
990
+                            $arg[0] = "rest";
991
+                            $isVararg = true;
992
+                        }
993
+                    }
994
+
995
+                    $values[] = $arg;
996
+                    if ($isVararg) {
997
+                        break;
998
+                    }
999
+                    continue;
1000
+                } else {
1001
+                    $values[] = array("lit", $value);
1002
+                }
1003
+            }
1004
+
1005
+
1006
+            if (!$this->literal($delim)) {
1007
+                if ($delim == "," && $this->literal(";")) {
1008
+                    // found new delim, convert existing args
1009
+                    $delim = ";";
1010
+                    $method = "propertyValue";
1011
+
1012
+                    // transform arg list
1013
+                    if (isset($values[1])) { // 2 items
1014
+                        $newList = array();
1015
+                        foreach ($values as $i => $arg) {
1016
+                            switch ($arg[0]) {
1017
+                                case "arg":
1018
+                                    if ($i) {
1019
+                                        $this->throwError("Cannot mix ; and , as delimiter types");
1020
+                                    }
1021
+                                    $newList[] = $arg[2];
1022
+                                    break;
1023
+                                case "lit":
1024
+                                    $newList[] = $arg[1];
1025
+                                    break;
1026
+                                case "rest":
1027
+                                    $this->throwError("Unexpected rest before semicolon");
1028
+                            }
1029
+                        }
1030
+
1031
+                        $newList = array("list", ", ", $newList);
1032
+
1033
+                        switch ($values[0][0]) {
1034
+                            case "arg":
1035
+                                $newArg = array("arg", $values[0][1], $newList);
1036
+                                break;
1037
+                            case "lit":
1038
+                                $newArg = array("lit", $newList);
1039
+                                break;
1040
+                        }
1041
+
1042
+                    } elseif ($values) { // 1 item
1043
+                        $newArg = $values[0];
1044
+                    }
1045
+
1046
+                    if ($newArg) {
1047
+                        $values = array($newArg);
1048
+                    }
1049
+                } else {
1050
+                    break;
1051
+                }
1052
+            }
1053
+        }
1054
+
1055
+        if (!$this->literal(')')) {
1056
+            $this->seek($s);
1057
+            return false;
1058
+        }
1059
+
1060
+        $args = $values;
1061
+
1062
+        return true;
1063
+    }
1064
+
1065
+    // consume a list of tags
1066
+    // this accepts a hanging delimiter
1067
+    protected function tags(&$tags, $simple = false, $delim = ',')
1068
+    {
1069
+        $tt = array();
1070
+
1071
+        $tags = array();
1072
+        while ($this->tag($tt, $simple)) {
1073
+            $tags[] = $tt;
1074
+            if (!$this->literal($delim)) {
1075
+                break;
1076
+            }
1077
+        }
1078
+        if (count($tags) == 0) {
1079
+            return false;
1080
+        }
1081
+
1082
+        return true;
1083
+    }
1084
+
1085
+    // list of tags of specifying mixin path
1086
+    // optionally separated by > (lazy, accepts extra >)
1087
+    protected function mixinTags(&$tags)
1088
+    {
1089
+        $tt = array();
1090
+
1091
+        $tags = array();
1092
+        while ($this->tag($tt, true)) {
1093
+            $tags[] = $tt;
1094
+            $this->literal(">");
1095
+        }
1096
+
1097
+        if (!$tags) {
1098
+            return false;
1099
+        }
1100
+
1101
+        return true;
1102
+    }
1103
+
1104
+    // a bracketed value (contained within in a tag definition)
1105
+    protected function tagBracket(&$parts, &$hasExpression)
1106
+    {
1107
+        $str = null;
1108
+        $inter = null;
1109
+        $word = null;
1110
+
1111
+        // speed shortcut
1112
+        if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] != "[") {
1113
+            return false;
1114
+        }
1115
+
1116
+        $s = $this->seek();
1117
+
1118
+        $hasInterpolation = false;
1119
+
1120
+        if ($this->literal("[", false)) {
1121
+            $attrParts = array("[");
1122
+            // keyword, string, operator
1123
+            while (true) {
1124
+                if ($this->literal("]", false)) {
1125
+                    $this->count--;
1126
+                    break; // get out early
1127
+                }
1128
+
1129
+                $m = array();
1130
+                if ($this->match('\s+', $m)) {
1131
+                    $attrParts[] = " ";
1132
+                    continue;
1133
+                }
1134
+                if ($this->string($str)) {
1135
+                    // escape parent selector, (yuck)
1136
+                    foreach ($str[2] as &$chunk) {
1137
+                        $chunk = str_replace($this->lessc->parentSelector, "$&$", $chunk);
1138
+                    }
1139
+
1140
+                    $attrParts[] = $str;
1141
+                    $hasInterpolation = true;
1142
+                    continue;
1143
+                }
1144
+
1145
+                if ($this->keyword($word)) {
1146
+                    $attrParts[] = $word;
1147
+                    continue;
1148
+                }
1149
+
1150
+                if ($this->interpolation($inter)) {
1151
+                    $attrParts[] = $inter;
1152
+                    $hasInterpolation = true;
1153
+                    continue;
1154
+                }
1155
+
1156
+                // operator, handles attr namespace too
1157
+                if ($this->match('[|-~\$\*\^=]+', $m)) {
1158
+                    $attrParts[] = $m[0];
1159
+                    continue;
1160
+                }
1161
+
1162
+                break;
1163
+            }
1164
+
1165
+            if ($this->literal("]", false)) {
1166
+                $attrParts[] = "]";
1167
+                foreach ($attrParts as $part) {
1168
+                    $parts[] = $part;
1169
+                }
1170
+                $hasExpression = $hasExpression || $hasInterpolation;
1171
+                return true;
1172
+            }
1173
+            $this->seek($s);
1174
+        }
1175
+
1176
+        $this->seek($s);
1177
+        return false;
1178
+    }
1179
+
1180
+    // a space separated list of selectors
1181
+    protected function tag(&$tag, $simple = false)
1182
+    {
1183
+        $interp = null;
1184
+        $unit = null;
1185
+
1186
+        if ($simple) {
1187
+            $chars = '^@,:;{}\][>\(\) "\'';
1188
+        } else {
1189
+            $chars = '^@,;{}["\'';
1190
+        }
1191
+        $s = $this->seek();
1192
+
1193
+        $hasExpression = false;
1194
+        $parts = array();
1195
+        while ($this->tagBracket($parts, $hasExpression));
1196
+
1197
+        $oldWhite = $this->eatWhiteDefault;
1198
+        $this->eatWhiteDefault = false;
1199
+
1200
+        while (true) {
1201
+            $m = array();
1202
+            if ($this->match('(['.$chars.'0-9]['.$chars.']*)', $m)) {
1203
+                $parts[] = $m[1];
1204
+                if ($simple) {
1205
+                    break;
1206
+                }
1207
+
1208
+                while ($this->tagBracket($parts, $hasExpression));
1209
+                continue;
1210
+            }
1211
+
1212
+            if (isset($this->buffer[$this->count]) && $this->buffer[$this->count] == "@") {
1213
+                if ($this->interpolation($interp)) {
1214
+                    $hasExpression = true;
1215
+                    $interp[2] = true; // don't unescape
1216
+                    $parts[] = $interp;
1217
+                    continue;
1218
+                }
1219
+
1220
+                if ($this->literal("@")) {
1221
+                    $parts[] = "@";
1222
+                    continue;
1223
+                }
1224
+            }
1225
+
1226
+            if ($this->unit($unit)) { // for keyframes
1227
+                $parts[] = $unit[1];
1228
+                $parts[] = $unit[2];
1229
+                continue;
1230
+            }
1231
+
1232
+            break;
1233
+        }
1234
+
1235
+        $this->eatWhiteDefault = $oldWhite;
1236
+        if (!$parts) {
1237
+            $this->seek($s);
1238
+            return false;
1239
+        }
1240
+
1241
+        if ($hasExpression) {
1242
+            $tag = array("exp", array("string", "", $parts));
1243
+        } else {
1244
+            $tag = trim(implode($parts));
1245
+        }
1246
+
1247
+        $this->whitespace();
1248
+        return true;
1249
+    }
1250
+
1251
+    // a css function
1252
+    protected function func(&$func)
1253
+    {
1254
+        $s = $this->seek();
1255
+
1256
+        $m = array();
1257
+        $value = array();
1258
+        $string = array();
1259
+        $name = null;
1260
+
1261
+        if ($this->match('(%|[\w\-_][\w\-_:\.]+|[\w_])', $m) && $this->literal('(')) {
1262
+            $fname = $m[1];
1263
+
1264
+            $sPreArgs = $this->seek();
1265
+
1266
+            $args = array();
1267
+            while (true) {
1268
+                $ss = $this->seek();
1269
+                // this ugly nonsense is for ie filter properties
1270
+                if ($this->keyword($name) && $this->literal('=') && $this->expressionList($value)) {
1271
+                    $args[] = array("string", "", array($name, "=", $value));
1272
+                } else {
1273
+                    $this->seek($ss);
1274
+                    if ($this->expressionList($value)) {
1275
+                        $args[] = $value;
1276
+                    }
1277
+                }
1278
+
1279
+                if (!$this->literal(',')) {
1280
+                    break;
1281
+                }
1282
+            }
1283
+            $args = array('list', ',', $args);
1284
+
1285
+            if ($this->literal(')')) {
1286
+                $func = array('function', $fname, $args);
1287
+                return true;
1288
+            } elseif ($fname == 'url') {
1289
+                // couldn't parse and in url? treat as string
1290
+                $this->seek($sPreArgs);
1291
+                if ($this->openString(")", $string) && $this->literal(")")) {
1292
+                    $func = array('function', $fname, $string);
1293
+                    return true;
1294
+                }
1295
+            }
1296
+        }
1297
+
1298
+        $this->seek($s);
1299
+        return false;
1300
+    }
1301
+
1302
+    // consume a less variable
1303
+    protected function variable(&$name)
1304
+    {
1305
+        $sub = null;
1306
+        $name = null;
1307
+
1308
+        $s = $this->seek();
1309
+        if ($this->literal($this->lessc->vPrefix, false) &&
1310
+            ($this->variable($sub) || $this->keyword($name))
1311
+        ) {
1312
+            if (!empty($sub)) {
1313
+                $name = array('variable', $sub);
1314
+            } else {
1315
+                $name = $this->lessc->vPrefix.$name;
1316
+            }
1317
+            return true;
1318
+        }
1319
+
1320
+        $name = null;
1321
+        $this->seek($s);
1322
+        return false;
1323
+    }
1324
+
1325
+    /**
1326
+     * Consume an assignment operator
1327
+     * Can optionally take a name that will be set to the current property name
1328
+     */
1329
+    protected function assign($name = null)
1330
+    {
1331
+        if ($name) {
1332
+            $this->currentProperty = $name;
1333
+        }
1334
+        return $this->literal(':') || $this->literal('=');
1335
+    }
1336
+
1337
+    // consume a keyword
1338
+    protected function keyword(&$word)
1339
+    {
1340
+        $m = array();
1341
+        if ($this->match('([\w_\-\*!"][\w\-_"]*)', $m)) {
1342
+            $word = $m[1];
1343
+            return true;
1344
+        }
1345
+        return false;
1346
+    }
1347
+
1348
+    // consume an end of statement delimiter
1349
+    protected function end()
1350
+    {
1351
+        if ($this->literal(';', false)) {
1352
+            return true;
1353
+        } elseif ($this->count == strlen($this->buffer) || $this->buffer[$this->count] == '}') {
1354
+            // if there is end of file or a closing block next then we don't need a ;
1355
+            return true;
1356
+        }
1357
+        return false;
1358
+    }
1359
+
1360
+    protected function guards(&$guards)
1361
+    {
1362
+        $g = null;
1363
+
1364
+        $s = $this->seek();
1365
+
1366
+        if (!$this->literal("when")) {
1367
+            $this->seek($s);
1368
+            return false;
1369
+        }
1370
+
1371
+        $guards = array();
1372
+
1373
+        while ($this->guardGroup($g)) {
1374
+            $guards[] = $g;
1375
+            if (!$this->literal(",")) {
1376
+                break;
1377
+            }
1378
+        }
1379
+
1380
+        if (count($guards) == 0) {
1381
+            $guards = null;
1382
+            $this->seek($s);
1383
+            return false;
1384
+        }
1385
+
1386
+        return true;
1387
+    }
1388
+
1389
+    // a bunch of guards that are and'd together
1390
+    // TODO rename to guardGroup
1391
+    protected function guardGroup(&$guardGroup)
1392
+    {
1393
+        $guard = null;
1394
+
1395
+        $s = $this->seek();
1396
+        $guardGroup = array();
1397
+        while ($this->guard($guard)) {
1398
+            $guardGroup[] = $guard;
1399
+            if (!$this->literal("and")) {
1400
+                break;
1401
+            }
1402
+        }
1403
+
1404
+        if (count($guardGroup) == 0) {
1405
+            $guardGroup = null;
1406
+            $this->seek($s);
1407
+            return false;
1408
+        }
1409
+
1410
+        return true;
1411
+    }
1412
+
1413
+    protected function guard(&$guard)
1414
+    {
1415
+        $exp = null;
1416
+
1417
+        $s = $this->seek();
1418
+        $negate = $this->literal("not");
1419
+
1420
+        if ($this->literal("(") && $this->expression($exp) && $this->literal(")")) {
1421
+            $guard = $exp;
1422
+            if ($negate) {
1423
+                $guard = array("negate", $guard);
1424
+            }
1425
+            return true;
1426
+        }
1427
+
1428
+        $this->seek($s);
1429
+        return false;
1430
+    }
1431
+
1432
+    /* raw parsing functions */
1433
+
1434
+    protected function literal($what, $eatWhitespace = null)
1435
+    {
1436
+        if ($eatWhitespace === null) {
1437
+            $eatWhitespace = $this->eatWhiteDefault;
1438
+        }
1439
+
1440
+        // shortcut on single letter
1441
+        if (!isset($what[1]) && isset($this->buffer[$this->count])) {
1442
+            if ($this->buffer[$this->count] == $what) {
1443
+                if (!$eatWhitespace) {
1444
+                    $this->count++;
1445
+                    return true;
1446
+                }
1447
+            // goes below...
1448
+            } else {
1449
+                return false;
1450
+            }
1451
+        }
1452
+
1453
+        if (!isset(self::$literalCache[$what])) {
1454
+            self::$literalCache[$what] = Lessc::preg_quote($what);
1455
+        }
1456
+
1457
+        $m = array();
1458
+        return $this->match(self::$literalCache[$what], $m, $eatWhitespace);
1459
+    }
1460
+
1461
+    protected function genericList(&$out, $parseItem, $delim = "", $flatten = true)
1462
+    {
1463
+        $value = null;
1464
+
1465
+        $s = $this->seek();
1466
+        $items = array();
1467
+        while ($this->$parseItem($value)) {
1468
+            $items[] = $value;
1469
+            if ($delim) {
1470
+                if (!$this->literal($delim)) {
1471
+                    break;
1472
+                }
1473
+            }
1474
+        }
1475
+
1476
+        if (count($items) == 0) {
1477
+            $this->seek($s);
1478
+            return false;
1479
+        }
1480
+
1481
+        if ($flatten && count($items) == 1) {
1482
+            $out = $items[0];
1483
+        } else {
1484
+            $out = array("list", $delim, $items);
1485
+        }
1486
+
1487
+        return true;
1488
+    }
1489
+
1490
+
1491
+    // advance counter to next occurrence of $what
1492
+    // $until - don't include $what in advance
1493
+    // $allowNewline, if string, will be used as valid char set
1494
+    protected function to($what, &$out, $until = false, $allowNewline = false)
1495
+    {
1496
+        if (is_string($allowNewline)) {
1497
+            $validChars = $allowNewline;
1498
+        } else {
1499
+            $validChars = $allowNewline ? "." : "[^\n]";
1500
+        }
1501
+        $m = array();
1502
+        if (!$this->match('('.$validChars.'*?)'.Lessc::preg_quote($what), $m, !$until)) {
1503
+            return false;
1504
+        }
1505
+        if ($until) {
1506
+            $this->count -= strlen($what); // give back $what
1507
+        }
1508
+        $out = $m[1];
1509
+        return true;
1510
+    }
1511
+
1512
+    // try to match something on head of buffer
1513
+    protected function match($regex, &$out, $eatWhitespace = null)
1514
+    {
1515
+        if ($eatWhitespace === null) {
1516
+            $eatWhitespace = $this->eatWhiteDefault;
1517
+        }
1518
+
1519
+        $r = '/'.$regex.($eatWhitespace && !$this->writeComments ? '\s*' : '').'/Ais';
1520
+        if (preg_match($r, $this->buffer, $out, 0, $this->count)) {
1521
+            $this->count += strlen($out[0]);
1522
+            if ($eatWhitespace && $this->writeComments) {
1523
+                $this->whitespace();
1524
+            }
1525
+            return true;
1526
+        }
1527
+        return false;
1528
+    }
1529
+
1530
+    // match some whitespace
1531
+    protected function whitespace()
1532
+    {
1533
+        if ($this->writeComments) {
1534
+            $gotWhite = false;
1535
+            $m = array();
1536
+            while (preg_match(self::$whitePattern, $this->buffer, $m, 0, $this->count)) {
1537
+                if (isset($m[1]) && empty($this->seenComments[$this->count])) {
1538
+                    $this->append(array("comment", $m[1]));
1539
+                    $this->seenComments[$this->count] = true;
1540
+                }
1541
+                $this->count += strlen($m[0]);
1542
+                $gotWhite = true;
1543
+            }
1544
+            return $gotWhite;
1545
+        } else {
1546
+            $this->match("", $m);
1547
+            return strlen($m[0]) > 0;
1548
+        }
1549
+    }
1550
+
1551
+    // match something without consuming it
1552
+    protected function peek($regex, &$out = null, $from = null)
1553
+    {
1554
+        if (is_null($from)) {
1555
+            $from = $this->count;
1556
+        }
1557
+        $r = '/'.$regex.'/Ais';
1558
+        $result = preg_match($r, $this->buffer, $out, 0, $from);
1559
+
1560
+        return $result;
1561
+    }
1562
+
1563
+    // seek to a spot in the buffer or return where we are on no argument
1564
+    protected function seek($where = null)
1565
+    {
1566
+        if ($where === null) {
1567
+            return $this->count;
1568
+        } else {
1569
+            $this->count = $where;
1570
+        }
1571
+        return true;
1572
+    }
1573
+
1574
+    /* misc functions */
1575
+
1576
+    public function throwError($msg = "parse error", $count = null)
1577
+    {
1578
+        $count = is_null($count) ? $this->count : $count;
1579
+
1580
+        $line = $this->line +
1581
+            substr_count(substr($this->buffer, 0, $count), "\n");
1582
+
1583
+        if (!empty($this->sourceName)) {
1584
+            $loc = "$this->sourceName on line $line";
1585
+        } else {
1586
+            $loc = "line: $line";
1587
+        }
1588
+
1589
+        // TODO this depends on $this->count
1590
+        $m = array();
1591
+        if ($this->peek("(.*?)(\n|$)", $m, $count)) {
1592
+            throw new exception("$msg: failed at `$m[1]` $loc");
1593
+        } else {
1594
+            throw new exception("$msg: $loc");
1595
+        }
1596
+    }
1597
+
1598
+    protected function pushBlock($selectors = null, $type = null)
1599
+    {
1600
+        $b = new stdclass();
1601
+        $b->parent = $this->env;
1602
+
1603
+        $b->type = $type;
1604
+        $b->id = self::$nextBlockId++;
1605
+
1606
+        $b->isVararg = false; // TODO: kill me from here
1607
+        $b->tags = $selectors;
1608
+
1609
+        $b->props = array();
1610
+        $b->children = array();
1611
+
1612
+        $this->env = $b;
1613
+        return $b;
1614
+    }
1615
+
1616
+    // push a block that doesn't multiply tags
1617
+    protected function pushSpecialBlock($type)
1618
+    {
1619
+        return $this->pushBlock(null, $type);
1620
+    }
1621
+
1622
+    // append a property to the current block
1623
+    protected function append($prop, $pos = null)
1624
+    {
1625
+        if ($pos !== null) {
1626
+            $prop[-1] = $pos;
1627
+        }
1628
+        $this->env->props[] = $prop;
1629
+    }
1630
+
1631
+    // pop something off the stack
1632
+    protected function pop()
1633
+    {
1634
+        $old = $this->env;
1635
+        $this->env = $this->env->parent;
1636
+        return $old;
1637
+    }
1638
+
1639
+    // remove comments from $text
1640
+    // todo: make it work for all functions, not just url
1641
+    protected function removeComments($text)
1642
+    {
1643
+        $look = array(
1644
+            'url(', '//', '/*', '"', "'"
1645
+        );
1646
+
1647
+        $out = '';
1648
+        $min = null;
1649
+        while (true) {
1650
+            // find the next item
1651
+            foreach ($look as $token) {
1652
+                $pos = strpos($text, $token);
1653
+                if ($pos !== false) {
1654
+                    if (!isset($min) || $pos < $min[1]) {
1655
+                        $min = array($token, $pos);
1656
+                    }
1657
+                }
1658
+            }
1659
+
1660
+            if (is_null($min)) {
1661
+                break;
1662
+            }
1663
+
1664
+            $count = $min[1];
1665
+            $skip = 0;
1666
+            $newlines = 0;
1667
+            switch ($min[0]) {
1668
+                case 'url(':
1669
+                    $m = array();
1670
+                    if (preg_match('/url\(.*?\)/', $text, $m, 0, $count)) {
1671
+                        $count += strlen($m[0]) - strlen($min[0]);
1672
+                    }
1673
+                    break;
1674
+                case '"':
1675
+                case "'":
1676
+                    $m = array();
1677
+                    if (preg_match('/'.$min[0].'.*?(?<!\\\\)'.$min[0].'/', $text, $m, 0, $count)) {
1678
+                        $count += strlen($m[0]) - 1;
1679
+                    }
1680
+                    break;
1681
+                case '//':
1682
+                    $skip = strpos($text, "\n", $count);
1683
+                    if ($skip === false) {
1684
+                        $skip = strlen($text) - $count;
1685
+                    } else {
1686
+                        $skip -= $count;
1687
+                    }
1688
+                    break;
1689
+                case '/*':
1690
+                    $m = array();
1691
+                    if (preg_match('/\/\*.*?\*\//s', $text, $m, 0, $count)) {
1692
+                        $skip = strlen($m[0]);
1693
+                        $newlines = substr_count($m[0], "\n");
1694
+                    }
1695
+                    break;
1696
+            }
1697
+
1698
+            if ($skip == 0) {
1699
+                $count += strlen($min[0]);
1700
+            }
1701
+
1702
+            $out .= substr($text, 0, $count).str_repeat("\n", $newlines);
1703
+            $text = substr($text, $count + $skip);
1704
+
1705
+            $min = null;
1706
+        }
1707
+
1708
+        return $out.$text;
1709
+    }
1710 1710
 }
Please login to merge, or discard this patch.
Dolibarr/Code/Core/Classes/CommonStickerGenerator.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     public $code; // Code of format
72 72
 
73
-	// phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore
73
+    // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore
74 74
     // protected
75 75
     // Name of stick
76 76
     protected $_Avery_Name = '';
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      * @var array
110 110
      */
111 111
     public $_Avery_Labels;
112
-	// phpcs:enable
112
+    // phpcs:enable
113 113
 
114 114
     /**
115 115
      *  Constructor
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         $this->db = $db;
122 122
     }
123 123
 
124
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
124
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
125 125
     /**
126 126
      *  Function to build PDF on disk, then output on HTTP stream.
127 127
      *
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      *  @return int                             1=OK, 0=KO
133 133
      */
134 134
     abstract public function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '');
135
-	// phpcs:enable
135
+    // phpcs:enable
136 136
 
137 137
     /**
138 138
      * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     abstract public function addSticker(&$pdf, $outputlangs, $param);
146 146
 
147
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
147
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
148 148
     /**
149 149
      * Methode qui permet de modifier la taille des caracteres
150 150
      * Cela modiera aussi l'espace entre chaque ligne
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function Set_Char_Size(&$pdf, $pt)
157 157
     {
158
-		// phpcs:enable
158
+        // phpcs:enable
159 159
         if ($pt > 3) {
160 160
             $this->_Char_Size = $pt;
161 161
             $this->_Line_Height = $this->_Get_Height_Chars($pt);
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
         }
164 164
     }
165 165
 
166
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
167
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
166
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
167
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
168 168
     /**
169 169
      * protected Print dot line
170 170
      *
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      */
180 180
     protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15)
181 181
     {
182
-		// phpcs:enable
182
+        // phpcs:enable
183 183
         $pdf->SetLineWidth($epaisseur);
184 184
         $length = abs($x1 - $x2);
185 185
         $hauteur = abs($y1 - $y2);
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
         }
211 211
     }
212 212
 
213
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
214
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
213
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
214
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
215 215
     /**
216 216
      * protected Function realisant une croix aux 4 coins des cartes
217 217
      *
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
      */
229 229
     protected function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4)
230 230
     {
231
-		// phpcs:enable
231
+        // phpcs:enable
232 232
         $pdf->SetDrawColor(192, 192, 192);
233 233
 
234 234
         $pdf->SetLineWidth($epaisseur);
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
         return $value;
272 272
     }
273 273
 
274
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
275
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
274
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
275
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
276 276
     /**
277 277
      * protected Give the height for a char size given.
278 278
      *
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      */
282 282
     protected function _Get_Height_Chars($pt)
283 283
     {
284
-		// phpcs:enable
284
+        // phpcs:enable
285 285
         // Array for link between height of characters and space between lines
286 286
         $_Table_Hauteur_Chars = array(6 => 2, 7 => 2.5, 8 => 3, 9 => 3.5, 10 => 4, 11 => 6, 12 => 7, 13 => 8, 14 => 9, 15 => 10);
287 287
         if (in_array($pt, array_keys($_Table_Hauteur_Chars))) {
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
         }
292 292
     }
293 293
 
294
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
295
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
294
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
295
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
296 296
     /**
297 297
      * protected Set format
298 298
      *
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
      */
303 303
     protected function _Set_Format(&$pdf, $format)
304 304
     {
305
-		// phpcs:enable
305
+        // phpcs:enable
306 306
         $this->_Metric = $format['metric'];
307 307
         $this->_Avery_Name = $format['name'];
308 308
         $this->_Avery_Code = empty($format['code']) ? '' : $format['code'];
Please login to merge, or discard this patch.
Dolibarr/Code/Core/Classes/SMTPs.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
      * Message Sensitivity
142 142
      */
143 143
     private $_arySensitivity = array(false,
144
-                                  'Personal',
145
-                                  'Private',
146
-                                  'Company Confidential');
144
+                                    'Personal',
145
+                                    'Private',
146
+                                    'Company Confidential');
147 147
 
148 148
     /**
149 149
      * Message Sensitivity
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
      * Content-Transfer-Encoding
172 172
      */
173 173
     private $_smtpsTransEncodeTypes = array('7bit', // Simple 7-bit ASCII
174
-                                         '8bit', // 8-bit coding with line termination characters
175
-                                         'base64', // 3 octets encoded into 4 sextets with offset
176
-                                         'binary', // Arbitrary binary stream
177
-                                         'mac-binhex40', // Macintosh binary to hex encoding
178
-                                         'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH"
179
-                                         'uuencode'); // UUENCODE encoding
174
+                                            '8bit', // 8-bit coding with line termination characters
175
+                                            'base64', // 3 octets encoded into 4 sextets with offset
176
+                                            'binary', // Arbitrary binary stream
177
+                                            'mac-binhex40', // Macintosh binary to hex encoding
178
+                                            'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH"
179
+                                            'uuencode'); // UUENCODE encoding
180 180
 
181 181
     /**
182 182
      * Content-Transfer-Encoding
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         $_aryToList = $this->getTo();
402 402
     }
403 403
 
404
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
404
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
405 405
     /**
406 406
      * Attempt a connection to mail server
407 407
      *
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
      */
410 410
     private function _server_connect()
411 411
     {
412
-		// phpcs:enable
412
+        // phpcs:enable
413 413
         // Default return value
414 414
         $_retVal = true;
415 415
 
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
         return $_retVal;
480 480
     }
481 481
 
482
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
482
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
483 483
     /**
484 484
      * Attempt mail server authentication for a secure connection
485 485
      *
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
      */
488 488
     private function _server_authenticate()
489 489
     {
490
-		// phpcs:enable
490
+        // phpcs:enable
491 491
         global $conf;
492 492
 
493 493
         require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/geturl.lib.php';
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
         $this->_msgRecipients = $aryHost;
1265 1265
     }
1266 1266
 
1267
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1267
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1268 1268
     /**
1269 1269
      * Returns an array of the various parts of an email address
1270 1270
      * This assumes a well formed address:
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
      */
1284 1284
     private function _strip_email($_strAddr)
1285 1285
     {
1286
-		// phpcs:enable
1286
+        // phpcs:enable
1287 1287
         $_aryEmail = array();
1288 1288
         // Keep the original
1289 1289
         $_aryEmail['org'] = $_strAddr;
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
         return $_aryEmail;
1321 1321
     }
1322 1322
 
1323
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1323
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1324 1324
     /**
1325 1325
      * Returns an array of bares addresses for use with 'RCPT TO:'
1326 1326
      * This is a "build as you go" method. Each time this method is called
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
      */
1331 1331
     public function get_RCPT_list()
1332 1332
     {
1333
-		// phpcs:enable
1333
+        // phpcs:enable
1334 1334
         /**
1335 1335
          * An array of bares addresses for use with 'RCPT TO:'
1336 1336
          */
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
         return $_RCPT_list;
1350 1350
     }
1351 1351
 
1352
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1352
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1353 1353
     /**
1354 1354
      * Returns an array of addresses for a specific type; TO, CC or BCC
1355 1355
      *
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
      */
1359 1359
     public function get_email_list($_which = null)
1360 1360
     {
1361
-		// phpcs:enable
1361
+        // phpcs:enable
1362 1362
         // We need to know which address segment to pull
1363 1363
         if ($_which) {
1364 1364
             // Make sure we have addresses to process
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
         return '';
1972 1972
     }
1973 1973
 
1974
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1974
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1975 1975
     /**
1976 1976
      * This function has been modified as provided by SirSir to allow multiline responses when
1977 1977
      * using SMTP Extensions
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
      */
1985 1985
     public function server_parse($socket, $response)
1986 1986
     {
1987
-		// phpcs:enable
1987
+        // phpcs:enable
1988 1988
         /**
1989 1989
          * Returns constructed SELECT Object string or boolean upon failure
1990 1990
          * Default value is set at true
@@ -2016,7 +2016,7 @@  discard block
 block discarded – undo
2016 2016
         return $_retVal;
2017 2017
     }
2018 2018
 
2019
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2019
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2020 2020
     /**
2021 2021
      * Send str
2022 2022
      *
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
      */
2028 2028
     public function socket_send_str($_strSend, $_returnCode = null, $CRLF = "\r\n")
2029 2029
     {
2030
-		// phpcs:enable
2030
+        // phpcs:enable
2031 2031
         if ($this->_debug) {
2032 2032
             $this->log .= $_strSend; // @CHANGE LDR for log
2033 2033
         }
Please login to merge, or discard this patch.
Dolibarr/Code/Core/Classes/Interfaces.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         $this->db = $db;
60 60
     }
61 61
 
62
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
62
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
63 63
     /**
64 64
      *   Function called when a Dolibarr business event occurs
65 65
      *   This function call all qualified triggers.
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     public function run_triggers($action, $object, $user, $langs, $conf)
75 75
     {
76
-		// phpcs:enable
76
+        // phpcs:enable
77 77
 
78 78
         if (getDolGlobalInt('MAIN_TRIGGER_DEBUG')) {
79 79
             // This his too much verbose, enabled if const enabled only
Please login to merge, or discard this patch.
Dolibarr/Code/Core/Classes/DolGraph.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     }
146 146
 
147 147
 
148
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
148
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
149 149
     /**
150 150
      * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
151 151
      *
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function SetHorizTickIncrement($xi)
156 156
     {
157
-		// phpcs:enable
157
+        // phpcs:enable
158 158
         $this->horizTickIncrement = $xi;
159 159
         return true;
160 160
     }
161 161
 
162
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
162
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
163 163
     /**
164 164
      * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
165 165
      *
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function SetNumXTicks($xt)
170 170
     {
171
-		// phpcs:enable
171
+        // phpcs:enable
172 172
         $this->SetNumXTicks = $xt;
173 173
         return true;
174 174
     }
175 175
 
176
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
176
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
177 177
     /**
178 178
      * Set label interval to reduce number of labels
179 179
      *
@@ -182,12 +182,12 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function SetLabelInterval($x)
184 184
     {
185
-		// phpcs:enable
185
+        // phpcs:enable
186 186
         $this->labelInterval = $x;
187 187
         return true;
188 188
     }
189 189
 
190
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
190
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
191 191
     /**
192 192
      * Hide X grid
193 193
      *
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      */
197 197
     public function SetHideXGrid($bool)
198 198
     {
199
-		// phpcs:enable
199
+        // phpcs:enable
200 200
         $this->hideXGrid = $bool;
201 201
         return true;
202 202
     }
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         return true;
214 214
     }
215 215
 
216
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
216
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
217 217
     /**
218 218
      * Hide Y grid
219 219
      *
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
      */
223 223
     public function SetHideYGrid($bool)
224 224
     {
225
-		// phpcs:enable
225
+        // phpcs:enable
226 226
         $this->hideYGrid = $bool;
227 227
         return true;
228 228
     }
229 229
 
230
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
230
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
231 231
     /**
232 232
      * Set y label
233 233
      *
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function SetYLabel($label)
238 238
     {
239
-		// phpcs:enable
239
+        // phpcs:enable
240 240
         $this->YLabel = $label;
241 241
     }
242 242
 
243
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
243
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
244 244
     /**
245 245
      * Set width
246 246
      *
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
      */
250 250
     public function SetWidth($w)
251 251
     {
252
-		// phpcs:enable
252
+        // phpcs:enable
253 253
         $this->width = $w;
254 254
     }
255 255
 
256
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
256
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
257 257
     /**
258 258
      * Set title
259 259
      *
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public function SetTitle($title)
264 264
     {
265
-		// phpcs:enable
265
+        // phpcs:enable
266 266
         $this->title = $title;
267 267
     }
268 268
 
269
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
269
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
270 270
     /**
271 271
      * Set data
272 272
      *
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
      */
277 277
     public function SetData($data)
278 278
     {
279
-		// phpcs:enable
279
+        // phpcs:enable
280 280
         $this->data = $data;
281 281
     }
282 282
 
283
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
283
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
284 284
     /**
285 285
      * Set data color
286 286
      *
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      */
290 290
     public function SetDataColor($datacolor)
291 291
     {
292
-		// phpcs:enable
292
+        // phpcs:enable
293 293
         $this->datacolor = $datacolor;
294 294
     }
295 295
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         $this->tooltipsTitles = $tooltipsTitles;
350 350
     }
351 351
 
352
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
352
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
353 353
     /**
354 354
      * Set type
355 355
      *
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
      */
360 360
     public function SetType($type)
361 361
     {
362
-		// phpcs:enable
362
+        // phpcs:enable
363 363
         $this->type = $type;
364 364
     }
365 365
 
366
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
366
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
367 367
     /**
368 368
      * Set legend
369 369
      *
@@ -372,11 +372,11 @@  discard block
 block discarded – undo
372 372
      */
373 373
     public function SetLegend($legend)
374 374
     {
375
-		// phpcs:enable
375
+        // phpcs:enable
376 376
         $this->Legend = $legend;
377 377
     }
378 378
 
379
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
379
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
380 380
     /**
381 381
      * Set min width
382 382
      *
@@ -385,11 +385,11 @@  discard block
 block discarded – undo
385 385
      */
386 386
     public function SetLegendWidthMin($legendwidthmin)
387 387
     {
388
-		// phpcs:enable
388
+        // phpcs:enable
389 389
         $this->LegendWidthMin = $legendwidthmin;
390 390
     }
391 391
 
392
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
392
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
393 393
     /**
394 394
      * Set max value
395 395
      *
@@ -398,11 +398,11 @@  discard block
 block discarded – undo
398 398
      */
399 399
     public function SetMaxValue($max)
400 400
     {
401
-		// phpcs:enable
401
+        // phpcs:enable
402 402
         $this->MaxValue = $max;
403 403
     }
404 404
 
405
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
405
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
406 406
     /**
407 407
      * Get max value
408 408
      *
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
      */
411 411
     public function GetMaxValue()
412 412
     {
413
-		// phpcs:enable
413
+        // phpcs:enable
414 414
         return $this->MaxValue;
415 415
     }
416 416
 
417
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
417
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
418 418
     /**
419 419
      * Set min value
420 420
      *
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
      */
424 424
     public function SetMinValue($min)
425 425
     {
426
-		// phpcs:enable
426
+        // phpcs:enable
427 427
         $this->MinValue = $min;
428 428
     }
429 429
 
430
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
430
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
431 431
     /**
432 432
      * Get min value
433 433
      *
@@ -435,11 +435,11 @@  discard block
 block discarded – undo
435 435
      */
436 436
     public function GetMinValue()
437 437
     {
438
-		// phpcs:enable
438
+        // phpcs:enable
439 439
         return $this->MinValue;
440 440
     }
441 441
 
442
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
442
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
443 443
     /**
444 444
      * Set height
445 445
      *
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
      */
449 449
     public function SetHeight($h)
450 450
     {
451
-		// phpcs:enable
451
+        // phpcs:enable
452 452
         $this->height = $h;
453 453
     }
454 454
 
455
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
455
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
456 456
     /**
457 457
      * Set shading
458 458
      *
@@ -461,11 +461,11 @@  discard block
 block discarded – undo
461 461
      */
462 462
     public function SetShading($s)
463 463
     {
464
-		// phpcs:enable
464
+        // phpcs:enable
465 465
         $this->SetShading = $s;
466 466
     }
467 467
 
468
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
468
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
469 469
     /**
470 470
      * Set shading
471 471
      *
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
      */
475 475
     public function SetCssPrefix($s)
476 476
     {
477
-		// phpcs:enable
477
+        // phpcs:enable
478 478
         $this->cssprefix = $s;
479 479
     }
480 480
 
481
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
481
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
482 482
     /**
483 483
      * Reset bg color
484 484
      *
@@ -486,11 +486,11 @@  discard block
 block discarded – undo
486 486
      */
487 487
     public function ResetBgColor()
488 488
     {
489
-		// phpcs:enable
489
+        // phpcs:enable
490 490
         unset($this->bgcolor);
491 491
     }
492 492
 
493
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
493
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
494 494
     /**
495 495
      * Reset bgcolorgrid
496 496
      *
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
      */
499 499
     public function ResetBgColorGrid()
500 500
     {
501
-		// phpcs:enable
501
+        // phpcs:enable
502 502
         unset($this->bgcolorgrid);
503 503
     }
504 504
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 
559 559
 
560 560
 
561
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
561
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
562 562
     /**
563 563
      * Define background color of complete image
564 564
      *
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
      */
568 568
     public function SetBgColor($bg_color = array(255, 255, 255))
569 569
     {
570
-		// phpcs:enable
570
+        // phpcs:enable
571 571
         global $theme_bgcolor, $theme_bgcoloronglet;
572 572
 
573 573
         if (!is_array($bg_color)) {
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
         }
583 583
     }
584 584
 
585
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
585
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
586 586
     /**
587 587
      * Define background color of grid
588 588
      *
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
      */
592 592
     public function SetBgColorGrid($bg_colorgrid = array(255, 255, 255))
593 593
     {
594
-		// phpcs:enable
594
+        // phpcs:enable
595 595
         global $theme_bgcolor, $theme_bgcoloronglet;
596 596
 
597 597
         if (!is_array($bg_colorgrid)) {
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
         }
607 607
     }
608 608
 
609
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
609
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
610 610
     /**
611 611
      * Reset data color
612 612
      *
@@ -614,11 +614,11 @@  discard block
 block discarded – undo
614 614
      */
615 615
     public function ResetDataColor()
616 616
     {
617
-		// phpcs:enable
617
+        // phpcs:enable
618 618
         unset($this->datacolor);
619 619
     }
620 620
 
621
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
621
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
622 622
     /**
623 623
      * Get max value among all values of all series
624 624
      *
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
      */
627 627
     public function GetMaxValueInData()
628 628
     {
629
-		// phpcs:enable
629
+        // phpcs:enable
630 630
         if (!is_array($this->data)) {
631 631
             return 0;
632 632
         }
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
         return $max;
649 649
     }
650 650
 
651
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
651
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
652 652
     /**
653 653
      * Return min value of all values of all series
654 654
      *
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
      */
657 657
     public function GetMinValueInData()
658 658
     {
659
-		// phpcs:enable
659
+        // phpcs:enable
660 660
         if (!is_array($this->data)) {
661 661
             return 0;
662 662
         }
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
         return $min;
679 679
     }
680 680
 
681
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
681
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
682 682
     /**
683 683
      * Return max value of all data
684 684
      *
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
      */
687 687
     public function GetCeilMaxValue()
688 688
     {
689
-		// phpcs:enable
689
+        // phpcs:enable
690 690
         $max = $this->GetMaxValueInData();
691 691
         if ($max != 0) {
692 692
             $max++;
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
         return (int) $res;
707 707
     }
708 708
 
709
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
709
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
710 710
     /**
711 711
      * Return min value of all data
712 712
      *
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
      */
715 715
     public function GetFloorMinValue()
716 716
     {
717
-		// phpcs:enable
717
+        // phpcs:enable
718 718
         $min = $this->GetMinValueInData();
719 719
         if ($min == '') {
720 720
             $min = 0;
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         return call_user_func_array(array($this, $call), array($file, $fileurl));
763 763
     }
764 764
 
765
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
765
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
766 766
     /**
767 767
      * Build a graph into ->stringtoshow using the JFlot library. Input when calling this method should be:
768 768
      *  $this->data  = array(array(0=>'labelxA',1=>yA),  array('labelxB',yB));
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
      */
782 782
     private function draw_jflot($file, $fileurl) // @phpstan-ignore-line
783 783
     {
784
-		// phpcs:enable
784
+        // phpcs:enable
785 785
         global $langs;
786 786
 
787 787
         dol_syslog(get_class($this) . "::draw_jflot this->type=" . implode(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
     }
1050 1050
 
1051 1051
 
1052
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1052
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1053 1053
     /**
1054 1054
      * Build a graph using Chart library. Input when calling this method should be:
1055 1055
      *  $this->data  = array(array(0=>'labelxA',1=>yA),  array('labelxB',yB));
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
      */
1069 1069
     private function draw_chart($file, $fileurl) // @phpstan-ignore-line
1070 1070
     {
1071
-		// phpcs:enable
1071
+        // phpcs:enable
1072 1072
         global $langs;
1073 1073
 
1074 1074
         dol_syslog(get_class($this) . "::draw_chart this->type=" . implode(',', $this->type) . " this->MaxValue=" . $this->MaxValue);
Please login to merge, or discard this patch.
Dolibarr/Code/Core/Classes/FormCompany.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  */
42 42
 class FormCompany extends Form
43 43
 {
44
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
44
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
45 45
     /**
46 46
      *      Return list of labels (translated) of third parties type
47 47
      *
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function typent_array($mode = 0, $filter = '')
53 53
     {
54
-		// phpcs:enable
54
+        // phpcs:enable
55 55
         global $langs, $mysoc;
56 56
 
57 57
         $effs = array();
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         return $effs;
93 93
     }
94 94
 
95
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
95
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
96 96
     /**
97 97
      *  Return the list of entries for staff (no translation, it is number ranges)
98 98
      *
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function effectif_array($mode = 0, $filter = '')
104 104
     {
105
-		// phpcs:enable
105
+        // phpcs:enable
106 106
         $effs = array();
107 107
 
108 108
         $sql = "SELECT id, code, libelle as label";
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     }
138 138
 
139 139
 
140
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
140
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
141 141
     /**
142 142
      *  Affiche formulaire de selection des modes de reglement
143 143
      *
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function form_prospect_level($page, $selected = 0, $htmlname = 'prospect_level_id', $empty = 0)
151 151
     {
152
-		// phpcs:enable
152
+        // phpcs:enable
153 153
         global $user, $langs;
154 154
 
155 155
         print '<form method="post" action="' . $page . '">';
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         print '</form>';
242 242
     }
243 243
 
244
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
244
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
245 245
     /**
246 246
      *   Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
247 247
      *   In the case of an all-country list, the display breaks on the country.
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
      */
256 256
     public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id')
257 257
     {
258
-		// phpcs:enable
258
+        // phpcs:enable
259 259
         print $this->select_state($selected, $country_codeid, $htmlname);
260 260
     }
261 261
 
262
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
262
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
263 263
     /**
264 264
      *   Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
265 265
      *   In the case of an all-country list, the display breaks on the country.
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
      */
276 276
     public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id', $morecss = 'maxwidth200onsmartphone  minwidth300')
277 277
     {
278
-		// phpcs:enable
278
+        // phpcs:enable
279 279
         global $conf, $langs, $user;
280 280
 
281 281
         dol_syslog(get_class($this) . "::select_departement selected=" . $selected . ", country_codeid=" . $country_codeid, LOG_DEBUG);
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         return $out;
372 372
     }
373 373
 
374
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
374
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
375 375
     /**
376 376
      *   Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
377 377
      *   In the case of an all-country list, the display breaks on the country.
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
         return $html . '</script><span id="target_' . $htmlname . '">' . $this->select_state($selected, $country_codeid, $htmlname, $morecss) . '</span>';
399 399
     }
400 400
 
401
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
401
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
402 402
     /**
403 403
      *   Retourne la liste deroulante des regions actives don't le pays est actif
404 404
      *   La cle de la liste est le code (il peut y avoir plusieurs entree pour
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
      */
412 412
     public function select_region($selected = '', $htmlname = 'region_id')
413 413
     {
414
-		// phpcs:enable
414
+        // phpcs:enable
415 415
         global $conf, $langs;
416 416
         $langs->load("dict");
417 417
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
         }
458 458
     }
459 459
 
460
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
460
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
461 461
     /**
462 462
      *  Return combo list with people title
463 463
      *
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
      */
470 470
     public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 1)
471 471
     {
472
-		// phpcs:enable
472
+        // phpcs:enable
473 473
         global $conf, $langs, $user;
474 474
         $langs->load("dict");
475 475
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
         return $out;
517 517
     }
518 518
 
519
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
519
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
520 520
     /**
521 521
      *    Return the list of all juridical entity types for all countries or a specific country.
522 522
      *    A country separator is included in case the list for all countries is returned.
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
      */
531 531
     public function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '')
532 532
     {
533
-		// phpcs:enable
533
+        // phpcs:enable
534 534
         print $this->select_juridicalstatus($selected, $country_codeid, $filter);
535 535
     }
536 536
 
537
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
537
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
538 538
     /**
539 539
      *    Return the list of all juridical entity types for all countries or a specific country.
540 540
      *    A country separator is included in case the list for all countries is returned.
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
      */
549 549
     public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code', $morecss = '')
550 550
     {
551
-		// phpcs:enable
551
+        // phpcs:enable
552 552
         global $conf, $langs, $user;
553 553
         $langs->load("dict");
554 554
 
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
         return 'ErrorBadValueForParameterRenderMode'; // Should not happened
895 895
     }
896 896
 
897
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
897
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
898 898
     /**
899 899
      *    Return a select list with zip codes and their town
900 900
      *
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
      */
910 910
     public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = array(), $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
911 911
     {
912
-		// phpcs:enable
912
+        // phpcs:enable
913 913
         global $conf;
914 914
 
915 915
         $out = '';
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
         return $out;
929 929
     }
930 930
 
931
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
931
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
932 932
     /**
933 933
      *  Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...)
934 934
      *
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
      */
942 942
     public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth200')
943 943
     {
944
-		// phpcs:enable
944
+        // phpcs:enable
945 945
         global $conf, $langs, $hookmanager;
946 946
 
947 947
         $formlength = 0;
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
         return $out;
1007 1007
     }
1008 1008
 
1009
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1009
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1010 1010
     /**
1011 1011
      * Return a HTML select with localtax values for thirdparties
1012 1012
      *
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
      */
1018 1018
     public function select_localtax($local, $selected, $htmlname)
1019 1019
     {
1020
-		// phpcs:enable
1020
+        // phpcs:enable
1021 1021
         $tax = get_localtax_by_third($local);
1022 1022
 
1023 1023
         if ($tax) {
Please login to merge, or discard this patch.
Dolibarr/Code/Core/Classes/FormSms.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
         $this->withbodyreadonly = 0;
123 123
     }
124 124
 
125
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
125
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
126 126
     /**
127 127
      *  Show the form to input an sms.
128 128
      *
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function show_form($morecss = 'titlefield', $showform = 1)
134 134
     {
135
-		// phpcs:enable
135
+        // phpcs:enable
136 136
         global $conf, $langs, $form;
137 137
 
138 138
         if (!is_object($form)) {
Please login to merge, or discard this patch.
Dolibarr/Code/Core/Classes/FormActions.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     }
54 54
 
55 55
 
56
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
56
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
57 57
     /**
58 58
      *  Show list of action status
59 59
      *
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100')
70 70
     {
71
-		// phpcs:enable
71
+        // phpcs:enable
72 72
         global $langs, $conf;
73 73
 
74 74
         $listofstatus = array(
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
     }
366 366
 
367 367
 
368
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
368
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
369 369
     /**
370 370
      *  Output html select list of type of event
371 371
      *
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
      */
382 382
     public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = 'minwidth300')
383 383
     {
384
-		// phpcs:enable
384
+        // phpcs:enable
385 385
         global $langs, $user, $form;
386 386
 
387 387
         if (!is_object($form)) {
Please login to merge, or discard this patch.
Dolibarr/Code/Core/Classes/CMailFile.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
         return '=?' . $conf->file->character_set_client . '?B?' . base64_encode($stringtoencode) . '?=';
1338 1338
     }
1339 1339
 
1340
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1340
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1341 1341
     /**
1342 1342
      * Read a file on disk and return encoded content for emails (mode = 'mail')
1343 1343
      *
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
      */
1347 1347
     private function _encode_file($sourcefile)
1348 1348
     {
1349
-		// phpcs:enable
1349
+        // phpcs:enable
1350 1350
         $newsourcefile = dol_osencode($sourcefile);
1351 1351
 
1352 1352
         if (is_readable($newsourcefile)) {
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
     }
1362 1362
 
1363 1363
 
1364
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1364
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1365 1365
     /**
1366 1366
      *  Write content of a SMTP request into a dump file (mode = all)
1367 1367
      *  Used for debugging.
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
      */
1372 1372
     public function dump_mail()
1373 1373
     {
1374
-		// phpcs:enable
1374
+        // phpcs:enable
1375 1375
         global $dolibarr_main_data_root;
1376 1376
 
1377 1377
         if (@is_writable($dolibarr_main_data_root)) {   // Avoid fatal error on fopen with open_basedir
@@ -1402,7 +1402,7 @@  discard block
 block discarded – undo
1402 1402
         }
1403 1403
     }
1404 1404
 
1405
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1405
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1406 1406
     /**
1407 1407
      *  Save content if mail is in error
1408 1408
      *  Used for debugging.
@@ -1499,7 +1499,7 @@  discard block
 block discarded – undo
1499 1499
     }
1500 1500
 
1501 1501
 
1502
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1502
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1503 1503
     /**
1504 1504
      * Create SMTP headers (mode = 'mail')
1505 1505
      *
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
      */
1508 1508
     public function write_smtpheaders()
1509 1509
     {
1510
-		// phpcs:enable
1510
+        // phpcs:enable
1511 1511
         $out = "";
1512 1512
         $host = dol_getprefix('email');
1513 1513
 
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
     }
1572 1572
 
1573 1573
 
1574
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1574
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1575 1575
     /**
1576 1576
      * Create header MIME (mode = 'mail')
1577 1577
      *
@@ -1581,7 +1581,7 @@  discard block
 block discarded – undo
1581 1581
      */
1582 1582
     public function write_mimeheaders($filename_list, $mimefilename_list)
1583 1583
     {
1584
-		// phpcs:enable
1584
+        // phpcs:enable
1585 1585
         $mimedone = 0;
1586 1586
         $out = "";
1587 1587
 
@@ -1601,7 +1601,7 @@  discard block
 block discarded – undo
1601 1601
         return $out;
1602 1602
     }
1603 1603
 
1604
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1604
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1605 1605
     /**
1606 1606
      * Return email content (mode = 'mail')
1607 1607
      *
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
      */
1611 1611
     public function write_body($msgtext)
1612 1612
     {
1613
-		// phpcs:enable
1613
+        // phpcs:enable
1614 1614
         global $conf;
1615 1615
 
1616 1616
         $out = '';
@@ -1694,7 +1694,7 @@  discard block
 block discarded – undo
1694 1694
         return $out;
1695 1695
     }
1696 1696
 
1697
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1697
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1698 1698
     /**
1699 1699
      * Attach file to email (mode = 'mail')
1700 1700
      *
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
      */
1707 1707
     private function write_files($filename_list, $mimetype_list, $mimefilename_list, $cidlist)
1708 1708
     {
1709
-		// phpcs:enable
1709
+        // phpcs:enable
1710 1710
         $out = '';
1711 1711
 
1712 1712
         $filename_list_size = count($filename_list);
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
     }
1746 1746
 
1747 1747
 
1748
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1748
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1749 1749
     /**
1750 1750
      * Attach an image to email (mode = 'mail')
1751 1751
      *
@@ -1754,7 +1754,7 @@  discard block
 block discarded – undo
1754 1754
      */
1755 1755
     public function write_images($images_list)
1756 1756
     {
1757
-		// phpcs:enable
1757
+        // phpcs:enable
1758 1758
         $out = '';
1759 1759
 
1760 1760
         if (is_array($images_list)) {
@@ -1776,7 +1776,7 @@  discard block
 block discarded – undo
1776 1776
     }
1777 1777
 
1778 1778
 
1779
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1779
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1780 1780
     /**
1781 1781
      * Try to create a socket connection
1782 1782
      *
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
      */
1787 1787
     public function check_server_port($host, $port)
1788 1788
     {
1789
-		// phpcs:enable
1789
+        // phpcs:enable
1790 1790
         global $conf;
1791 1791
 
1792 1792
         $_retVal = 0;
@@ -1857,7 +1857,7 @@  discard block
 block discarded – undo
1857 1857
         return $_retVal;
1858 1858
     }
1859 1859
 
1860
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1860
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1861 1861
     /**
1862 1862
      * This function has been modified as provided by SirSir to allow multiline responses when
1863 1863
      * using SMTP Extensions.
@@ -1868,7 +1868,7 @@  discard block
 block discarded – undo
1868 1868
      */
1869 1869
     public function server_parse($socket, $response)
1870 1870
     {
1871
-		// phpcs:enable
1871
+        // phpcs:enable
1872 1872
         $_retVal = true; // Indicates if Object was created or not
1873 1873
         $server_response = '';
1874 1874
 
Please login to merge, or discard this patch.