@@ -29,7 +29,7 @@ |
||
29 | 29 | public function resolve($path) |
30 | 30 | { |
31 | 31 | foreach ($this->_repositories as $repository) { |
32 | - $file = $repository . DIRECTORY_SEPARATOR . $path; |
|
32 | + $file = $repository.DIRECTORY_SEPARATOR.$path; |
|
33 | 33 | if (file_exists($file)) { |
34 | 34 | return new PHPTAL_FileSource($file); |
35 | 35 | } |
@@ -46,7 +46,9 @@ discard block |
||
46 | 46 | |
47 | 47 | public function __toString() |
48 | 48 | { |
49 | - if (!$this->srcFile || $this->is_src_accurate) return parent::__toString(); |
|
49 | + if (!$this->srcFile || $this->is_src_accurate) { |
|
50 | + return parent::__toString(); |
|
51 | + } |
|
50 | 52 | return "From {$this->srcFile} around line {$this->srcLine}\n".parent::__toString(); |
51 | 53 | } |
52 | 54 | |
@@ -87,7 +89,9 @@ discard block |
||
87 | 89 | |
88 | 90 | // searches backtrace to find template file |
89 | 91 | foreach($this->getTrace() as $tr) { |
90 | - if (!isset($tr['file'],$tr['line'])) continue; |
|
92 | + if (!isset($tr['file'],$tr['line'])) { |
|
93 | + continue; |
|
94 | + } |
|
91 | 95 | |
92 | 96 | if ($this->isTemplatePath($tr['file'])) { |
93 | 97 | return array($tr['file'], $tr['line']); |
@@ -97,8 +101,7 @@ discard block |
||
97 | 101 | // However, function name matches template path and eval() is visible in backtrace. |
98 | 102 | if (false !== strpos($tr['file'], 'eval()')) { |
99 | 103 | $eval_line = $tr['line']; |
100 | - } |
|
101 | - else if ($eval_line && isset($tr['function'],$tr['args'],$tr['args'][0]) && |
|
104 | + } else if ($eval_line && isset($tr['function'],$tr['args'],$tr['args'][0]) && |
|
102 | 105 | $this->isTemplatePath("/".$tr['function'].".php") && $tr['args'][0] instanceof PHPTAL) { |
103 | 106 | return array($tr['args'][0]->getCodePath(), $eval_line); |
104 | 107 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param int $srcLine |
33 | 33 | * @param Throwable $previous |
34 | 34 | */ |
35 | - public function __construct($msg, $srcFile='', $srcLine=0, $previous = null) |
|
35 | + public function __construct($msg, $srcFile = '', $srcLine = 0, $previous = null) |
|
36 | 36 | { |
37 | 37 | parent::__construct($msg, 0, $previous); |
38 | 38 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | if ($this->is_src_accurate) { |
48 | 48 | $this->file = $this->srcFile; |
49 | - $this->line = (int)$this->srcLine; |
|
49 | + $this->line = (int) $this->srcLine; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | if ($this->is_src_accurate) { |
75 | 75 | $this->file = $this->srcFile; |
76 | - $this->line = (int)$this->srcLine; |
|
76 | + $this->line = (int) $this->srcLine; |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | $eval_path = NULL; |
93 | 93 | |
94 | 94 | // searches backtrace to find template file |
95 | - foreach($this->getTrace() as $tr) { |
|
96 | - if (!isset($tr['file'],$tr['line'])) continue; |
|
95 | + foreach ($this->getTrace() as $tr) { |
|
96 | + if (!isset($tr['file'], $tr['line'])) continue; |
|
97 | 97 | |
98 | 98 | if ($this->isTemplatePath($tr['file'])) { |
99 | 99 | return array($tr['file'], $tr['line']); |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | if (false !== strpos($tr['file'], 'eval()')) { |
105 | 105 | $eval_line = $tr['line']; |
106 | 106 | } |
107 | - else if ($eval_line && isset($tr['function'],$tr['args'],$tr['args'][0]) && |
|
107 | + else if ($eval_line && isset($tr['function'], $tr['args'], $tr['args'][0]) && |
|
108 | 108 | $this->isTemplatePath("/".$tr['function'].".php") && $tr['args'][0] instanceof PHPTAL) { |
109 | 109 | return array($tr['args'][0]->getCodePath(), $eval_line); |
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | - return array(NULL,NULL); |
|
113 | + return array(NULL, NULL); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $this->srcFile = $this->file; |
126 | 126 | $this->srcLine = $this->line; |
127 | 127 | |
128 | - list($file,$line) = $this->findFileAndLine(); |
|
128 | + list($file, $line) = $this->findFileAndLine(); |
|
129 | 129 | |
130 | 130 | if (NULL === $file) { |
131 | 131 | return false; |
@@ -140,23 +140,23 @@ discard block |
||
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
143 | - $found_line=false; |
|
144 | - $found_file=false; |
|
143 | + $found_line = false; |
|
144 | + $found_file = false; |
|
145 | 145 | |
146 | 146 | // scan lines backwards looking for "from line" comments |
147 | 147 | $end = min(count($lines), $line)-1; |
148 | - for($i=$end; $i >= 0; $i--) { |
|
148 | + for ($i = $end; $i >= 0; $i--) { |
|
149 | 149 | if (preg_match('/tag "[^"]*" from line (\d+)/', $lines[$i], $m)) { |
150 | 150 | $this->srcLine = intval($m[1]); |
151 | - $found_line=true; |
|
151 | + $found_line = true; |
|
152 | 152 | break; |
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | - foreach(preg_grep('/Generated by PHPTAL from/',$lines) as $line) { |
|
156 | + foreach (preg_grep('/Generated by PHPTAL from/', $lines) as $line) { |
|
157 | 157 | if (preg_match('/Generated by PHPTAL from (.*) \(/', $line, $m)) { |
158 | 158 | $this->srcFile = $m[1]; |
159 | - $found_file=true; |
|
159 | + $found_file = true; |
|
160 | 160 | break; |
161 | 161 | } |
162 | 162 | } |
@@ -76,7 +76,7 @@ |
||
76 | 76 | $prefix_to_uri[$prefix] = $value; |
77 | 77 | } |
78 | 78 | |
79 | - if ($qname == 'xmlns') {$changed=true;$current_default = $value;} |
|
79 | + if ($qname == 'xmlns') {$changed = true; $current_default = $value; } |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | if ($changed) { |
@@ -34,8 +34,12 @@ |
||
34 | 34 | |
35 | 35 | public function prefixToNamespaceURI($prefix) |
36 | 36 | { |
37 | - if ($prefix === 'xmlns') return 'http://www.w3.org/2000/xmlns/'; |
|
38 | - if ($prefix === 'xml') return 'http://www.w3.org/XML/1998/namespace'; |
|
37 | + if ($prefix === 'xmlns') { |
|
38 | + return 'http://www.w3.org/2000/xmlns/'; |
|
39 | + } |
|
40 | + if ($prefix === 'xml') { |
|
41 | + return 'http://www.w3.org/XML/1998/namespace'; |
|
42 | + } |
|
39 | 43 | |
40 | 44 | // domdefs provides fallback for all known phptal ns |
41 | 45 | if (isset($this->prefix_to_uri[$prefix])) { |
@@ -34,10 +34,12 @@ |
||
34 | 34 | $codewriter->pushHTML($codewriter->interpolateCDATA(str_replace('</', '<\/', $value))); |
35 | 35 | } elseif (($mode === PHPTAL::XHTML && $inCDATAelement) // safe for text/html |
36 | 36 | || ($mode === PHPTAL::XML && preg_match('/[<>&]/', $value)) // non-useless in XML |
37 | - || ($mode !== PHPTAL::HTML5 && preg_match('/<\?|\${structure/', $value))) // hacks with structure (in X[HT]ML) may need it |
|
37 | + || ($mode !== PHPTAL::HTML5 && preg_match('/<\?|\${structure/', $value))) { |
|
38 | + // hacks with structure (in X[HT]ML) may need it |
|
38 | 39 | { |
39 | 40 | // in text/html "</" is dangerous and the only sensible way to escape is ECMAScript string escapes. |
40 | 41 | if ($mode === PHPTAL::XHTML) $value = str_replace('</', '<\/', $value); |
42 | + } |
|
41 | 43 | |
42 | 44 | $codewriter->pushHTML($codewriter->interpolateCDATA('<![CDATA['.$value.']]>')); |
43 | 45 | } else { |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | abstract class PHPTAL_Dom_DocumentBuilder |
23 | 23 | { |
24 | - protected $_stack; /* array<PHPTAL_Dom_Node> */ |
|
24 | + protected $_stack; /* array<PHPTAL_Dom_Node> */ |
|
25 | 25 | protected $_current; /* PHPTAL_Dom_Node */ |
26 | 26 | |
27 | 27 | protected $file, $line; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class PHPTAL_Dom_PHPTALDocumentBuilder extends PHPTAL_Dom_DocumentBuilder |
24 | 24 | { |
25 | - private $_xmlns; /* PHPTAL_Dom_XmlnsState */ |
|
25 | + private $_xmlns; /* PHPTAL_Dom_XmlnsState */ |
|
26 | 26 | private $encoding; |
27 | 27 | |
28 | 28 | public function __construct() |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | public function onDocumentEnd() |
53 | 53 | { |
54 | 54 | if (count($this->_stack) > 0) { |
55 | - $left='</'.$this->_current->getQualifiedName().'>'; |
|
56 | - for ($i = count($this->_stack)-1; $i>0; $i--) $left .= '</'.$this->_stack[$i]->getQualifiedName().'>'; |
|
55 | + $left = '</'.$this->_current->getQualifiedName().'>'; |
|
56 | + for ($i = count($this->_stack)-1; $i > 0; $i--) $left .= '</'.$this->_stack[$i]->getQualifiedName().'>'; |
|
57 | 57 | throw new PHPTAL_ParserException("Not all elements were closed before end of the document. Missing: ".$left, |
58 | 58 | $this->file, $this->line); |
59 | 59 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | $node = new PHPTAL_Dom_Element($element_qname, $namespace_uri, $attrnodes, $this->getXmlnsState()); |
131 | 131 | $this->pushNode($node); |
132 | - $this->_stack[] = $this->_current; |
|
132 | + $this->_stack[] = $this->_current; |
|
133 | 133 | $this->_current = $node; |
134 | 134 | } |
135 | 135 |
@@ -53,7 +53,9 @@ |
||
53 | 53 | { |
54 | 54 | if (count($this->_stack) > 0) { |
55 | 55 | $left='</'.$this->_current->getQualifiedName().'>'; |
56 | - for ($i = count($this->_stack)-1; $i>0; $i--) $left .= '</'.$this->_stack[$i]->getQualifiedName().'>'; |
|
56 | + for ($i = count($this->_stack)-1; $i>0; $i--) { |
|
57 | + $left .= '</'.$this->_stack[$i]->getQualifiedName().'>'; |
|
58 | + } |
|
57 | 59 | throw new PHPTAL_ParserException("Not all elements were closed before end of the document. Missing: ".$left, |
58 | 60 | $this->file, $this->line); |
59 | 61 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * |
104 | 104 | * Encoding must be set before calling addDomain! |
105 | 105 | */ |
106 | - public function addDomain($domain, $path='./locale/') |
|
106 | + public function addDomain($domain, $path = './locale/') |
|
107 | 107 | { |
108 | 108 | bindtextdomain($domain, $path); |
109 | 109 | if ($this->_encoding) { |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @param bool $htmlencode if true, output will be HTML-escaped. |
142 | 142 | */ |
143 | - public function translate($key, $htmlencode=true) |
|
143 | + public function translate($key, $htmlencode = true) |
|
144 | 144 | { |
145 | 145 | if ($this->_canonicalize) $key = self::_canonicalizeKey($key); |
146 | 146 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $key_ = trim($key_); |
169 | 169 | $key_ = str_replace("\n", "", $key_); |
170 | 170 | $key_ = str_replace("\r", "", $key_); |
171 | - for ($i = 0; $i<strlen($key_); $i++) { |
|
171 | + for ($i = 0; $i < strlen($key_); $i++) { |
|
172 | 172 | $c = $key_[$i]; |
173 | 173 | $o = ord($c); |
174 | 174 | if ($o < 5 || $o > 127) { |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | |
35 | 35 | public function __construct() |
36 | 36 | { |
37 | - if (!function_exists('gettext')) throw new PHPTAL_ConfigurationException("Gettext not installed"); |
|
37 | + if (!function_exists('gettext')) { |
|
38 | + throw new PHPTAL_ConfigurationException("Gettext not installed"); |
|
39 | + } |
|
38 | 40 | $this->useDomain("messages"); // PHP bug #21965 |
39 | 41 | } |
40 | 42 | |
@@ -75,11 +77,15 @@ discard block |
||
75 | 77 | $langs = func_get_args(); |
76 | 78 | |
77 | 79 | $langCode = $this->trySettingLanguages(LC_ALL, $langs); |
78 | - if ($langCode) return $langCode; |
|
80 | + if ($langCode) { |
|
81 | + return $langCode; |
|
82 | + } |
|
79 | 83 | |
80 | 84 | if (defined("LC_MESSAGES")) { |
81 | 85 | $langCode = $this->trySettingLanguages(LC_MESSAGES, $langs); |
82 | - if ($langCode) return $langCode; |
|
86 | + if ($langCode) { |
|
87 | + return $langCode; |
|
88 | + } |
|
83 | 89 | } |
84 | 90 | |
85 | 91 | throw new PHPTAL_ConfigurationException('Language(s) code(s) "'.implode(', ', $langs).'" not supported by your system'); |
@@ -142,7 +148,9 @@ discard block |
||
142 | 148 | */ |
143 | 149 | public function translate($key, $htmlencode=true) |
144 | 150 | { |
145 | - if ($this->_canonicalize) $key = self::_canonicalizeKey($key); |
|
151 | + if ($this->_canonicalize) { |
|
152 | + $key = self::_canonicalizeKey($key); |
|
153 | + } |
|
146 | 154 | |
147 | 155 | $value = gettext($key); |
148 | 156 |