Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 4 | class __TwigTemplate_2fd5b29735c4f46f3af0c10dcdaafd7c8d11fecbb69d734eb926970e7db230b1 extends Twig_Template |
||
| 5 | { |
||
| 6 | public function __construct(Twig_Environment $env) |
||
| 7 | { |
||
| 8 | parent::__construct($env); |
||
| 9 | |||
| 10 | $this->parent = false; |
||
| 11 | |||
| 12 | $this->blocks = array( |
||
| 13 | 'title' => array($this, 'block_title'), |
||
| 14 | 'head' => array($this, 'block_head'), |
||
| 15 | 'html' => array($this, 'block_html'), |
||
| 16 | 'body_class' => array($this, 'block_body_class'), |
||
| 17 | 'page_id' => array($this, 'block_page_id'), |
||
| 18 | 'content' => array($this, 'block_content'), |
||
| 19 | ); |
||
| 20 | } |
||
| 21 | |||
| 22 | protected function doDisplay(array $context, array $blocks = array()) |
||
| 23 | { |
||
| 24 | // line 1 |
||
| 25 | echo "<!DOCTYPE html> |
||
| 26 | <html lang=\"en\"> |
||
| 27 | <head> |
||
| 28 | <meta charset=\"UTF-8\" /> |
||
| 29 | <meta name=\"robots\" content=\"index, follow, all\" /> |
||
| 30 | <title>"; |
||
| 31 | // line 6 |
||
| 32 | $this->displayBlock('title', $context, $blocks); |
||
| 33 | echo "</title> |
||
| 34 | |||
| 35 | "; |
||
| 36 | // line 8 |
||
| 37 | $this->displayBlock('head', $context, $blocks); |
||
| 38 | // line 20 |
||
| 39 | echo " |
||
| 40 | "; |
||
| 41 | // line 21 |
||
| 42 | if ($this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "favicon"), "method")) { |
||
| 43 | // line 22 |
||
| 44 | echo " <link rel=\"shortcut icon\" href=\""; |
||
| 45 | echo twig_escape_filter($this->env, $this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "favicon"), "method"), "html", null, true); |
||
| 46 | echo "\" /> |
||
| 47 | "; |
||
| 48 | } |
||
| 49 | // line 24 |
||
| 50 | echo " |
||
| 51 | "; |
||
| 52 | // line 25 |
||
| 53 | if ($this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "base_url"), "method")) { |
||
| 54 | // line 26 |
||
| 55 | $context['_parent'] = $context; |
||
| 56 | $context['_seq'] = twig_ensure_traversable($this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "versions", array())); |
||
| 57 | foreach ($context['_seq'] as $context["_key"] => $context["version"]) { |
||
| 58 | // line 27 |
||
| 59 | echo "<link rel=\"search\" |
||
| 60 | type=\"application/opensearchdescription+xml\" |
||
| 61 | href=\""; |
||
| 62 | // line 29 |
||
| 63 | echo twig_escape_filter($this->env, twig_replace_filter($this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "base_url"), "method"), array("%version%" => $context["version"])), "html", null, true); |
||
| 64 | echo "/opensearch.xml\" |
||
| 65 | title=\""; |
||
| 66 | // line 30 |
||
| 67 | echo twig_escape_filter($this->env, $this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "title"), "method"), "html", null, true); |
||
| 68 | echo " ("; |
||
| 69 | echo twig_escape_filter($this->env, $context["version"], "html", null, true); |
||
| 70 | echo ")\" /> |
||
| 71 | "; |
||
| 72 | } |
||
| 73 | $_parent = $context['_parent']; |
||
| 74 | unset($context['_seq'], $context['_iterated'], $context['_key'], $context['version'], $context['_parent'], $context['loop']); |
||
| 75 | $context = array_intersect_key($context, $_parent) + $_parent; |
||
| 76 | } |
||
| 77 | // line 33 |
||
| 78 | echo "</head> |
||
| 79 | |||
| 80 | "; |
||
| 81 | // line 35 |
||
| 82 | $this->displayBlock('html', $context, $blocks); |
||
| 83 | // line 40 |
||
| 84 | echo " |
||
| 85 | </html> |
||
| 86 | "; |
||
| 87 | } |
||
| 88 | |||
| 89 | // line 6 |
||
| 90 | public function block_title($context, array $blocks = array()) |
||
| 91 | { |
||
| 92 | echo twig_escape_filter($this->env, $this->getAttribute((isset($context["project"]) ? $context["project"] : $this->getContext($context, "project")), "config", array(0 => "title"), "method"), "html", null, true); |
||
| 93 | } |
||
| 94 | |||
| 95 | // line 8 |
||
| 96 | public function block_head($context, array $blocks = array()) |
||
| 97 | { |
||
| 98 | // line 9 |
||
| 99 | echo " <link rel=\"stylesheet\" type=\"text/css\" href=\""; |
||
| 100 | echo twig_escape_filter($this->env, $this->env->getExtension('sami')->pathForStaticFile($context, "css/bootstrap.min.css"), "html", null, true); |
||
| 101 | echo "\"> |
||
| 102 | <link rel=\"stylesheet\" type=\"text/css\" href=\""; |
||
| 103 | // line 10 |
||
| 104 | echo twig_escape_filter($this->env, $this->env->getExtension('sami')->pathForStaticFile($context, "css/bootstrap-theme.min.css"), "html", null, true); |
||
| 105 | echo "\"> |
||
| 106 | <link rel=\"stylesheet\" type=\"text/css\" href=\""; |
||
| 107 | // line 11 |
||
| 108 | echo twig_escape_filter($this->env, $this->env->getExtension('sami')->pathForStaticFile($context, "css/sami.css"), "html", null, true); |
||
| 109 | echo "\"> |
||
| 110 | <script src=\""; |
||
| 111 | // line 12 |
||
| 112 | echo twig_escape_filter($this->env, $this->env->getExtension('sami')->pathForStaticFile($context, "js/jquery-1.11.1.min.js"), "html", null, true); |
||
| 113 | echo "\"></script> |
||
| 114 | <script src=\""; |
||
| 115 | // line 13 |
||
| 116 | echo twig_escape_filter($this->env, $this->env->getExtension('sami')->pathForStaticFile($context, "js/bootstrap.min.js"), "html", null, true); |
||
| 117 | echo "\"></script> |
||
| 118 | <script src=\""; |
||
| 119 | // line 14 |
||
| 120 | echo twig_escape_filter($this->env, $this->env->getExtension('sami')->pathForStaticFile($context, "js/typeahead.min.js"), "html", null, true); |
||
| 121 | echo "\"></script> |
||
| 122 | <script src=\""; |
||
| 123 | // line 15 |
||
| 124 | echo twig_escape_filter($this->env, $this->env->getExtension('sami')->pathForStaticFile($context, "sami.js"), "html", null, true); |
||
| 125 | echo "\"></script> |
||
| 126 | <meta name=\"MobileOptimized\" content=\"width\"> |
||
| 127 | <meta name=\"HandheldFriendly\" content=\"true\"> |
||
| 128 | <meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1\"> |
||
| 129 | "; |
||
| 130 | } |
||
| 131 | |||
| 132 | // line 35 |
||
| 133 | public function block_html($context, array $blocks = array()) |
||
| 134 | { |
||
| 135 | // line 36 |
||
| 136 | echo " <body id=\""; |
||
| 137 | $this->displayBlock('body_class', $context, $blocks); |
||
| 138 | echo "\" data-name=\""; |
||
| 139 | $this->displayBlock('page_id', $context, $blocks); |
||
| 140 | echo "\" data-root-path=\""; |
||
| 141 | echo twig_escape_filter($this->env, (isset($context["root_path"]) ? $context["root_path"] : $this->getContext($context, "root_path")), "html", null, true); |
||
| 142 | echo "\"> |
||
| 143 | "; |
||
| 144 | // line 37 |
||
| 145 | $this->displayBlock('content', $context, $blocks); |
||
| 146 | // line 38 |
||
| 147 | echo " </body> |
||
| 148 | "; |
||
| 149 | } |
||
| 150 | |||
| 151 | // line 36 |
||
| 152 | public function block_body_class($context, array $blocks = array()) |
||
| 153 | { |
||
| 154 | echo ""; |
||
| 155 | } |
||
| 156 | |||
| 157 | public function block_page_id($context, array $blocks = array()) |
||
| 158 | { |
||
| 159 | echo ""; |
||
| 160 | } |
||
| 161 | |||
| 162 | // line 37 |
||
| 163 | public function block_content($context, array $blocks = array()) |
||
| 164 | { |
||
| 165 | echo ""; |
||
| 166 | } |
||
| 167 | |||
| 168 | public function getTemplateName() |
||
| 169 | { |
||
| 170 | return "layout/base.twig"; |
||
| 171 | } |
||
| 172 | |||
| 173 | public function isTraitable() |
||
| 174 | { |
||
| 175 | return false; |
||
| 176 | } |
||
| 177 | |||
| 178 | public function getDebugInfo() |
||
| 179 | { |
||
| 180 | return array ( 163 => 37, 152 => 36, 147 => 38, 145 => 37, 136 => 36, 133 => 35, 124 => 15, 120 => 14, 116 => 13, 112 => 12, 108 => 11, 104 => 10, 99 => 9, 96 => 8, 90 => 6, 84 => 40, 82 => 35, 78 => 33, 67 => 30, 63 => 29, 59 => 27, 55 => 26, 53 => 25, 50 => 24, 44 => 22, 42 => 21, 39 => 20, 37 => 8, 32 => 6, 25 => 1,); |
||
| 181 | } |
||
| 182 | } |
||
| 183 | /* <!DOCTYPE html>*/ |
||
| 225 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.