Esempio n. 1
0
 /**
  * @param string $tag
  * @return string
  */
 public function convert($tag)
 {
     /* Lecseréli a <?php if ($warning) ?> típusú template-eket */
     $name = "Conditional Statements";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPTemplate::IF_CONDITION_BEGIN . PHPConverter::getConditionalExpressionRegex(true) . PHPTemplate::IF_CONDITION_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $from = 1;
         return "{% if " . PHPConverter::convertConditionalExpression($matches, $from) . " %}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     /* Lecseréli a <?php elseif ($warning) ?> típusú template-eket */
     $name = "Elseif Statements";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPTemplate::ELSE_IF_CONDITION_BEGIN . PHPConverter::getConditionalExpressionRegex(true) . PHPTemplate::IF_CONDITION_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $from = 1;
         return "{% elseif " . PHPConverter::convertConditionalExpression($matches, $from) . " %}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     /* Lecseréli a <?php else ?> típusú template-eket */
     $name = "Else Statements";
     $tag = preg_replace("/" . PHPTemplate::TEMPLATE_START . PHPTemplate::ELSE_BEGIN . PHPTemplate::TEMPLATE_END . "/s", "{% else %}", $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     /* Lecseréli a <?php endif; ?> típusú template-eket */
     $name = "Endif Statements";
     $tag = preg_replace("/" . PHPTemplate::TEMPLATE_START . PHPTemplate::ENDIF_STATEMENT . PHPTemplate::TEMPLATE_END . "/s", "{% endif %}", $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     return $tag;
 }
 /**
  * @param string $tag
  * @return string
  */
 public function convert($tag)
 {
     /* Lecseréli a <?php foreach($a as $v) ?> típusú template-eket */
     $name = "Value";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPTemplate::FOREACH_HEAD_BEGIN . PHPConverter::getExpressionRegex(true) . "\\s*as\\s*" . PHPConverter::getVariableRegex(true) . PHPTemplate::FOREACH_HEAD_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $from = 2;
         $result = "{% for " . PHPConverter::convertVariable($matches[$from]) . " in ";
         $from = 1;
         $result .= PHPConverter::convertExpression($matches, $from) . " %}";
         return $result;
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     /* Lecseréli a <?php foreach($a as $k => $v) ?> típusú template-eket */
     $name = "Key and value";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPTemplate::FOREACH_HEAD_BEGIN . PHPConverter::getExpressionRegex(true) . "\\s*as\\s*" . PHPConverter::getVariableRegex(true) . "\\s*=>\\s*" . PHPConverter::getVariableRegex(true) . PHPTemplate::FOREACH_HEAD_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $from = 2;
         $result = "{% for " . PHPConverter::convertVariable($matches[$from]) . ", ";
         $from = 3;
         $result .= PHPConverter::convertVariable($matches[$from]) . " in ";
         $from = 1;
         $result .= PHPConverter::convertExpression($matches, $from) . " %}";
         return $result;
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     /* Lecseréli a <?php endforeach; ?> típusú template-eket */
     $name = "Key and value";
     $tag = preg_replace("/" . PHPTemplate::TEMPLATE_START . PHPTemplate::ENDFOREACH_STATEMENT . PHPTemplate::TEMPLATE_END . "/s", "{% endfor %}", $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     return $tag;
 }
Esempio n. 3
0
 /**
  * @param string $tag
  * @return string
  */
 public function convert($tag)
 {
     $name = "Echoing static method call without parameters";
     $count = 0;
     $tag = preg_replace("/" . PHPTemplate::TEMPLATE_START . PHPTemplate::ECHO_BEGIN . PHPConverter::getIdentifierRegex(true) . "\\:\\:" . PHPConverter::getIdentifierRegex(true) . "\\s*\\(\\s*\\)\\s*" . PHPTemplate::ECHO_OPTIONAL_END . PHPTemplate::OPTIONAL_STATEMENT_END . PHPTemplate::TEMPLATE_END . "/s", "{{ staticCall(\"\\1\", \"\\2\") }}", $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     return $tag;
 }
Esempio n. 4
0
 /**
  * @param string $tag
  * @return string
  */
 public function convert($tag)
 {
     $name = "Expression";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPTemplate::ECHO_BEGIN . PHPConverter::getExpressionRegex(true) . PHPTemplate::ECHO_OPTIONAL_END . PHPTemplate::OPTIONAL_STATEMENT_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $from = 1;
         return "{{ " . PHPConverter::convertExpression($matches, $from) . " }}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     $name = "Ternary operator call";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPTemplate::ECHO_BEGIN . PHPConverter::getTernaryOperatorExpressionRegex(true) . PHPTemplate::ECHO_OPTIONAL_END . PHPTemplate::OPTIONAL_STATEMENT_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $from = 1;
         return "{{ " . PHPConverter::convertTernaryOperatorExpression($matches, $from) . " }}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     $name = "Printf";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPConverter::getFunctionCallRegex(true) . PHPTemplate::OPTIONAL_STATEMENT_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $from = 1;
         return "{{ " . PHPConverter::convertFunctionCall($matches, $from) . " }}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     return $tag;
 }
 /**
  * @param string $tag
  * @return string
  */
 public function convert($tag)
 {
     $name = "Expression";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPConverter::getVariableRegex(true) . '\\s*=\\s*' . PHPConverter::getExpressionRegex(true) . PHPTemplate::OPTIONAL_STATEMENT_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $variable = PHPConverter::convertVariable($matches[1]);
         $from = 2;
         return "{% set " . $variable . " = " . PHPConverter::convertExpression($matches, $from) . " %}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     $name = "Ternary operator expression";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPConverter::getVariableRegex(true) . '\\s*=\\s*' . PHPConverter::getTernaryOperatorExpressionRegex(true) . PHPTemplate::OPTIONAL_STATEMENT_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $variable = PHPConverter::convertVariable($matches[1]);
         $from = 2;
         return "{% set " . $variable . " = " . PHPConverter::convertTernaryOperatorExpression($matches, $from) . " %}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     $name = "Postfix increase";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPConverter::getVariableRegex(true) . '\\s*\\+\\+\\s*' . PHPTemplate::OPTIONAL_STATEMENT_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $variable = PHPConverter::convertVariable($matches[1]);
         return "{% set {$variable} = {$variable} + 1 %}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     $name = "Prefix increase";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . '\\s*\\+\\+\\s*' . PHPConverter::getVariableRegex(true) . PHPTemplate::OPTIONAL_STATEMENT_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $from = 1;
         $variable = PHPConverter::convertVariableCall($matches, $from);
         return "{% set {$variable} = {$variable} + 1 %}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     $name = "Postfix decrease";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . PHPConverter::getVariableRegex(true) . '\\s*\\-\\-\\s*' . PHPTemplate::OPTIONAL_STATEMENT_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $variable = PHPConverter::convertVariable($matches[1]);
         return "{% set {$variable} = {$variable} - 1 %}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     $name = "Prefix decrease";
     $tag = preg_replace_callback("/" . PHPTemplate::TEMPLATE_START . '\\s*\\-\\-\\s*' . PHPConverter::getVariableRegex(true) . PHPTemplate::OPTIONAL_STATEMENT_END . PHPTemplate::TEMPLATE_END . "/s", function ($matches) {
         $variable = PHPConverter::convertVariable($matches[1]);
         return "{% set {$variable} = {$variable} - 1 %}";
     }, $tag, -1, $count);
     if (isset($this->conversionInfo[$name])) {
         $this->conversionInfo[$name] += $count;
     } else {
         $this->conversionInfo[$name] = 0;
     }
     if ($count !== 0) {
         return $tag;
     }
     return $tag;
 }