@@ -33,11 +33,17 @@ |
||
33 | 33 | class Text extends Tag { |
34 | 34 | protected $escape = true; |
35 | 35 | |
36 | + /** |
|
37 | + * @param string $tag |
|
38 | + */ |
|
36 | 39 | function __construct($tag) { |
37 | 40 | parent::__construct(); |
38 | 41 | $this->escape = ($tag == "_"); |
39 | 42 | } |
40 | 43 | |
44 | + /** |
|
45 | + * @param string $s |
|
46 | + */ |
|
41 | 47 | function addContent($s, $strtype = H\Text::TOKEN_HTML) { |
42 | 48 | if (trim($s)) { |
43 | 49 | if ($this->escape) { |
@@ -43,8 +43,9 @@ |
||
43 | 43 | if ($this->escape) { |
44 | 44 | $parse = new H\Text($s, $strtype); |
45 | 45 | $this->content[] = $parse->toHTML(); |
46 | - } else |
|
47 | - $this->content[] = $s; |
|
46 | + } else { |
|
47 | + $this->content[] = $s; |
|
48 | + } |
|
48 | 49 | } |
49 | 50 | } |
50 | 51 |
@@ -33,6 +33,9 @@ |
||
33 | 33 | protected $param1, $param2, $operator; |
34 | 34 | const REGEX_COMP_OPER = '(equals|notequal|notequals|less|greater|has|starts|contains|ends)'; |
35 | 35 | |
36 | + /** |
|
37 | + * @param string $s |
|
38 | + */ |
|
36 | 39 | function __construct($s, $mode = self::TOKEN_CONTROL) { |
37 | 40 | $m = array(); |
38 | 41 | if(preg_match('/^(.*) '.self::REGEX_COMP_OPER.' (.*)$/', $s, $m)) { |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | |
36 | 36 | function __construct($s, $mode = self::TOKEN_CONTROL) { |
37 | 37 | $m = array(); |
38 | - if(preg_match('/^(.*) '.self::REGEX_COMP_OPER.' (.*)$/', $s, $m)) { |
|
39 | - $this->param1 = new Text($m[1],Text::TOKEN_HTML); |
|
40 | - $this->param2 = new Text($m[3],Text::TOKEN_HTML); |
|
38 | + if (preg_match('/^(.*) ' . self::REGEX_COMP_OPER . ' (.*)$/', $s, $m)) { |
|
39 | + $this->param1 = new Text($m[1], Text::TOKEN_HTML); |
|
40 | + $this->param2 = new Text($m[3], Text::TOKEN_HTML); |
|
41 | 41 | $this->operator = $m[2]; |
42 | 42 | } else |
43 | - $this->param1 = new Text($s,Text::TOKEN_HTML); |
|
43 | + $this->param1 = new Text($s, Text::TOKEN_HTML); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // function __construct(String $p1, String $p2, $operator) { |
@@ -49,20 +49,20 @@ discard block |
||
49 | 49 | // $this->operator = $operator; |
50 | 50 | // } |
51 | 51 | function toPHP() { |
52 | - if(!$this->param2) return $this->param1->toPHP(); |
|
52 | + if (!$this->param2) return $this->param1->toPHP(); |
|
53 | 53 | $p1 = $this->param1->toPHP(); |
54 | 54 | $p2 = $this->param2->toPHP(); |
55 | - switch($this->operator) { |
|
55 | + switch ($this->operator) { |
|
56 | 56 | case "equals": |
57 | 57 | case "equal": |
58 | - return $p1." == ".$p2; |
|
58 | + return $p1 . " == " . $p2; |
|
59 | 59 | case "notequals": |
60 | 60 | case "notequal": |
61 | - return $p1." != ".$p2; |
|
61 | + return $p1 . " != " . $p2; |
|
62 | 62 | case "less": |
63 | - return $p1." < ".$p2; |
|
63 | + return $p1 . " < " . $p2; |
|
64 | 64 | case "greater": |
65 | - return $p1." > ".$p2; |
|
65 | + return $p1 . " > " . $p2; |
|
66 | 66 | case "has": |
67 | 67 | return "in_array($p2, $p1)"; |
68 | 68 | case "starts": |
@@ -39,8 +39,9 @@ discard block |
||
39 | 39 | $this->param1 = new Text($m[1],Text::TOKEN_HTML); |
40 | 40 | $this->param2 = new Text($m[3],Text::TOKEN_HTML); |
41 | 41 | $this->operator = $m[2]; |
42 | - } else |
|
43 | - $this->param1 = new Text($s,Text::TOKEN_HTML); |
|
42 | + } else { |
|
43 | + $this->param1 = new Text($s,Text::TOKEN_HTML); |
|
44 | + } |
|
44 | 45 | } |
45 | 46 | |
46 | 47 | // function __construct(String $p1, String $p2, $operator) { |
@@ -49,7 +50,9 @@ discard block |
||
49 | 50 | // $this->operator = $operator; |
50 | 51 | // } |
51 | 52 | function toPHP() { |
52 | - if(!$this->param2) return $this->param1->toPHP(); |
|
53 | + if(!$this->param2) { |
|
54 | + return $this->param1->toPHP(); |
|
55 | + } |
|
53 | 56 | $p1 = $this->param1->toPHP(); |
54 | 57 | $p2 = $this->param2->toPHP(); |
55 | 58 | switch($this->operator) { |
@@ -33,6 +33,9 @@ |
||
33 | 33 | protected $sel = null; |
34 | 34 | protected $filter; |
35 | 35 | |
36 | + /** |
|
37 | + * @param string $s |
|
38 | + */ |
|
36 | 39 | function __construct($s) { |
37 | 40 | if(FALSE !== $pos = strpos($s,'|')) { |
38 | 41 | $this->filter = new Filter(substr($s, $pos+1), $this); |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | protected $filter; |
35 | 35 | |
36 | 36 | function __construct($s) { |
37 | - if(FALSE !== $pos = strpos($s,'|')) { |
|
38 | - $this->filter = new Filter(substr($s, $pos+1), $this); |
|
39 | - $s = substr($s,0,$pos); |
|
37 | + if (FALSE !== $pos = strpos($s, '|')) { |
|
38 | + $this->filter = new Filter(substr($s, $pos + 1), $this); |
|
39 | + $s = substr($s, 0, $pos); |
|
40 | 40 | } |
41 | 41 | $s = explode("->", $s); |
42 | 42 | if (!$s[0]) throw new ParseError("Unable to parse Complex Expression"); |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | function toHTML($escape = false) { |
54 | - if($escape) |
|
55 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
54 | + if ($escape) |
|
55 | + return "<?=htmlspecialchars(" . $this->toPHP() . ")?>"; |
|
56 | 56 | return "<?=" . $this->toPHP() . "?>"; |
57 | 57 | } |
58 | 58 | function toPHP() { |
59 | - return $this->filter?$this->filter->toPHP():$this->toPHPVar(); |
|
59 | + return $this->filter ? $this->filter->toPHP() : $this->toPHPVar(); |
|
60 | 60 | } |
61 | 61 | function toPHPVar() { |
62 | 62 | if ($this->sel) { |
@@ -39,20 +39,24 @@ discard block |
||
39 | 39 | $s = substr($s,0,$pos); |
40 | 40 | } |
41 | 41 | $s = explode("->", $s); |
42 | - if (!$s[0]) throw new ParseError("Unable to parse Complex Expression"); |
|
43 | - if ($s[0][1] == "(") |
|
44 | - $this->func = new Text\Func($s[0]); |
|
45 | - elseif ($s[0][1] == "[") |
|
46 | - $this->func = new Text\Scope($s[0]); |
|
47 | - else |
|
48 | - $this->func = new SimpleVar($s[0]); |
|
42 | + if (!$s[0]) { |
|
43 | + throw new ParseError("Unable to parse Complex Expression"); |
|
44 | + } |
|
45 | + if ($s[0][1] == "(") { |
|
46 | + $this->func = new Text\Func($s[0]); |
|
47 | + } elseif ($s[0][1] == "[") { |
|
48 | + $this->func = new Text\Scope($s[0]); |
|
49 | + } else { |
|
50 | + $this->func = new SimpleVar($s[0]); |
|
51 | + } |
|
49 | 52 | array_shift($s); |
50 | 53 | $this->sel = $s; |
51 | 54 | } |
52 | 55 | |
53 | 56 | function toHTML($escape = false) { |
54 | - if($escape) |
|
55 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
57 | + if($escape) { |
|
58 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
59 | + } |
|
56 | 60 | return "<?=" . $this->toPHP() . "?>"; |
57 | 61 | } |
58 | 62 | function toPHP() { |
@@ -61,11 +65,13 @@ discard block |
||
61 | 65 | function toPHPVar() { |
62 | 66 | if ($this->sel) { |
63 | 67 | $sel = array(); |
64 | - foreach ($this->sel as $s) |
|
65 | - $sel[] = "hamleGet('$s')"; |
|
68 | + foreach ($this->sel as $s) { |
|
69 | + $sel[] = "hamleGet('$s')"; |
|
70 | + } |
|
66 | 71 | return $this->func->toPHP() . "->" . implode('->', $sel); |
67 | - } else |
|
68 | - return $this->func->toPHP(); |
|
72 | + } else { |
|
73 | + return $this->func->toPHP(); |
|
74 | + } |
|
69 | 75 | } |
70 | 76 | |
71 | 77 | } |
72 | 78 | \ No newline at end of file |
@@ -36,6 +36,9 @@ |
||
36 | 36 | /** @var SimpleVar */ |
37 | 37 | protected $what; |
38 | 38 | |
39 | + /** |
|
40 | + * @param string $s |
|
41 | + */ |
|
39 | 42 | function __construct($s, Text $what) { |
40 | 43 | if(preg_match("/^([a-z]+)(\\((.*)\\))$/",$s, $m)) { |
41 | 44 | $this->filter = $m[1]; |
@@ -37,28 +37,28 @@ |
||
37 | 37 | protected $what; |
38 | 38 | |
39 | 39 | function __construct($s, Text $what) { |
40 | - if(preg_match("/^([a-z]+)(\\((.*)\\))$/",$s, $m)) { |
|
40 | + if (preg_match("/^([a-z]+)(\\((.*)\\))$/", $s, $m)) { |
|
41 | 41 | $this->filter = $m[1]; |
42 | - $this->vars = isset($m[3])?explode(',',$m[3]):[]; |
|
42 | + $this->vars = isset($m[3]) ? explode(',', $m[3]) : []; |
|
43 | 43 | } else { |
44 | 44 | throw new ParseError("Unable to parse filter expression \"$s\""); |
45 | 45 | } |
46 | - if(!in_array($this->filter,['round','strtoupper','strtolower','ucfirst'])) { |
|
46 | + if (!in_array($this->filter, ['round', 'strtoupper', 'strtolower', 'ucfirst'])) { |
|
47 | 47 | throw new ParseError("Unknown Filter Type \"{$this->filter}\""); |
48 | 48 | } |
49 | 49 | $this->what = $what; |
50 | 50 | } |
51 | 51 | |
52 | 52 | function toHTML($escape = false) { |
53 | - if($escape) |
|
54 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
53 | + if ($escape) |
|
54 | + return "<?=htmlspecialchars(" . $this->toPHP() . ")?>"; |
|
55 | 55 | return "<?=" . $this->toPHP() . "?>"; |
56 | 56 | } |
57 | 57 | |
58 | 58 | function toPHP() { |
59 | - $o = [$this->what->toPHPVar()] ; |
|
60 | - foreach($this->vars as $v) |
|
59 | + $o = [$this->what->toPHPVar()]; |
|
60 | + foreach ($this->vars as $v) |
|
61 | 61 | $o[] = $this->varToCode($v); |
62 | - return "{$this->filter}(" . implode(',',$o) . ")"; |
|
62 | + return "{$this->filter}(" . implode(',', $o) . ")"; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -50,15 +50,17 @@ |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | function toHTML($escape = false) { |
53 | - if($escape) |
|
54 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
53 | + if($escape) { |
|
54 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
55 | + } |
|
55 | 56 | return "<?=" . $this->toPHP() . "?>"; |
56 | 57 | } |
57 | 58 | |
58 | 59 | function toPHP() { |
59 | 60 | $o = [$this->what->toPHPVar()] ; |
60 | - foreach($this->vars as $v) |
|
61 | - $o[] = $this->varToCode($v); |
|
61 | + foreach($this->vars as $v) { |
|
62 | + $o[] = $this->varToCode($v); |
|
63 | + } |
|
62 | 64 | return "{$this->filter}(" . implode(',',$o) . ")"; |
63 | 65 | } |
64 | 66 | } |
65 | 67 | \ No newline at end of file |
@@ -31,6 +31,9 @@ |
||
31 | 31 | class FuncSub extends Hamle\Text\Func { |
32 | 32 | protected $dir; |
33 | 33 | |
34 | + /** |
|
35 | + * @param string $s |
|
36 | + */ |
|
34 | 37 | function __construct($s) { |
35 | 38 | $m = array(); |
36 | 39 | if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) |
@@ -33,7 +33,7 @@ |
||
33 | 33 | |
34 | 34 | function __construct($s) { |
35 | 35 | $m = array(); |
36 | - if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) |
|
36 | + if (!preg_match('/^ +([><]) +(' . self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) |
|
37 | 37 | throw new ParseError("Unable to read \$ sub func in '$s'"); |
38 | 38 | if ($m[1] == "<") $this->dir = Hamle\Hamle::REL_PARENT; |
39 | 39 | elseif ($m[1] == ">") $this->dir = Hamle\Hamle::REL_CHILD; |
@@ -33,17 +33,25 @@ |
||
33 | 33 | |
34 | 34 | function __construct($s) { |
35 | 35 | $m = array(); |
36 | - if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) |
|
37 | - throw new ParseError("Unable to read \$ sub func in '$s'"); |
|
38 | - if ($m[1] == "<") $this->dir = Hamle\Hamle::REL_PARENT; |
|
39 | - elseif ($m[1] == ">") $this->dir = Hamle\Hamle::REL_CHILD; |
|
40 | - else $this->dir = Hamle\Hamle::REL_ANY; |
|
36 | + if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) { |
|
37 | + throw new ParseError("Unable to read \$ sub func in '$s'"); |
|
38 | + } |
|
39 | + if ($m[1] == "<") { |
|
40 | + $this->dir = Hamle\Hamle::REL_PARENT; |
|
41 | + } elseif ($m[1] == ">") { |
|
42 | + $this->dir = Hamle\Hamle::REL_CHILD; |
|
43 | + } else { |
|
44 | + $this->dir = Hamle\Hamle::REL_ANY; |
|
45 | + } |
|
41 | 46 | $this->sortlimit = $this->attSortLimit($m[2]); |
42 | 47 | $this->filt = $this->attIdTag($m[2]); |
43 | 48 | $this->grouptype = $this->attGroupType($m[2]); |
44 | - if ($this->filt['id']) throw new ParseError("Unable to select by id"); |
|
45 | - if (trim($m[3])) |
|
46 | - $this->sub = new FuncSub($m[3]); |
|
49 | + if ($this->filt['id']) { |
|
50 | + throw new ParseError("Unable to select by id"); |
|
51 | + } |
|
52 | + if (trim($m[3])) { |
|
53 | + $this->sub = new FuncSub($m[3]); |
|
54 | + } |
|
47 | 55 | } |
48 | 56 | |
49 | 57 | function toPHP() { |
@@ -13,6 +13,9 @@ |
||
13 | 13 | protected $s; |
14 | 14 | protected $type; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $s |
|
18 | + */ |
|
16 | 19 | function __construct($s, $type = self::TOKEN_HTML) { |
17 | 20 | $this->s = str_replace('\\$', "$", $s); |
18 | 21 | $this->type = $type; |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Created by PhpStorm. |
|
4 | - * User: Chris |
|
5 | - * Date: 4/12/2014 |
|
6 | - * Time: 12:04 PM |
|
7 | - */ |
|
3 | + * Created by PhpStorm. |
|
4 | + * User: Chris |
|
5 | + * Date: 4/12/2014 |
|
6 | + * Time: 12:04 PM |
|
7 | + */ |
|
8 | 8 | namespace Seufert\Hamle\Text; |
9 | 9 | |
10 | 10 | use Seufert\Hamle\Text; |
@@ -23,8 +23,9 @@ |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | function toHTML($escape = false) { |
26 | - if ($this->type == self::TOKEN_CODE) |
|
27 | - return $this->s; |
|
26 | + if ($this->type == self::TOKEN_CODE) { |
|
27 | + return $this->s; |
|
28 | + } |
|
28 | 29 | return htmlspecialchars($this->s); |
29 | 30 | } |
30 | 31 | } |
31 | 32 | \ No newline at end of file |
@@ -34,11 +34,11 @@ |
||
34 | 34 | * @param string $class Class name to be autoloaded |
35 | 35 | */ |
36 | 36 | spl_autoload_register(function($class) { |
37 | - if(strpos($class, "Seufert\\Hamle\\") === 0) { |
|
37 | + if (strpos($class, "Seufert\\Hamle\\") === 0) { |
|
38 | 38 | $s = DIRECTORY_SEPARATOR; |
39 | - $class = str_replace("\\",$s,substr($class,14)); |
|
40 | - $path = __DIR__.$s."hamle".$s."$class.php"; |
|
41 | - if(is_file($path)) include_once($path); |
|
39 | + $class = str_replace("\\", $s, substr($class, 14)); |
|
40 | + $path = __DIR__ . $s . "hamle" . $s . "$class.php"; |
|
41 | + if (is_file($path)) include_once($path); |
|
42 | 42 | } |
43 | -},true,true); |
|
43 | +},true, true); |
|
44 | 44 |
@@ -38,7 +38,9 @@ |
||
38 | 38 | $s = DIRECTORY_SEPARATOR; |
39 | 39 | $class = str_replace("\\",$s,substr($class,14)); |
40 | 40 | $path = __DIR__.$s."hamle".$s."$class.php"; |
41 | - if(is_file($path)) include_once($path); |
|
41 | + if(is_file($path)) { |
|
42 | + include_once($path); |
|
43 | + } |
|
42 | 44 | } |
43 | 45 | },true,true); |
44 | 46 |
@@ -34,14 +34,18 @@ |
||
34 | 34 | static function filterText($s) { |
35 | 35 | $as = explode("\n", $s); |
36 | 36 | $indent = -1; |
37 | - foreach ($as as $line) |
|
38 | - if (preg_match('/^(\s+).*$/', $line, $m)) { |
|
37 | + foreach ($as as $line) { |
|
38 | + if (preg_match('/^(\s+).*$/', $line, $m)) { |
|
39 | 39 | $lnInd = strlen($m[1]); |
40 | - if ($indent < 0) $indent = $lnInd; |
|
40 | + } |
|
41 | + if ($indent < 0) { |
|
42 | + $indent = $lnInd; |
|
43 | + } |
|
41 | 44 | $indent = min($indent, $lnInd); |
42 | 45 | } |
43 | - foreach ($as as $k => $v) |
|
44 | - $as[$k] = substr($v, $indent); |
|
46 | + foreach ($as as $k => $v) { |
|
47 | + $as[$k] = substr($v, $indent); |
|
48 | + } |
|
45 | 49 | $s = implode("\n", $as); |
46 | 50 | |
47 | 51 | require_once ME_DIR . "/lib/phpsass/SassParser.php"; |
@@ -53,39 +53,48 @@ discard block |
||
53 | 53 | $pos = 0; |
54 | 54 | $this->nodes = array(); |
55 | 55 | $rFlag = PREG_OFFSET_CAPTURE + PREG_SET_ORDER; |
56 | - if (strlen(trim($s)) == 0) return; |
|
56 | + if (strlen(trim($s)) == 0) { |
|
57 | + return; |
|
58 | + } |
|
57 | 59 | if ($mode == self::TOKEN_CONTROL) { |
58 | 60 | if (preg_match('/^"(.*)"$/', trim($s), $m)) { |
59 | 61 | $this->nodes[] = new Text($m[1]); |
60 | - } else |
|
61 | - $this->nodes[] = new Text\Complex(trim($s)); |
|
62 | + } else { |
|
63 | + $this->nodes[] = new Text\Complex(trim($s)); |
|
64 | + } |
|
62 | 65 | return; |
63 | 66 | } |
64 | 67 | preg_match_all(self::REGEX_HTML, $s, $m, $rFlag); |
65 | 68 | foreach ($m as $match) { |
66 | 69 | if ($mode & self::FIND_BARDOLLAR && isset($match[2])) { |
67 | - if ($match[2][1] != $pos) |
|
68 | - $this->nodes[] = new Text\Plain( |
|
70 | + if ($match[2][1] != $pos) { |
|
71 | + $this->nodes[] = new Text\Plain( |
|
69 | 72 | substr($s, $pos, $match[2][1] - $pos), $mode); |
73 | + } |
|
70 | 74 | $this->nodes[] = new Text\Complex(substr($match[2][0], 1, -1)); |
71 | 75 | $pos = $match[2][1] + strlen($match[2][0]); |
72 | 76 | } elseif ($mode & self::FIND_DOLLARVAR) { |
73 | - if ($match[1][1] > 0 && $s[$match[1][1] - 1] == '\\') continue; |
|
74 | - if ($match[1][1] != $pos) |
|
75 | - $this->nodes[] = new Text\Plain( |
|
77 | + if ($match[1][1] > 0 && $s[$match[1][1] - 1] == '\\') { |
|
78 | + continue; |
|
79 | + } |
|
80 | + if ($match[1][1] != $pos) { |
|
81 | + $this->nodes[] = new Text\Plain( |
|
76 | 82 | substr($s, $pos, $match[1][1] - $pos), $mode); |
83 | + } |
|
77 | 84 | $this->nodes[] = new Text\SimpleVar($match[1][0]); |
78 | 85 | $pos = $match[1][1] + strlen($match[1][0]); |
79 | 86 | } |
80 | 87 | } |
81 | - if ($pos != strlen($s)) |
|
82 | - $this->nodes[] = new Text\Plain(substr($s, $pos), $mode); |
|
88 | + if ($pos != strlen($s)) { |
|
89 | + $this->nodes[] = new Text\Plain(substr($s, $pos), $mode); |
|
90 | + } |
|
83 | 91 | } |
84 | 92 | |
85 | 93 | function toHTML($escape = false) { |
86 | 94 | $out = array(); |
87 | - foreach ($this->nodes as $string) |
|
88 | - $out[] = $string->toHTML($escape); |
|
95 | + foreach ($this->nodes as $string) { |
|
96 | + $out[] = $string->toHTML($escape); |
|
97 | + } |
|
89 | 98 | return implode("", $out); |
90 | 99 | } |
91 | 100 | |
@@ -95,8 +104,9 @@ discard block |
||
95 | 104 | |
96 | 105 | function toPHP() { |
97 | 106 | $out = array(); |
98 | - foreach ($this->nodes as $string) |
|
99 | - $out[] = $string->toPHP(); |
|
107 | + foreach ($this->nodes as $string) { |
|
108 | + $out[] = $string->toPHP(); |
|
109 | + } |
|
100 | 110 | return implode(".", $out); |
101 | 111 | } |
102 | 112 | |
@@ -107,8 +117,9 @@ discard block |
||
107 | 117 | static function varToCode($var) { |
108 | 118 | if (is_array($var)) { |
109 | 119 | $code = array(); |
110 | - foreach ($var as $key => $value) |
|
111 | - $code[] = self::varToCode($key) . "=>" . self::varToCode($value); |
|
120 | + foreach ($var as $key => $value) { |
|
121 | + $code[] = self::varToCode($key) . "=>" . self::varToCode($value); |
|
122 | + } |
|
112 | 123 | return 'array(' . implode(",", $code) . ')'; //remove unnecessary coma |
113 | 124 | } elseif (is_bool($var)) { |
114 | 125 | return ($var ? 'TRUE' : 'FALSE'); |