| @@ -966,10 +966,10 @@ discard block | ||
| 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 | ||
| 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 | } | 
| @@ -175,7 +175,7 @@ discard block | ||
| 175 | 175 | * | 
| 176 | 176 | * @param string $path Template file path. | 
| 177 | 177 | */ | 
| 178 | - public function __construct($path=false) | |
| 178 | + public function __construct($path = false) | |
| 179 | 179 |      { | 
| 180 | 180 | $this->_path = $path; | 
| 181 | 181 | $this->_globalContext = new stdClass(); | 
| @@ -203,7 +203,7 @@ discard block | ||
| 203 | 203 | * | 
| 204 | 204 | * @return PHPTAL | 
| 205 | 205 | */ | 
| 206 | - public static function create($path=false) | |
| 206 | + public static function create($path = false) | |
| 207 | 207 |      { | 
| 208 | 208 | return new PHPTAL($path); | 
| 209 | 209 | } | 
| @@ -408,7 +408,7 @@ discard block | ||
| 408 | 408 | */ | 
| 409 | 409 | public function setPhpCodeDestination($path) | 
| 410 | 410 |      { | 
| 411 | - $this->_phpCodeDestination = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; | |
| 411 | + $this->_phpCodeDestination = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; | |
| 412 | 412 | $this->resetPrepared(); | 
| 413 | 413 | return $this; | 
| 414 | 414 | } | 
| @@ -548,7 +548,7 @@ discard block | ||
| 548 | 548 | private function getPreFiltersCacheId() | 
| 549 | 549 |      { | 
| 550 | 550 | $cacheid = ''; | 
| 551 | -        foreach($this->getPreFilters() as $key => $prefilter) { | |
| 551 | +        foreach ($this->getPreFilters() as $key => $prefilter) { | |
| 552 | 552 |              if ($prefilter instanceof PHPTAL_PreFilter) { | 
| 553 | 553 | $cacheid .= $key.$prefilter->getCacheId(); | 
| 554 | 554 |              } elseif ($prefilter instanceof PHPTAL_Filter) { | 
| @@ -569,7 +569,7 @@ discard block | ||
| 569 | 569 |      { | 
| 570 | 570 | $prefilters = $this->getPreFilters(); | 
| 571 | 571 | |
| 572 | -        foreach($prefilters as $prefilter) { | |
| 572 | +        foreach ($prefilters as $prefilter) { | |
| 573 | 573 |              if ($prefilter instanceof PHPTAL_PreFilter) { | 
| 574 | 574 | $prefilter->setPHPTAL($this); | 
| 575 | 575 | } | 
| @@ -675,12 +675,12 @@ discard block | ||
| 675 | 675 | |
| 676 | 676 | // unshift doctype | 
| 677 | 677 |              if ($this->_context->_docType) { | 
| 678 | - $res = $this->_context->_docType . $res; | |
| 678 | + $res = $this->_context->_docType.$res; | |
| 679 | 679 | } | 
| 680 | 680 | |
| 681 | 681 | // unshift xml declaration | 
| 682 | 682 |              if ($this->_context->_xmlDeclaration) { | 
| 683 | - $res = $this->_context->_xmlDeclaration . "\n" . $res; | |
| 683 | + $res = $this->_context->_xmlDeclaration."\n".$res; | |
| 684 | 684 | } | 
| 685 | 685 | |
| 686 | 686 |              if ($this->_postfilter) { | 
| @@ -768,7 +768,7 @@ discard block | ||
| 768 | 768 | $this->externalMacroTemplatesCache[$file] = $tpl; | 
| 769 | 769 | } | 
| 770 | 770 | |
| 771 | - $fun = $tpl->getFunctionName() . '_' . strtr($macroName, "-", "_"); | |
| 771 | + $fun = $tpl->getFunctionName().'_'.strtr($macroName, "-", "_"); | |
| 772 | 772 |              if (!function_exists($fun)) { | 
| 773 | 773 |                  throw new PHPTAL_MacroMissingException("Macro '$macroName' is not defined in $file", $this->_source->getRealPath()); | 
| 774 | 774 | } | 
| @@ -777,11 +777,11 @@ discard block | ||
| 777 | 777 | |
| 778 | 778 |          } else { | 
| 779 | 779 | // call local macro | 
| 780 | - $fun = $local_tpl->getFunctionName() . '_' . strtr($path, "-", "_"); | |
| 780 | + $fun = $local_tpl->getFunctionName().'_'.strtr($path, "-", "_"); | |
| 781 | 781 |              if (!function_exists($fun)) { | 
| 782 | 782 |                  throw new PHPTAL_MacroMissingException("Macro '$path' is not defined", $local_tpl->_source->getRealPath()); | 
| 783 | 783 | } | 
| 784 | - $fun( $local_tpl, $this); | |
| 784 | + $fun($local_tpl, $this); | |
| 785 | 785 | } | 
| 786 | 786 | } | 
| 787 | 787 | |
| @@ -791,7 +791,7 @@ discard block | ||
| 791 | 791 | private function setCodeFile() | 
| 792 | 792 |      { | 
| 793 | 793 | $this->findTemplate(); | 
| 794 | - $this->_codeFile = $this->getPhpCodeDestination() . $this->getFunctionName() . '.' . $this->getPhpCodeExtension(); | |
| 794 | + $this->_codeFile = $this->getPhpCodeDestination().$this->getFunctionName().'.'.$this->getPhpCodeExtension(); | |
| 795 | 795 | } | 
| 796 | 796 | |
| 797 | 797 | protected function resetPrepared() | 
| @@ -819,7 +819,7 @@ discard block | ||
| 819 | 819 | |
| 820 | 820 | // i'm not sure where that belongs, but not in normal path of execution | 
| 821 | 821 | // because some sites have _a lot_ of files in temp | 
| 822 | -                if ($this->getCachePurgeFrequency() && mt_rand()%$this->getCachePurgeFrequency() == 0) { | |
| 822 | +                if ($this->getCachePurgeFrequency() && mt_rand() % $this->getCachePurgeFrequency() == 0) { | |
| 823 | 823 | $this->cleanUpGarbage(); | 
| 824 | 824 | } | 
| 825 | 825 | |
| @@ -836,16 +836,16 @@ discard block | ||
| 836 | 836 |                  try { | 
| 837 | 837 |                      eval("?>\n".$result); | 
| 838 | 838 | } | 
| 839 | -                catch(ParseError $parseError) { | |
| 839 | +                catch (ParseError $parseError) { | |
| 840 | 840 | ob_end_clean(); | 
| 841 | 841 | throw new PHPTAL_TemplateException( | 
| 842 | - 'Parse error: ' . $parseError->getMessage(), | |
| 842 | + 'Parse error: '.$parseError->getMessage(), | |
| 843 | 843 | $this->getCodePath(), | 
| 844 | 844 | $parseError->getLine(), | 
| 845 | 845 | $parseError | 
| 846 | 846 | ); | 
| 847 | 847 | } | 
| 848 | -                catch(Exception $e) { | |
| 848 | +                catch (Exception $e) { | |
| 849 | 849 | ob_end_clean(); | 
| 850 | 850 | throw $e; | 
| 851 | 851 | } | 
| @@ -854,7 +854,7 @@ discard block | ||
| 854 | 854 |                      $msg = str_replace('eval()\'d code', $this->getCodePath(), ob_get_clean()); | 
| 855 | 855 | |
| 856 | 856 | // greedy .* ensures last match | 
| 857 | -                    if (preg_match('/.*on line (\d+)$/m', $msg, $m)) $line=$m[1]; else $line=0; | |
| 857 | +                    if (preg_match('/.*on line (\d+)$/m', $msg, $m)) $line = $m[1]; else $line = 0; | |
| 858 | 858 | throw new PHPTAL_TemplateException(trim($msg), $this->getCodePath(), $line); | 
| 859 | 859 | } | 
| 860 | 860 | ob_end_clean(); | 
| @@ -895,7 +895,7 @@ discard block | ||
| 895 | 895 | */ | 
| 896 | 896 | public function setCachePurgeFrequency($n) | 
| 897 | 897 |      { | 
| 898 | - $this->_cachePurgeFrequency = (int)$n; | |
| 898 | + $this->_cachePurgeFrequency = (int) $n; | |
| 899 | 899 | return $this; | 
| 900 | 900 | } | 
| 901 | 901 | |
| @@ -915,14 +915,14 @@ discard block | ||
| 915 | 915 | */ | 
| 916 | 916 | public function cleanUpGarbage() | 
| 917 | 917 |      { | 
| 918 | - $cacheFilesExpire = time() - $this->getCacheLifetime() * 3600 * 24; | |
| 918 | + $cacheFilesExpire = time()-$this->getCacheLifetime() * 3600 * 24; | |
| 919 | 919 | |
| 920 | 920 | // relies on templates sorting order being related to their modification dates | 
| 921 | - $upperLimit = $this->getPhpCodeDestination() . $this->getFunctionNamePrefix($cacheFilesExpire) . '_'; | |
| 922 | - $lowerLimit = $this->getPhpCodeDestination() . $this->getFunctionNamePrefix(0); | |
| 921 | + $upperLimit = $this->getPhpCodeDestination().$this->getFunctionNamePrefix($cacheFilesExpire).'_'; | |
| 922 | + $lowerLimit = $this->getPhpCodeDestination().$this->getFunctionNamePrefix(0); | |
| 923 | 923 | |
| 924 | 924 | // second * gets phptal:cache | 
| 925 | - $cacheFiles = glob($this->getPhpCodeDestination() . 'tpl_????????_*.' . $this->getPhpCodeExtension() . '*'); | |
| 925 | + $cacheFiles = glob($this->getPhpCodeDestination().'tpl_????????_*.'.$this->getPhpCodeExtension().'*'); | |
| 926 | 926 | |
| 927 | 927 |          if ($cacheFiles) { | 
| 928 | 928 |              foreach ($cacheFiles as $index => $file) { | 
| @@ -945,7 +945,7 @@ discard block | ||
| 945 | 945 | public function cleanUpCache() | 
| 946 | 946 |      { | 
| 947 | 947 | $filename = $this->getCodePath(); | 
| 948 | - $cacheFiles = glob($filename . '?*'); | |
| 948 | + $cacheFiles = glob($filename.'?*'); | |
| 949 | 949 |          if ($cacheFiles) { | 
| 950 | 950 |              foreach ($cacheFiles as $file) { | 
| 951 | 951 | if (substr($file, 0, strlen($filename)) !== $filename) continue; // safety net | 
| @@ -984,7 +984,7 @@ discard block | ||
| 984 | 984 |              $basename = preg_replace('/\.[a-z]{3,5}$/', '', basename($this->_source->getRealPath())); | 
| 985 | 985 |              $basename = substr(trim(preg_replace('/[^a-zA-Z0-9]+/', '_', $basename), "_"), 0, 20); | 
| 986 | 986 | |
| 987 | - $hash = md5(PHPTAL_VERSION . PHP_VERSION | |
| 987 | + $hash = md5(PHPTAL_VERSION.PHP_VERSION | |
| 988 | 988 | . $this->_source->getRealPath() | 
| 989 | 989 | . $this->getEncoding() | 
| 990 | 990 | . $this->getPrefiltersCacheId() | 
| @@ -995,10 +995,10 @@ discard block | ||
| 995 | 995 | // uses base64 rather than hex to make filename shorter. | 
| 996 | 996 | // there is loss of some bits due to name constraints and case-insensivity, | 
| 997 | 997 | // but that's still over 110 bits in addition to basename and timestamp. | 
| 998 | - $hash = strtr(rtrim(base64_encode($hash),"="),"+/=","_A_"); | |
| 998 | + $hash = strtr(rtrim(base64_encode($hash), "="), "+/=", "_A_"); | |
| 999 | 999 | |
| 1000 | - $this->_functionName = $this->getFunctionNamePrefix($this->_source->getLastModifiedTime()) . | |
| 1001 | - $basename . '__' . $hash; | |
| 1000 | + $this->_functionName = $this->getFunctionNamePrefix($this->_source->getLastModifiedTime()). | |
| 1001 | + $basename.'__'.$hash; | |
| 1002 | 1002 | } | 
| 1003 | 1003 | return $this->_functionName; | 
| 1004 | 1004 | } | 
| @@ -1015,7 +1015,7 @@ discard block | ||
| 1015 | 1015 |      { | 
| 1016 | 1016 | // tpl_ prefix and last modified time must not be changed, | 
| 1017 | 1017 | // because cache cleanup relies on that | 
| 1018 | -        return 'tpl_' . sprintf("%08x", $timestamp) .'_'; | |
| 1018 | +        return 'tpl_'.sprintf("%08x", $timestamp).'_'; | |
| 1019 | 1019 | } | 
| 1020 | 1020 | |
| 1021 | 1021 | /** | 
| @@ -1045,7 +1045,7 @@ discard block | ||
| 1045 | 1045 | */ | 
| 1046 | 1046 | public function addError(Exception $error) | 
| 1047 | 1047 |      { | 
| 1048 | - $this->_errors[] = $error; | |
| 1048 | + $this->_errors[] = $error; | |
| 1049 | 1049 | } | 
| 1050 | 1050 | |
| 1051 | 1051 | /** | 
| @@ -1101,7 +1101,7 @@ discard block | ||
| 1101 | 1101 | $data = $this->_source->getData(); | 
| 1102 | 1102 | |
| 1103 | 1103 | $prefilters = $this->getPreFilterInstances(); | 
| 1104 | -        foreach($prefilters as $prefilter) { | |
| 1104 | +        foreach ($prefilters as $prefilter) { | |
| 1105 | 1105 | $data = $prefilter->filter($data); | 
| 1106 | 1106 | } | 
| 1107 | 1107 | |
| @@ -1111,7 +1111,7 @@ discard block | ||
| 1111 | 1111 | $builder = new PHPTAL_Dom_PHPTALDocumentBuilder(); | 
| 1112 | 1112 | $tree = $parser->parseString($builder, $data, $realpath)->getResult(); | 
| 1113 | 1113 | |
| 1114 | -        foreach($prefilters as $prefilter) { | |
| 1114 | +        foreach ($prefilters as $prefilter) { | |
| 1115 | 1115 |              if ($prefilter instanceof PHPTAL_PreFilter) { | 
| 1116 | 1116 |                  if ($prefilter->filterDOM($tree) !== NULL) { | 
| 1117 | 1117 |                      throw new PHPTAL_ConfigurationException("Don't return value from filterDOM()"); | 
| @@ -1198,7 +1198,7 @@ discard block | ||
| 1198 | 1198 | |
| 1199 | 1199 | if (substr($class, 0, 7) !== 'PHPTAL_') return; | 
| 1200 | 1200 | |
| 1201 | -        $path = dirname(__FILE__) . strtr("_".$class, "_", DIRECTORY_SEPARATOR) . '.php'; | |
| 1201 | +        $path = dirname(__FILE__).strtr("_".$class, "_", DIRECTORY_SEPARATOR).'.php'; | |
| 1202 | 1202 | |
| 1203 | 1203 | require $path; | 
| 1204 | 1204 | } | 
| @@ -1223,9 +1223,9 @@ discard block | ||
| 1223 | 1223 | // Prepending PHPTAL's autoloader helps if there are other autoloaders | 
| 1224 | 1224 | // that throw/die when file is not found. Only >5.3 though. | 
| 1225 | 1225 |          if (version_compare(PHP_VERSION, '5.3', '>=')) { | 
| 1226 | - spl_autoload_register(array(__CLASS__,'autoload'), false, true); | |
| 1226 | + spl_autoload_register(array(__CLASS__, 'autoload'), false, true); | |
| 1227 | 1227 |          } else { | 
| 1228 | - spl_autoload_register(array(__CLASS__,'autoload')); | |
| 1228 | + spl_autoload_register(array(__CLASS__, 'autoload')); | |
| 1229 | 1229 | } | 
| 1230 | 1230 | |
| 1231 | 1231 |          if ($uses_autoload) { | 
| @@ -37,20 +37,20 @@ discard block | ||
| 37 | 37 | class PHPTAL_Php_Transformer | 
| 38 | 38 |  { | 
| 39 | 39 | const ST_WHITE = -1; // start of string or whitespace | 
| 40 | - const ST_NONE = 0; // pass through (operators, parens, etc.) | |
| 41 | - const ST_STR = 1; // 'foo' | |
| 42 | -    const ST_ESTR   = 2;  // "foo ${x} bar" | |
| 43 | - const ST_VAR = 3; // abcd | |
| 44 | - const ST_NUM = 4; // 123.02 | |
| 45 | - const ST_EVAL = 5; // $somevar | |
| 46 | - const ST_MEMBER = 6; // abcd.x | |
| 47 | - const ST_STATIC = 7; // class::[$]static|const | |
| 48 | - const ST_DEFINE = 8; // @MY_DEFINE | |
| 40 | + const ST_NONE = 0; // pass through (operators, parens, etc.) | |
| 41 | + const ST_STR = 1; // 'foo' | |
| 42 | +    const ST_ESTR   = 2; // "foo ${x} bar" | |
| 43 | + const ST_VAR = 3; // abcd | |
| 44 | + const ST_NUM = 4; // 123.02 | |
| 45 | + const ST_EVAL = 5; // $somevar | |
| 46 | + const ST_MEMBER = 6; // abcd.x | |
| 47 | + const ST_STATIC = 7; // class::[$]static|const | |
| 48 | + const ST_DEFINE = 8; // @MY_DEFINE | |
| 49 | 49 | |
| 50 | 50 | /** | 
| 51 | 51 | * transform PHPTAL's php-like syntax into real PHP | 
| 52 | 52 | */ | 
| 53 | - public static function transform($str, $prefix='$') | |
| 53 | + public static function transform($str, $prefix = '$') | |
| 54 | 54 |      { | 
| 55 | 55 | $len = strlen($str); | 
| 56 | 56 | $state = self::ST_WHITE; | 
| @@ -119,7 +119,7 @@ discard block | ||
| 119 | 119 | $result .= '->'; | 
| 120 | 120 | $state = self::ST_MEMBER; | 
| 121 | 121 | $mark = $i+2; | 
| 122 | - $i+=2; | |
| 122 | + $i += 2; | |
| 123 | 123 | } | 
| 124 | 124 | } | 
| 125 | 125 | // @ is an access to some defined variable | 
| @@ -140,7 +140,7 @@ discard block | ||
| 140 | 140 | // $xxx | 
| 141 | 141 | case self::ST_EVAL: | 
| 142 | 142 |                      if (!self::isVarNameChar($c)) { | 
| 143 | - $result .= $prefix . substr($str, $mark, $i-$mark); | |
| 143 | + $result .= $prefix.substr($str, $mark, $i-$mark); | |
| 144 | 144 | $result .= '}'; | 
| 145 | 145 | $state = self::ST_NONE; | 
| 146 | 146 | } | 
| @@ -177,10 +177,10 @@ discard block | ||
| 177 | 177 | // instring interpolation, search } and transform the | 
| 178 | 178 | // interpollation to insert it into the string | 
| 179 | 179 |                      elseif ($c === '$' && $i+1 < $len && $str[$i+1] === '{') { | 
| 180 | -                        $result .= substr($str, $mark, $i-$mark) . '{'; | |
| 180 | +                        $result .= substr($str, $mark, $i-$mark).'{'; | |
| 181 | 181 | |
| 182 | 182 | $sub = 0; | 
| 183 | -                        for ($j = $i; $j<$len; $j++) { | |
| 183 | +                        for ($j = $i; $j < $len; $j++) { | |
| 184 | 184 |                              if ($str[$j] === '{') { | 
| 185 | 185 | $sub++; | 
| 186 | 186 |                              } elseif ($str[$j] === '}' && (--$sub) == 0) { | 
| @@ -199,7 +199,7 @@ discard block | ||
| 199 | 199 | } | 
| 200 | 200 | // end of var, begin of member (method or var) | 
| 201 | 201 |                      elseif ($c === '.') { | 
| 202 | - $result .= $prefix . substr($str, $mark, $i-$mark); | |
| 202 | + $result .= $prefix.substr($str, $mark, $i-$mark); | |
| 203 | 203 | $result .= '->'; | 
| 204 | 204 | $state = self::ST_MEMBER; | 
| 205 | 205 | $mark = $i+1; | 
| @@ -219,10 +219,10 @@ discard block | ||
| 219 | 219 | } | 
| 220 | 220 | // array index, the var is done | 
| 221 | 221 |                      elseif ($c === '[') { | 
| 222 | -                        if ($str[$mark]==='_') { // superglobal? | |
| 223 | - $result .= '$' . substr($str, $mark, $i-$mark+1); | |
| 222 | +                        if ($str[$mark] === '_') { // superglobal? | |
| 223 | + $result .= '$'.substr($str, $mark, $i-$mark+1); | |
| 224 | 224 |                          } else { | 
| 225 | - $result .= $prefix . substr($str, $mark, $i-$mark+1); | |
| 225 | + $result .= $prefix.substr($str, $mark, $i-$mark+1); | |
| 226 | 226 | } | 
| 227 | 227 | $state = self::ST_NONE; | 
| 228 | 228 | } | 
| @@ -252,7 +252,7 @@ discard block | ||
| 252 | 252 | } | 
| 253 | 253 | // regular variable | 
| 254 | 254 |                          else { | 
| 255 | - $result .= $prefix . $var; | |
| 255 | + $result .= $prefix.$var; | |
| 256 | 256 | } | 
| 257 | 257 | $i--; | 
| 258 | 258 | $state = self::ST_NONE; | 
| @@ -265,7 +265,7 @@ discard block | ||
| 265 | 265 | } | 
| 266 | 266 |                      // eval mode ${foo} | 
| 267 | 267 |                      elseif ($c === '$' && ($i >= $len-2 || $str[$i+1] !== '{')) { | 
| 268 | -                        $result .= '{' . $prefix; | |
| 268 | +                        $result .= '{'.$prefix; | |
| 269 | 269 | $mark++; | 
| 270 | 270 | $eval = true; | 
| 271 | 271 | } | 
| @@ -276,7 +276,7 @@ discard block | ||
| 276 | 276 | // end of var member var, begin of new member | 
| 277 | 277 |                      elseif ($c === '.') { | 
| 278 | 278 | $result .= substr($str, $mark, $i-$mark); | 
| 279 | -                        if ($eval) { $result .='}'; $eval = false; } | |
| 279 | +                        if ($eval) { $result .= '}'; $eval = false; } | |
| 280 | 280 | $result .= '->'; | 
| 281 | 281 | $mark = $i+1; | 
| 282 | 282 | $state = self::ST_MEMBER; | 
| @@ -284,24 +284,24 @@ discard block | ||
| 284 | 284 | // begin of static access | 
| 285 | 285 |                      elseif ($c === ':') { | 
| 286 | 286 | $result .= substr($str, $mark, $i-$mark+1); | 
| 287 | -                        if ($eval) { $result .='}'; $eval = false; } | |
| 287 | +                        if ($eval) { $result .= '}'; $eval = false; } | |
| 288 | 288 | $state = self::ST_STATIC; | 
| 289 | 289 | break; | 
| 290 | 290 | } | 
| 291 | 291 | // the member is a method or an array | 
| 292 | 292 |                      elseif ($c === '(' || $c === '[') { | 
| 293 | 293 | $result .= substr($str, $mark, $i-$mark+1); | 
| 294 | -                        if ($eval) { $result .='}'; $eval = false; } | |
| 294 | +                        if ($eval) { $result .= '}'; $eval = false; } | |
| 295 | 295 | $state = self::ST_NONE; | 
| 296 | 296 | } | 
| 297 | 297 | // regular end of member, it is a var | 
| 298 | 298 |                      else { | 
| 299 | 299 | $var = substr($str, $mark, $i-$mark); | 
| 300 | -                        if ($var !== '' && !preg_match('/^[a-z][a-z0-9_\x7f-\xff]*$/i',$var)) { | |
| 300 | +                        if ($var !== '' && !preg_match('/^[a-z][a-z0-9_\x7f-\xff]*$/i', $var)) { | |
| 301 | 301 |                              throw new PHPTAL_ParserException("Invalid field name '$var' in expression php:$str"); | 
| 302 | 302 | } | 
| 303 | 303 | $result .= $var; | 
| 304 | -                        if ($eval) { $result .='}'; $eval = false; } | |
| 304 | +                        if ($eval) { $result .= '}'; $eval = false; } | |
| 305 | 305 | $state = self::ST_NONE; | 
| 306 | 306 | $i--; | 
| 307 | 307 | } | 
| @@ -80,7 +80,7 @@ | ||
| 80 | 80 | $code = $codewriter->evaluateExpression($expression); | 
| 81 | 81 | |
| 82 | 82 | // instantiate controller using expression | 
| 83 | -        $codewriter->doSetVar( $this->var.'->'.$varName, 'new PHPTAL_RepeatController('.$code.')'."\n" ); | |
| 83 | +        $codewriter->doSetVar($this->var.'->'.$varName, 'new PHPTAL_RepeatController('.$code.')'."\n"); | |
| 84 | 84 | |
| 85 | 85 | $codewriter->pushContext(); | 
| 86 | 86 | |
| @@ -186,7 +186,7 @@ | ||
| 186 | 186 | $executor->doElse(); | 
| 187 | 187 | $attr_str = ($this->_default_escaped !== false) | 
| 188 | 188 | ? ' '.$this->_attribute.'='.$codewriter->quoteAttributeValue($this->_default_escaped) // default value | 
| 189 | - : ''; // do not print attribute | |
| 189 | + : ''; // do not print attribute | |
| 190 | 190 | $codewriter->doSetVar($this->_attkey, $codewriter->str($attr_str)); | 
| 191 | 191 | $executor->breakChain(); | 
| 192 | 192 | } | 
| @@ -52,7 +52,7 @@ discard block | ||
| 52 | 52 | $code = 'false'; | 
| 53 | 53 | } | 
| 54 | 54 | |
| 55 | -        $codewriter->doIf('phptal_true(' . $code . ')'); | |
| 55 | +        $codewriter->doIf('phptal_true('.$code.')'); | |
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | 58 | public function after(PHPTAL_Php_CodeWriter $codewriter) | 
| @@ -65,12 +65,12 @@ discard block | ||
| 65 | 65 |      { | 
| 66 | 66 | // check if the expression is empty | 
| 67 | 67 |          if ($exp !== 'false') { | 
| 68 | -            $this->expressions[] = '!phptal_isempty(' . $exp . ')'; | |
| 68 | +            $this->expressions[] = '!phptal_isempty('.$exp.')'; | |
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | 71 |          if ($islast) { | 
| 72 | 72 | // for the last one in the chain build a ORed condition | 
| 73 | -            $executor->getCodeWriter()->doIf( implode(' || ', $this->expressions ) ); | |
| 73 | +            $executor->getCodeWriter()->doIf(implode(' || ', $this->expressions)); | |
| 74 | 74 | // The executor will always end an if so we output a dummy if | 
| 75 | 75 |              $executor->doIf('false'); | 
| 76 | 76 | } | 
| @@ -46,7 +46,7 @@ discard block | ||
| 46 | 46 | /** | 
| 47 | 47 | * Prevents generation of invalid PHP code when given invalid TALES | 
| 48 | 48 | */ | 
| 49 | - private $_chainPartGenerated=false; | |
| 49 | + private $_chainPartGenerated = false; | |
| 50 | 50 | |
| 51 | 51 | public function before(PHPTAL_Php_CodeWriter $codewriter) | 
| 52 | 52 |      { | 
| @@ -79,7 +79,7 @@ discard block | ||
| 79 | 79 | $code = $codewriter->evaluateExpression($expression); | 
| 80 | 80 |              if (is_array($code)) { | 
| 81 | 81 | $this->chainedDefine($codewriter, $code); | 
| 82 | -            } elseif ( $code == PHPTAL_Php_TalesInternal::NOTHING_KEYWORD) { | |
| 82 | +            } elseif ($code == PHPTAL_Php_TalesInternal::NOTHING_KEYWORD) { | |
| 83 | 83 | $this->doDefineVarWith($codewriter, 'null'); | 
| 84 | 84 |              } else { | 
| 85 | 85 | $this->doDefineVarWith($codewriter, $code); | 
| @@ -127,7 +127,7 @@ discard block | ||
| 127 | 127 | |
| 128 | 128 | public function talesChainPart(PHPTAL_Php_TalesChainExecutor $executor, $exp, $islast) | 
| 129 | 129 |      { | 
| 130 | - $this->_chainPartGenerated=true; | |
| 130 | + $this->_chainPartGenerated = true; | |
| 131 | 131 | |
| 132 | 132 |          if ($this->_defineScope == 'global') { | 
| 133 | 133 | $var = '$tpl->getGlobalContext()->'.$this->_defineVar; | 
| @@ -173,7 +173,7 @@ discard block | ||
| 173 | 173 |      { | 
| 174 | 174 |          if (!$this->_buffered) { | 
| 175 | 175 | $this->tmp_content_var = $codewriter->createTempVariable(); | 
| 176 | - $codewriter->pushCode( 'ob_start()' ); | |
| 176 | +            $codewriter->pushCode('ob_start()'); | |
| 177 | 177 | $this->phpelement->generateContent($codewriter); | 
| 178 | 178 | $codewriter->doSetVar($this->tmp_content_var, 'ob_get_clean()'); | 
| 179 | 179 | $this->_buffered = true; | 
| @@ -37,7 +37,7 @@ | ||
| 37 | 37 | */ | 
| 38 | 38 | class PHPTAL_Php_Attribute_I18N_Target extends PHPTAL_Php_Attribute | 
| 39 | 39 |  { | 
| 40 | -    public function before(PHPTAL_Php_CodeWriter $codewriter){} | |
| 41 | -    public function after(PHPTAL_Php_CodeWriter $codewriter){} | |
| 40 | +    public function before(PHPTAL_Php_CodeWriter $codewriter) {} | |
| 41 | +    public function after(PHPTAL_Php_CodeWriter $codewriter) {} | |
| 42 | 42 | } | 
| 43 | 43 | |
| @@ -80,7 +80,7 @@ discard block | ||
| 80 | 80 | $code = $this->_getTranslationCode($codewriter, $attr->getValue()); | 
| 81 | 81 |                  } elseif ($attr->getReplacedState() === PHPTAL_Dom_Attr::VALUE_REPLACED && $attr->getOverwrittenVariableName()) { | 
| 82 | 82 | // sadly variables won't be interpolated in this translation | 
| 83 | -                    $code = 'echo '.$codewriter->escapeCode($codewriter->getTranslatorReference(). '->translate('.$attr->getOverwrittenVariableName().', false)'); | |
| 83 | +                    $code = 'echo '.$codewriter->escapeCode($codewriter->getTranslatorReference().'->translate('.$attr->getOverwrittenVariableName().', false)'); | |
| 84 | 84 |                  } else { | 
| 85 | 85 |                      throw new PHPTAL_TemplateException("Unable to translate attribute $qname, because other TAL attributes are using it", | 
| 86 | 86 | $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine()); | 
| @@ -104,7 +104,7 @@ discard block | ||
| 104 | 104 | array_shift($m); | 
| 105 | 105 | $m = array_shift($m); | 
| 106 | 106 |              foreach ($m as $name) { | 
| 107 | -                $code .= "\n".$codewriter->getTranslatorReference(). '->setVar('.$codewriter->str($name).','.PHPTAL_Php_TalesInternal::compileToPHPExpression($name).');'; // allow more complex TAL expressions | |
| 107 | +                $code .= "\n".$codewriter->getTranslatorReference().'->setVar('.$codewriter->str($name).','.PHPTAL_Php_TalesInternal::compileToPHPExpression($name).');'; // allow more complex TAL expressions | |
| 108 | 108 | } | 
| 109 | 109 | $code .= "\n"; | 
| 110 | 110 | } | 
| @@ -34,8 +34,8 @@ discard block | ||
| 34 | 34 | $escape = true; | 
| 35 | 35 | $this->_echoType = PHPTAL_Php_Attribute::ECHO_TEXT; | 
| 36 | 36 |          if (preg_match('/^(text|structure)(?:\s+(.*)|\s*$)/', $this->expression, $m)) { | 
| 37 | -            if ($m[1]=='structure') { $escape=false; $this->_echoType = PHPTAL_Php_Attribute::ECHO_STRUCTURE; } | |
| 38 | - $this->expression = isset($m[2])?$m[2]:''; | |
| 37 | +            if ($m[1] == 'structure') { $escape = false; $this->_echoType = PHPTAL_Php_Attribute::ECHO_STRUCTURE; } | |
| 38 | + $this->expression = isset($m[2]) ? $m[2] : ''; | |
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | 41 | $this->_prepareNames($codewriter, $this->phpelement); | 
| @@ -44,7 +44,7 @@ discard block | ||
| 44 | 44 | // a translation key | 
| 45 | 45 |          if (strlen(trim($this->expression)) == 0) { | 
| 46 | 46 | $key = $this->_getTranslationKey($this->phpelement, !$escape, $codewriter->getEncoding()); | 
| 47 | -            $key = trim(preg_replace('/\s+/sm'.($codewriter->getEncoding()=='UTF-8'?'u':''), ' ', $key)); | |
| 47 | +            $key = trim(preg_replace('/\s+/sm'.($codewriter->getEncoding() == 'UTF-8' ? 'u' : ''), ' ', $key)); | |
| 48 | 48 |              if ('' === trim($key)) { | 
| 49 | 49 |                  throw new PHPTAL_TemplateException("Empty translation key", | 
| 50 | 50 | $this->phpelement->getSourceFile(), $this->phpelement->getSourceLine()); | 
| @@ -58,7 +58,7 @@ discard block | ||
| 58 | 58 | $code = $codewriter->evaluateExpression($this->expression); | 
| 59 | 59 | } | 
| 60 | 60 | |
| 61 | -        $codewriter->pushCode('echo '.$codewriter->getTranslatorReference().'->translate('.$code.','.($escape ? 'true':'false').');'); | |
| 61 | +        $codewriter->pushCode('echo '.$codewriter->getTranslatorReference().'->translate('.$code.','.($escape ? 'true' : 'false').');'); | |
| 62 | 62 | } | 
| 63 | 63 | |
| 64 | 64 | public function after(PHPTAL_Php_CodeWriter $codewriter) | 
| @@ -70,7 +70,7 @@ discard block | ||
| 70 | 70 | $codewriter = $executor->getCodeWriter(); | 
| 71 | 71 | |
| 72 | 72 | $escape = !($this->_echoType == PHPTAL_Php_Attribute::ECHO_STRUCTURE); | 
| 73 | - $exp = $codewriter->getTranslatorReference()."->translate($exp, " . ($escape ? 'true':'false') . ')'; | |
| 73 | + $exp = $codewriter->getTranslatorReference()."->translate($exp, ".($escape ? 'true' : 'false').')'; | |
| 74 | 74 |          if (!$islast) { | 
| 75 | 75 | $var = $codewriter->createTempVariable(); | 
| 76 | 76 |              $executor->doIf('!phptal_isempty('.$var.' = '.$exp.')'); | 
| @@ -94,7 +94,7 @@ discard block | ||
| 94 | 94 | } | 
| 95 | 95 |              } elseif ($child instanceof PHPTAL_Dom_Element) { | 
| 96 | 96 |                  if ($attr = $child->getAttributeNodeNS('http://xml.zope.org/namespaces/i18n', 'name')) { | 
| 97 | -                    $result .= '${' . $attr->getValue() . '}'; | |
| 97 | +                    $result .= '${'.$attr->getValue().'}'; | |
| 98 | 98 |                  } else { | 
| 99 | 99 | |
| 100 | 100 |                      if ($preserve_tags) { | 
| @@ -104,7 +104,7 @@ discard block | ||
| 104 | 104 | |
| 105 | 105 | $result .= ' '.$attr->getQualifiedName().'="'.$attr->getValueEscaped().'"'; | 
| 106 | 106 | } | 
| 107 | - $result .= '>'.$this->_getTranslationKey($child, $preserve_tags, $encoding) . '</'.$child->getQualifiedName().'>'; | |
| 107 | + $result .= '>'.$this->_getTranslationKey($child, $preserve_tags, $encoding).'</'.$child->getQualifiedName().'>'; | |
| 108 | 108 |                      } else { | 
| 109 | 109 | $result .= $this->_getTranslationKey($child, $preserve_tags, $encoding); | 
| 110 | 110 | } |