@@ -14,7 +14,7 @@ |
||
14 | 14 | define('REGEX_TEMPLATE_COMPONENT_NAME', '/^(?![0-9_])(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
15 | 15 | |
16 | 16 | define('REGEX_TEMPLATE_STRUCTURE', '/(?s){[ ]*(!)?[ ]*(block|for|widget)[ ]*:[ ]*([a-zA-Z0-9_]+)[ ]*' . |
17 | - '(?:\/[ ]*}|}(.*?){[ ]*\/[ ]*\2[ ]*:[ ]*\3[ ]*})/'); |
|
17 | + '(?:\/[ ]*}|}(.*?){[ ]*\/[ ]*\2[ ]*:[ ]*\3[ ]*})/'); |
|
18 | 18 | |
19 | 19 | define('REGEX_TEMPLATE_VARIABLE', '/\$([a-zA-Z0-9_]+)\$/'); |
20 | 20 | define('REGEX_TEMPLATE_PHRASE', '/\%([a-zA-Z0-9_]+)\%/'); |
@@ -2,19 +2,19 @@ |
||
2 | 2 | |
3 | 3 | # Form expressions |
4 | 4 | |
5 | -define('REGEX_FORM_NAME', '/^[a-zA-Z][a-zA-Z0-9]*$/'); |
|
6 | -define('REGEX_FORM_FIELD_KEY', '/^(?![0-9_])(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
5 | +define('REGEX_FORM_NAME', '/^[a-zA-Z][a-zA-Z0-9]*$/'); |
|
6 | +define('REGEX_FORM_FIELD_KEY', '/^(?![0-9_])(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
7 | 7 | |
8 | 8 | # Language expressions |
9 | 9 | |
10 | -define('REGEX_LANGUAGE_PHRASE_NAME', '/^(?![0-9_])(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
10 | +define('REGEX_LANGUAGE_PHRASE_NAME', '/^(?![0-9_])(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
11 | 11 | |
12 | 12 | # Template expressions |
13 | 13 | |
14 | -define('REGEX_TEMPLATE_COMPONENT_NAME', '/^(?![0-9_])(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
14 | +define('REGEX_TEMPLATE_COMPONENT_NAME', '/^(?![0-9_])(?!.*_$)(?!.*_{2,})[a-zA-Z0-9_]+$/'); |
|
15 | 15 | |
16 | -define('REGEX_TEMPLATE_STRUCTURE', '/(?s){[ ]*(!)?[ ]*(block|for|widget)[ ]*:[ ]*([a-zA-Z0-9_]+)[ ]*' . |
|
16 | +define('REGEX_TEMPLATE_STRUCTURE', '/(?s){[ ]*(!)?[ ]*(block|for|widget)[ ]*:[ ]*([a-zA-Z0-9_]+)[ ]*'. |
|
17 | 17 | '(?:\/[ ]*}|}(.*?){[ ]*\/[ ]*\2[ ]*:[ ]*\3[ ]*})/'); |
18 | 18 | |
19 | -define('REGEX_TEMPLATE_VARIABLE', '/\$([a-zA-Z0-9_]+)\$/'); |
|
20 | -define('REGEX_TEMPLATE_PHRASE', '/\%([a-zA-Z0-9_]+)\%/'); |
|
19 | +define('REGEX_TEMPLATE_VARIABLE', '/\$([a-zA-Z0-9_]+)\$/'); |
|
20 | +define('REGEX_TEMPLATE_PHRASE', '/\%([a-zA-Z0-9_]+)\%/'); |
@@ -19,7 +19,9 @@ |
||
19 | 19 | |
20 | 20 | protected static function init(string $file_name) { |
21 | 21 | |
22 | - if (is_array($range = Explorer::include($file_name))) static::$range = $range; |
|
22 | + if (is_array($range = Explorer::include($file_name))) { |
|
23 | + static::$range = $range; |
|
24 | + } |
|
23 | 25 | } |
24 | 26 | |
25 | 27 | /** |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | public static function stringify(SimpleXMLElement $xml) { |
32 | 32 | |
33 | - if (false === ($xml = dom_import_simplexml($xml))) return false; |
|
33 | + if (false === ($xml = dom_import_simplexml($xml))) { |
|
34 | + return false; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | $dom = $xml->ownerDocument; $dom->formatOutput = true; |
36 | 38 | |
@@ -47,7 +49,9 @@ discard block |
||
47 | 49 | |
48 | 50 | public static function load(string $file_name) { |
49 | 51 | |
50 | - if (false === ($contents = Explorer::getContents($file_name))) return false; |
|
52 | + if (false === ($contents = Explorer::getContents($file_name))) { |
|
53 | + return false; |
|
54 | + } |
|
51 | 55 | |
52 | 56 | return self::parse($contents); |
53 | 57 | } |
@@ -60,7 +64,9 @@ discard block |
||
60 | 64 | |
61 | 65 | public static function save(string $file_name, SimpleXMLElement $xml) { |
62 | 66 | |
63 | - if (false === ($xml = self::stringify($xml))) return false; |
|
67 | + if (false === ($xml = self::stringify($xml))) { |
|
68 | + return false; |
|
69 | + } |
|
64 | 70 | |
65 | 71 | return Explorer::putContents($file_name, $xml); |
66 | 72 | } |
@@ -19,7 +19,9 @@ discard block |
||
19 | 19 | |
20 | 20 | private static function addPhrase(string $name, string $value) { |
21 | 21 | |
22 | - if (preg_match(REGEX_LANGUAGE_PHRASE_NAME, $name)) self::$phrases[$name] = $value; |
|
22 | + if (preg_match(REGEX_LANGUAGE_PHRASE_NAME, $name)) { |
|
23 | + self::$phrases[$name] = $value; |
|
24 | + } |
|
23 | 25 | } |
24 | 26 | |
25 | 27 | /** |
@@ -30,9 +32,13 @@ discard block |
||
30 | 32 | |
31 | 33 | public static function load(string $file_name) { |
32 | 34 | |
33 | - if (!is_array($phrases = Explorer::include($file_name))) return false; |
|
35 | + if (!is_array($phrases = Explorer::include($file_name))) { |
|
36 | + return false; |
|
37 | + } |
|
34 | 38 | |
35 | - foreach ($phrases as $name => $value) if (is_scalar($value)) self::addPhrase($name, $value); |
|
39 | + foreach ($phrases as $name => $value) { |
|
40 | + if (is_scalar($value)) self::addPhrase($name, $value); |
|
41 | + } |
|
36 | 42 | |
37 | 43 | # ------------------------ |
38 | 44 |
@@ -19,17 +19,17 @@ |
||
19 | 19 | |
20 | 20 | # Check basic types |
21 | 21 | |
22 | - if (is_string ($default)) return function(string $value) { return $value; }; |
|
22 | + if (is_string($default)) return function(string $value) { return $value; }; |
|
23 | 23 | |
24 | - if (is_bool ($default)) return function(bool $value) { return $value; }; |
|
24 | + if (is_bool($default)) return function(bool $value) { return $value; }; |
|
25 | 25 | |
26 | - if (is_int ($default)) return function(int $value) { return $value; }; |
|
26 | + if (is_int($default)) return function(int $value) { return $value; }; |
|
27 | 27 | |
28 | - if (is_float ($default)) return function(float $value) { return $value; }; |
|
28 | + if (is_float($default)) return function(float $value) { return $value; }; |
|
29 | 29 | |
30 | - if (is_array ($default)) return function(array $value) { return $value; }; |
|
30 | + if (is_array($default)) return function(array $value) { return $value; }; |
|
31 | 31 | |
32 | - if (is_callable ($default)) return function(callable $value) { return $value; }; |
|
32 | + if (is_callable($default)) return function(callable $value) { return $value; }; |
|
33 | 33 | |
34 | 34 | # Check object type |
35 | 35 |
@@ -19,28 +19,51 @@ |
||
19 | 19 | |
20 | 20 | # Check basic types |
21 | 21 | |
22 | - if (is_string ($default)) return function(string $value) { return $value; }; |
|
22 | + if (is_string ($default)) { |
|
23 | + return function(string $value) { return $value; |
|
24 | + } |
|
25 | + }; |
|
23 | 26 | |
24 | - if (is_bool ($default)) return function(bool $value) { return $value; }; |
|
27 | + if (is_bool ($default)) { |
|
28 | + return function(bool $value) { return $value; |
|
29 | + } |
|
30 | + }; |
|
25 | 31 | |
26 | - if (is_int ($default)) return function(int $value) { return $value; }; |
|
32 | + if (is_int ($default)) { |
|
33 | + return function(int $value) { return $value; |
|
34 | + } |
|
35 | + }; |
|
27 | 36 | |
28 | - if (is_float ($default)) return function(float $value) { return $value; }; |
|
37 | + if (is_float ($default)) { |
|
38 | + return function(float $value) { return $value; |
|
39 | + } |
|
40 | + }; |
|
29 | 41 | |
30 | - if (is_array ($default)) return function(array $value) { return $value; }; |
|
42 | + if (is_array ($default)) { |
|
43 | + return function(array $value) { return $value; |
|
44 | + } |
|
45 | + }; |
|
31 | 46 | |
32 | - if (is_callable ($default)) return function(callable $value) { return $value; }; |
|
47 | + if (is_callable ($default)) { |
|
48 | + return function(callable $value) { return $value; |
|
49 | + } |
|
50 | + }; |
|
33 | 51 | |
34 | 52 | # Check object type |
35 | 53 | |
36 | - if (is_object($default)) return function($value) use($default) { |
|
54 | + if (is_object($default)) { |
|
55 | + return function($value) use($default) { |
|
37 | 56 | |
38 | 57 | return (is_a($value, get_class($default)) ? $value : null); |
58 | + } |
|
39 | 59 | }; |
40 | 60 | |
41 | 61 | # Check resource type |
42 | 62 | |
43 | - if (is_resource($default)) return function($value) { return (is_resource($value) ? $value : null); }; |
|
63 | + if (is_resource($default)) { |
|
64 | + return function($value) { return (is_resource($value) ? $value : null); |
|
65 | + } |
|
66 | + }; |
|
44 | 67 | |
45 | 68 | # ------------------------ |
46 | 69 |
@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | # Build query |
31 | 31 | |
32 | - $this->query = ('UPDATE ' . $table . ' SET ' . $set . ($condition ? (' WHERE (' . $condition . ')') : '')); |
|
32 | + $this->query = ('UPDATE '.$table.' SET '.$set.($condition ? (' WHERE ('.$condition.')') : '')); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | |
18 | 18 | protected function getValue(string $value) { |
19 | 19 | |
20 | - return ('\'' . addslashes($value) . '\''); |
|
20 | + return ('\''.addslashes($value).'\''); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | # Get field sort |
@@ -31,7 +31,9 @@ discard block |
||
31 | 31 | |
32 | 32 | protected function getString($source = null, string $pattern = '', string $separator = '') { |
33 | 33 | |
34 | - if (!is_array($source)) return (is_scalar($source) ? strval($source) : ''); |
|
34 | + if (!is_array($source)) { |
|
35 | + return (is_scalar($source) ? strval($source) : ''); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | $regexs = ['key' => '/\^([a-z]+)/', 'value' => '/\$([a-z]+)/']; $matches = ['key' => [], 'value' => []]; |
37 | 39 | |
@@ -39,18 +41,25 @@ discard block |
||
39 | 41 | |
40 | 42 | # Parse pattern |
41 | 43 | |
42 | - foreach ($regexs as $name => $regex) preg_match($regex, $pattern, $matches[$name]); |
|
44 | + foreach ($regexs as $name => $regex) { |
|
45 | + preg_match($regex, $pattern, $matches[$name]); |
|
46 | + } |
|
43 | 47 | |
44 | 48 | # Process replacements |
45 | 49 | |
46 | - foreach ($source as $key => $value) if (is_scalar($value)) { |
|
50 | + foreach ($source as $key => $value) { |
|
51 | + if (is_scalar($value)) { |
|
47 | 52 | |
48 | - $output[$count] = $pattern; $item = &$output[$count++]; |
|
53 | + $output[$count] = $pattern; |
|
54 | + } |
|
55 | + $item = &$output[$count++]; |
|
49 | 56 | |
50 | - foreach ($matches as $name => $match) if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
57 | + foreach ($matches as $name => $match) { |
|
58 | + if (isset($match[1]) && isset($parsers[$match[1]])) { |
|
51 | 59 | |
52 | 60 | $item = str_replace($match[0], [$this, $parsers[$match[1]]]($$name), $item); |
53 | 61 | } |
62 | + } |
|
54 | 63 | }; |
55 | 64 | |
56 | 65 | # ------------------------ |
@@ -56,7 +56,9 @@ discard block |
||
56 | 56 | |
57 | 57 | public function getRow() { |
58 | 58 | |
59 | - if (!is_object($this->result)) return null; |
|
59 | + if (!is_object($this->result)) { |
|
60 | + return null; |
|
61 | + } |
|
60 | 62 | |
61 | 63 | return mysqli_fetch_assoc($this->result); |
62 | 64 | } |
@@ -67,9 +69,13 @@ discard block |
||
67 | 69 | |
68 | 70 | public function getRows() { |
69 | 71 | |
70 | - if (!is_object($this->result)) return []; |
|
72 | + if (!is_object($this->result)) { |
|
73 | + return []; |
|
74 | + } |
|
71 | 75 | |
72 | - $rows = []; while (null !== ($row = $this->getRow())) $rows[] = $row; |
|
76 | + $rows = []; while (null !== ($row = $this->getRow())) { |
|
77 | + $rows[] = $row; |
|
78 | + } |
|
73 | 79 | |
74 | 80 | # ------------------------ |
75 | 81 |
@@ -36,7 +36,9 @@ |
||
36 | 36 | |
37 | 37 | public function addItems(array $items) { |
38 | 38 | |
39 | - foreach ($items as $item) if (is_array($item)) $this->addItem($item); |
|
39 | + foreach ($items as $item) { |
|
40 | + if (is_array($item)) $this->addItem($item); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | return $this; |
42 | 44 | } |