Completed
Pull Request — master (#73)
by Witold
07:32
created
classes/PHPTAL.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -966,10 +966,10 @@  discard block
 block discarded – undo
966 966
      */
967 967
     public function getFunctionName()
968 968
     {
969
-       // function name is used as base for caching, so it must be unique for
970
-       // every combination of settings that changes code in compiled template
969
+        // function name is used as base for caching, so it must be unique for
970
+        // every combination of settings that changes code in compiled template
971 971
 
972
-       if (!$this->_functionName) {
972
+        if (!$this->_functionName) {
973 973
 
974 974
             // just to make tempalte name recognizable
975 975
             $basename = preg_replace('/\.[a-z]{3,5}$/', '', basename($this->_source->getRealPath()));
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
             $hash = strtr(rtrim(base64_encode($hash),"="),"+/=","_A_");
990 990
 
991 991
             $this->_functionName = $this->getFunctionNamePrefix($this->_source->getLastModifiedTime()) .
992
-                                   $basename . '__' . $hash;
992
+                                    $basename . '__' . $hash;
993 993
         }
994 994
         return $this->_functionName;
995 995
     }
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute/METAL/UseMacro.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -52,14 +52,14 @@
 block discarded – undo
52 52
 
53 53
         $macroname = strtr($this->expression, '-', '_');
54 54
 
55
-	// throw error if attempting to define and use macro at same time
56
-	// [should perhaps be a TemplateException? but I don't know how to set that up...]
57
-	if ($defineAttr = $this->phpelement->getAttributeNodeNS(
58
-		'http://xml.zope.org/namespaces/metal', 'define-macro')) {
59
-		if ($defineAttr->getValue() == $macroname) 
60
-            		throw new PHPTAL_TemplateException("Cannot simultaneously define and use macro '$macroname'",
61
-                		$this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());			
62
-	}
55
+    // throw error if attempting to define and use macro at same time
56
+    // [should perhaps be a TemplateException? but I don't know how to set that up...]
57
+    if ($defineAttr = $this->phpelement->getAttributeNodeNS(
58
+        'http://xml.zope.org/namespaces/metal', 'define-macro')) {
59
+        if ($defineAttr->getValue() == $macroname) 
60
+                    throw new PHPTAL_TemplateException("Cannot simultaneously define and use macro '$macroname'",
61
+                        $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());			
62
+    }
63 63
 
64 64
         // local macro (no filename specified) and non dynamic macro name
65 65
         // can be called directly if it's a known function (just generated or seen in previous compilation)
Please login to merge, or discard this patch.
classes/PHPTAL/Php/Attribute/PHPTAL/Cache.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,12 +67,12 @@
 block discarded – undo
67 67
         } elseif ($cache_per_expression == 'nothing') {
68 68
             /* do nothing */
69 69
         } elseif ($cache_per_expression) {
70
-             $code = $codewriter->evaluateExpression($cache_per_expression);
70
+                $code = $codewriter->evaluateExpression($cache_per_expression);
71 71
 
72
-             if (is_array($code)) throw new PHPTAL_ParserException("Chained expressions in per-cache directive are not supported",
72
+                if (is_array($code)) throw new PHPTAL_ParserException("Chained expressions in per-cache directive are not supported",
73 73
                                                 $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine());
74 74
 
75
-             $cache_tag = '('.$code.')."@".' . $cache_tag;
75
+                $cache_tag = '('.$code.')."@".' . $cache_tag;
76 76
         }
77 77
 
78 78
         $this->cache_filename_var = $codewriter->createTempVariable();
Please login to merge, or discard this patch.
classes/PHPTAL/Dom/Element.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -466,10 +466,10 @@
 block discarded – undo
466 466
             $nsattr = PHPTAL_Dom_Defs::getInstance()->getNamespaceAttribute($domattr->getNamespaceURI(), $domattr->getLocalName());
467 467
             if (array_key_exists($nsattr->getPriority(), $temp)) {
468 468
                 throw new PHPTAL_TemplateException(sprintf("Attribute conflict in < %s > '%s' cannot appear with '%s'",
469
-                               $this->qualifiedName,
470
-                               $key,
471
-                               $temp[$nsattr->getPriority()][0]->getNamespace()->getPrefix() . ':' . $temp[$nsattr->getPriority()][0]->getLocalName()
472
-                               ), $this->getSourceFile(), $this->getSourceLine());
469
+                                $this->qualifiedName,
470
+                                $key,
471
+                                $temp[$nsattr->getPriority()][0]->getNamespace()->getPrefix() . ':' . $temp[$nsattr->getPriority()][0]->getLocalName()
472
+                                ), $this->getSourceFile(), $this->getSourceLine());
473 473
             }
474 474
             $temp[$nsattr->getPriority()] = array($nsattr, $domattr);
475 475
         }
Please login to merge, or discard this patch.
classes/PHPTAL/Dom/SaxXmlParser.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
 
61 61
 
62 62
     static $state_names = array(
63
-      self::ST_ROOT => 'root node',
64
-      self::ST_TEXT => 'text',
65
-      self::ST_LT   => 'start of tag',
66
-      self::ST_TAG_NAME => 'tag name',
67
-      self::ST_TAG_CLOSE => 'closing tag',
68
-      self::ST_TAG_SINGLE => 'self-closing tag',
69
-      self::ST_TAG_ATTRIBUTES => 'tag',
70
-      self::ST_TAG_BETWEEN_ATTRIBUTE => 'tag attributes',
71
-      self::ST_CDATA => 'CDATA',
72
-      self::ST_COMMENT => 'comment',
73
-      self::ST_DOCTYPE => 'doctype',
74
-      self::ST_XMLDEC => 'XML declaration',
75
-      self::ST_PREPROC => 'preprocessor directive',
76
-      self::ST_ATTR_KEY => 'attribute name',
77
-      self::ST_ATTR_EQ => 'attribute value',
78
-      self::ST_ATTR_QUOTE => 'quoted attribute value',
79
-      self::ST_ATTR_VALUE => 'unquoted attribute value',
63
+        self::ST_ROOT => 'root node',
64
+        self::ST_TEXT => 'text',
65
+        self::ST_LT   => 'start of tag',
66
+        self::ST_TAG_NAME => 'tag name',
67
+        self::ST_TAG_CLOSE => 'closing tag',
68
+        self::ST_TAG_SINGLE => 'self-closing tag',
69
+        self::ST_TAG_ATTRIBUTES => 'tag',
70
+        self::ST_TAG_BETWEEN_ATTRIBUTE => 'tag attributes',
71
+        self::ST_CDATA => 'CDATA',
72
+        self::ST_COMMENT => 'comment',
73
+        self::ST_DOCTYPE => 'doctype',
74
+        self::ST_XMLDEC => 'XML declaration',
75
+        self::ST_PREPROC => 'preprocessor directive',
76
+        self::ST_ATTR_KEY => 'attribute name',
77
+        self::ST_ATTR_EQ => 'attribute value',
78
+        self::ST_ATTR_QUOTE => 'quoted attribute value',
79
+        self::ST_ATTR_VALUE => 'unquoted attribute value',
80 80
     );
81 81
 
82 82
     private $input_encoding;
@@ -381,15 +381,15 @@  discard block
 block discarded – undo
381 381
 
382 382
             // http://www.w3.org/International/questions/qa-forms-utf-8
383 383
             $match = '[\x09\x0A\x0D\x20-\x7F]'        // ASCII
384
-               . '|[\xC2-\xDF][\x80-\xBF]'            // non-overlong 2-byte
385
-               . '|\xE0[\xA0-\xBF][\x80-\xBF]'        // excluding overlongs
386
-               . '|[\xE1-\xEC\xEE\xEE][\x80-\xBF]{2}' // straight 3-byte (exclude FFFE and FFFF)
387
-               . '|\xEF[\x80-\xBE][\x80-\xBF]'        // straight 3-byte
388
-               . '|\xEF\xBF[\x80-\xBD]'               // straight 3-byte
389
-               . '|\xED[\x80-\x9F][\x80-\xBF]'        // excluding surrogates
390
-               . '|\xF0[\x90-\xBF][\x80-\xBF]{2}'     // planes 1-3
391
-               . '|[\xF1-\xF3][\x80-\xBF]{3}'         // planes 4-15
392
-               . '|\xF4[\x80-\x8F][\x80-\xBF]{2}';    // plane 16
384
+                . '|[\xC2-\xDF][\x80-\xBF]'            // non-overlong 2-byte
385
+                . '|\xE0[\xA0-\xBF][\x80-\xBF]'        // excluding overlongs
386
+                . '|[\xE1-\xEC\xEE\xEE][\x80-\xBF]{2}' // straight 3-byte (exclude FFFE and FFFF)
387
+                . '|\xEF[\x80-\xBE][\x80-\xBF]'        // straight 3-byte
388
+                . '|\xEF\xBF[\x80-\xBD]'               // straight 3-byte
389
+                . '|\xED[\x80-\x9F][\x80-\xBF]'        // excluding surrogates
390
+                . '|\xF0[\x90-\xBF][\x80-\xBF]{2}'     // planes 1-3
391
+                . '|[\xF1-\xF3][\x80-\xBF]{3}'         // planes 4-15
392
+                . '|\xF4[\x80-\x8F][\x80-\xBF]{2}';    // plane 16
393 393
 
394 394
             if (!preg_match('/^(?:(?>'.$match.'))+$/s',$str)) {
395 395
                 $res = preg_split('/((?>'.$match.')+)/s',$str,null,PREG_SPLIT_DELIM_CAPTURE);
Please login to merge, or discard this patch.
classes/PHPTAL/Php/State.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     public function interpolateTalesVarsInHTML($src)
154 154
     {
155 155
         return preg_replace_callback('/((?:\$\$)*)\$\{(structure |text )?(.*?)\}|((?:\$\$)+)\{/isS',
156
-                                     array($this,'_interpolateTalesVarsInHTMLCallback'), $src);
156
+                                        array($this,'_interpolateTalesVarsInHTMLCallback'), $src);
157 157
     }
158 158
 
159 159
     /**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     public function interpolateTalesVarsInCDATA($src)
173 173
     {
174 174
         return preg_replace_callback('/((?:\$\$)*)\$\{(structure |text )?(.*?)\}|((?:\$\$)+)\{/isS',
175
-                                     array($this,'_interpolateTalesVarsInCDATACallback'), $src);
175
+                                        array($this,'_interpolateTalesVarsInCDATACallback'), $src);
176 176
     }
177 177
 
178 178
     /**
Please login to merge, or discard this patch.
classes/PHPTAL/PreFilter/Compress.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
         }
173 173
 
174 174
         if ($element->getNamespaceURI() !== 'http://www.w3.org/1999/xhtml'
175
-	        && $element->getNamespaceURI() !== '') {
176
-	        return false;
175
+            && $element->getNamespaceURI() !== '') {
176
+            return false;
177 177
         }
178 178
 
179 179
         return in_array($element->getLocalName(), self::$breaks_line);
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
     private function isInlineBlock(PHPTAL_Dom_Element $element)
190 190
     {
191 191
         if ($element->getNamespaceURI() !== 'http://www.w3.org/1999/xhtml'
192
-	        && $element->getNamespaceURI() !== '') {
193
-	        return false;
192
+            && $element->getNamespaceURI() !== '') {
193
+            return false;
194 194
         }
195 195
 
196 196
         return in_array($element->getLocalName(), self::$inline_blocks);
@@ -209,45 +209,45 @@  discard block
 block discarded – undo
209 209
             $attrs_by_qname[$attrnode->getQualifiedName()] = $attrnode;
210 210
         }
211 211
 
212
-	if (count($attrs_by_qname) > 1) {
213
-		uksort($attrs_by_qname, array($this, 'compareQNames'));
214
-		$element->setAttributeNodes(array_values($attrs_by_qname));
215
-	}
212
+    if (count($attrs_by_qname) > 1) {
213
+        uksort($attrs_by_qname, array($this, 'compareQNames'));
214
+        $element->setAttributeNodes(array_values($attrs_by_qname));
215
+    }
216 216
     }
217 217
 
218 218
     /**
219
-	 * pre-defined order of attributes roughly by popularity
220
-	 */
221
-	private static $attributes_order = array(
219
+     * pre-defined order of attributes roughly by popularity
220
+     */
221
+    private static $attributes_order = array(
222 222
         'href','src','class','rel','type','title','width','height','alt','content','name','style','lang','id',
223 223
     );
224 224
 
225
-	/**
226
-	 * compare names according to $attributes_order array.
227
-	 * Elements that are not in array, are considered greater than all elements in array,
228
-	 * and are sorted alphabetically.
229
-	 */
230
-	private static function compareQNames($a, $b) {
231
-		$a_index = array_search($a, self::$attributes_order);
232
-		$b_index = array_search($b, self::$attributes_order);
233
-
234
-		if ($a_index !== false && $b_index !== false) {
235
-			return $a_index - $b_index;
236
-		}
237
-		if ($a_index === false && $b_index === false) {
238
-			return strcmp($a, $b);
239
-		}
240
-		return ($a_index === false) ? 1 : -1;
241
-	}
225
+    /**
226
+     * compare names according to $attributes_order array.
227
+     * Elements that are not in array, are considered greater than all elements in array,
228
+     * and are sorted alphabetically.
229
+     */
230
+    private static function compareQNames($a, $b) {
231
+        $a_index = array_search($a, self::$attributes_order);
232
+        $b_index = array_search($b, self::$attributes_order);
233
+
234
+        if ($a_index !== false && $b_index !== false) {
235
+            return $a_index - $b_index;
236
+        }
237
+        if ($a_index === false && $b_index === false) {
238
+            return strcmp($a, $b);
239
+        }
240
+        return ($a_index === false) ? 1 : -1;
241
+    }
242 242
 
243 243
     /**
244 244
      * HTML5 doesn't care about boilerplate
245 245
      */
246
-	private function elementSpecificOptimizations(PHPTAL_Dom_Element $element)
247
-	{
248
-	    if ($element->getNamespaceURI() !== 'http://www.w3.org/1999/xhtml'
249
-	     && $element->getNamespaceURI() !== '') {
250
-	        return;
246
+    private function elementSpecificOptimizations(PHPTAL_Dom_Element $element)
247
+    {
248
+        if ($element->getNamespaceURI() !== 'http://www.w3.org/1999/xhtml'
249
+         && $element->getNamespaceURI() !== '') {
250
+            return;
251 251
         }
252 252
 
253 253
         if ($this->getPHPTAL()->getOutputMode() !== PHPTAL::HTML5) {
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
         }
256 256
 
257 257
         // <meta charset>
258
-	    if ('meta' === $element->getLocalName() &&
259
-	        $element->getAttributeNS('','http-equiv') === 'Content-Type') {
260
-	            $element->removeAttributeNS('','http-equiv');
261
-	            $element->removeAttributeNS('','content');
262
-	            $element->setAttributeNS('','charset',strtolower($this->getPHPTAL()->getEncoding()));
258
+        if ('meta' === $element->getLocalName() &&
259
+            $element->getAttributeNS('','http-equiv') === 'Content-Type') {
260
+                $element->removeAttributeNS('','http-equiv');
261
+                $element->removeAttributeNS('','content');
262
+                $element->setAttributeNS('','charset',strtolower($this->getPHPTAL()->getEncoding()));
263 263
         }
264 264
         elseif (('link' === $element->getLocalName() && $element->getAttributeNS('','rel') === 'stylesheet') ||
265 265
             ('style' === $element->getLocalName())) {
Please login to merge, or discard this patch.