GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( c188f7...035d67 )
by Romain
05:21
created

block_page_content()   D

Complexity

Conditions 41
Paths 80

Size

Total Lines 119
Code Lines 45

Duplication

Lines 53
Ratio 44.54 %

Importance

Changes 0
Metric Value
dl 53
loc 119
rs 4.1818
c 0
b 0
f 0
cc 41
eloc 45
nc 80
nop 2

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/* class.twig */
4
class __TwigTemplate_1373a0924e16564e79f9cba7ce87feb91dde921516d40ff0ea35e47cc583926c extends Twig_Template
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
5
{
6
    public function __construct(Twig_Environment $env)
7
    {
8
        parent::__construct($env);
9
10
        // line 1
11
        $this->parent = $this->loadTemplate("layout/layout.twig", "class.twig", 1);
12
        $this->blocks = array(
13
            'title' => array($this, 'block_title'),
14
            'body_class' => array($this, 'block_body_class'),
15
            'page_id' => array($this, 'block_page_id'),
16
            'below_menu' => array($this, 'block_below_menu'),
17
            'page_content' => array($this, 'block_page_content'),
18
            'class_signature' => array($this, 'block_class_signature'),
19
            'method_signature' => array($this, 'block_method_signature'),
20
            'method_parameters_signature' => array($this, 'block_method_parameters_signature'),
21
            'parameters' => array($this, 'block_parameters'),
22
            'return' => array($this, 'block_return'),
23
            'exceptions' => array($this, 'block_exceptions'),
24
            'see' => array($this, 'block_see'),
25
            'constants' => array($this, 'block_constants'),
26
            'properties' => array($this, 'block_properties'),
27
            'methods' => array($this, 'block_methods'),
28
            'methods_details' => array($this, 'block_methods_details'),
29
            'method' => array($this, 'block_method'),
30
        );
31
    }
32
33
    protected function doGetParent(array $context)
34
    {
35
        return "layout/layout.twig";
0 ignored issues
show
Bug Best Practice introduced by
The return type of return 'layout/layout.twig'; (string) is incompatible with the return type of the parent method Twig_Template::doGetParent of type boolean.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
36
    }
37
38
    protected function doDisplay(array $context, array $blocks = array())
39
    {
40
        // line 2
41
        $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"] = $this->loadTemplate("macros.twig", "class.twig", 2);
42
        // line 1
43
        $this->parent->display($context, array_merge($this->blocks, $blocks));
0 ignored issues
show
Unused Code introduced by
The call to Twig_TemplateWrapper::display() has too many arguments starting with array_merge($this->blocks, $blocks).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
44
    }
45
46
    // line 3
47
    public function block_title($context, array $blocks = array())
48
    {
49
        echo (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 3, $this->getSourceContext()); })());
50
        echo " | ";
51
        $this->displayParentBlock("title", $context, $blocks);
52
    }
53
54
    // line 4
55
    public function block_body_class($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
56
    {
57
        echo "class";
58
    }
59
60
    // line 5
61
    public function block_page_id($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
62
    {
63
        echo twig_escape_filter($this->env, ("class:" . twig_replace_filter(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 5, $this->getSourceContext()); })()), "name", array()), array("\\" => "_"))), "html", null, true);
64
    }
65
66
    // line 7
67
    public function block_below_menu($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
68
    {
69
        // line 8
70
        echo "    ";
71
        if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 8, $this->getSourceContext()); })()), "namespace", array())) {
72
            // line 9
73
            echo "        <div class=\"namespace-breadcrumbs\">
74
            <ol class=\"breadcrumb\">
75
                <li><span class=\"label label-default\">";
76
            // line 11
77
            echo twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 11, $this->getSourceContext()); })()), "categoryName", array());
78
            echo "</span></li>
79
                ";
80
            // line 12
81
            echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_breadcrumbs(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 12, $this->getSourceContext()); })()), "namespace", array()));
82
            echo "
83
                <li>";
84
            // line 13
85
            echo twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 13, $this->getSourceContext()); })()), "shortname", array());
86
            echo "</li>
87
            </ol>
88
        </div>
89
    ";
90
        }
91
    }
92
93
    // line 19
94
    public function block_page_content($context, array $blocks = array())
95
    {
96
        // line 20
97
        echo "
98
    <div class=\"page-header\">
99
        <h1>
100
            ";
101
        // line 23
102
        echo twig_last($this->env, twig_split_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 23, $this->getSourceContext()); })()), "name", array()), "\\"));
103
        echo "
104
            ";
105
        // line 24
106
        echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_deprecated((isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 24, $this->getSourceContext()); })()));
107
        echo "
108
        </h1>
109
    </div>
110
111
    <p>";
112
        // line 28
113
        $this->displayBlock("class_signature", $context, $blocks);
114
        echo "</p>
115
116
    ";
117
        // line 30
118
        echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_deprecations((isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 30, $this->getSourceContext()); })()));
119
        echo "
120
121
    ";
122
        // line 32
123 View Code Duplication
        if ((twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 32, $this->getSourceContext()); })()), "shortdesc", array()) || twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 32, $this->getSourceContext()); })()), "longdesc", array()))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
124
            // line 33
125
            echo "        <div class=\"description\">
126
            ";
127
            // line 34
128
            if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 34, $this->getSourceContext()); })()), "shortdesc", array())) {
129
                // line 35
130
                echo "<p>";
131
                echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 35, $this->getSourceContext()); })()), "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 35, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
132
                echo "</p>";
133
            }
134
            // line 37
135
            echo "            ";
136
            if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 37, $this->getSourceContext()); })()), "longdesc", array())) {
137
                // line 38
138
                echo "<p>";
139
                echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 38, $this->getSourceContext()); })()), "longdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 38, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
140
                echo "</p>";
141
            }
142
            // line 40
143
            echo "        </div>
144
    ";
145
        }
146
        // line 42
147
        echo "
148
    ";
149
        // line 43
150 View Code Duplication
        if ((isset($context["traits"]) || array_key_exists("traits", $context) ? $context["traits"] : (function () { throw new Twig_Error_Runtime('Variable "traits" does not exist.', 43, $this->getSourceContext()); })())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
151
            // line 44
152
            echo "        <h2>Traits</h2>
153
154
        ";
155
            // line 46
156
            echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_render_classes((isset($context["traits"]) || array_key_exists("traits", $context) ? $context["traits"] : (function () { throw new Twig_Error_Runtime('Variable "traits" does not exist.', 46, $this->getSourceContext()); })()));
157
            echo "
158
    ";
159
        }
160
        // line 48
161
        echo "
162
    ";
163
        // line 49
164 View Code Duplication
        if ((isset($context["constants"]) || array_key_exists("constants", $context) ? $context["constants"] : (function () { throw new Twig_Error_Runtime('Variable "constants" does not exist.', 49, $this->getSourceContext()); })())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
165
            // line 50
166
            echo "        <h2>Constants</h2>
167
168
        ";
169
            // line 52
170
            $this->displayBlock("constants", $context, $blocks);
171
            echo "
172
    ";
173
        }
174
        // line 54
175
        echo "
176
    ";
177
        // line 55
178 View Code Duplication
        if ((isset($context["properties"]) || array_key_exists("properties", $context) ? $context["properties"] : (function () { throw new Twig_Error_Runtime('Variable "properties" does not exist.', 55, $this->getSourceContext()); })())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
179
            // line 56
180
            echo "        <h2>Properties</h2>
181
182
        ";
183
            // line 58
184
            $this->displayBlock("properties", $context, $blocks);
185
            echo "
186
    ";
187
        }
188
        // line 60
189
        echo "
190
    ";
191
        // line 61
192
        if ((isset($context["methods"]) || array_key_exists("methods", $context) ? $context["methods"] : (function () { throw new Twig_Error_Runtime('Variable "methods" does not exist.', 61, $this->getSourceContext()); })())) {
193
            // line 62
194
            echo "        <h2>Methods</h2>
195
196
        ";
197
            // line 64
198
            $this->displayBlock("methods", $context, $blocks);
199
            echo "
200
201
        <h2>Details</h2>
202
203
        ";
204
            // line 68
205
            $this->displayBlock("methods_details", $context, $blocks);
206
            echo "
207
    ";
208
        }
209
        // line 70
210
        echo "
211
";
212
    }
213
214
    // line 73
215
    public function block_class_signature($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
216
    {
217
        // line 74
218
        if (( !twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 74, $this->getSourceContext()); })()), "interface", array()) && twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 74, $this->getSourceContext()); })()), "abstract", array()))) {
219
            echo "abstract ";
220
        }
221
        // line 75
222
        echo "    ";
223
        echo twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 75, $this->getSourceContext()); })()), "categoryName", array());
224
        echo "
225
    <strong>";
226
        // line 76
227
        echo twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 76, $this->getSourceContext()); })()), "shortname", array());
228
        echo "</strong>";
229
        // line 77
230 View Code Duplication
        if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 77, $this->getSourceContext()); })()), "parent", array())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
231
            // line 78
232
            echo "        extends ";
233
            echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_class_link(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 78, $this->getSourceContext()); })()), "parent", array()));
234
        }
235
        // line 80
236
        if ((twig_length_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 80, $this->getSourceContext()); })()), "interfaces", array())) > 0)) {
237
            // line 81
238
            echo "        implements
239
        ";
240
            // line 82
241
            $context['_parent'] = $context;
242
            $context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 82, $this->getSourceContext()); })()), "interfaces", array()));
243
            $context['loop'] = array(
244
              'parent' => $context['_parent'],
245
              'index0' => 0,
246
              'index'  => 1,
247
              'first'  => true,
248
            );
249 View Code Duplication
            if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof Countable)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
250
                $length = count($context['_seq']);
251
                $context['loop']['revindex0'] = $length - 1;
252
                $context['loop']['revindex'] = $length;
253
                $context['loop']['length'] = $length;
254
                $context['loop']['last'] = 1 === $length;
255
            }
256
            foreach ($context['_seq'] as $context["_key"] => $context["interface"]) {
0 ignored issues
show
Bug introduced by
The expression $context['_seq'] of type array|object<Countable> is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
257
                // line 83
258
                echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_class_link($context["interface"]);
259
                // line 84
260
                if ( !twig_get_attribute($this->env, $this->getSourceContext(), $context["loop"], "last", array())) {
261
                    echo ", ";
262
                }
263
                ++$context['loop']['index0'];
264
                ++$context['loop']['index'];
265
                $context['loop']['first'] = false;
266 View Code Duplication
                if (isset($context['loop']['length'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
267
                    --$context['loop']['revindex0'];
268
                    --$context['loop']['revindex'];
269
                    $context['loop']['last'] = 0 === $context['loop']['revindex0'];
270
                }
271
            }
272
            $_parent = $context['_parent'];
273
            unset($context['_seq'], $context['_iterated'], $context['_key'], $context['interface'], $context['_parent'], $context['loop']);
274
            $context = array_intersect_key($context, $_parent) + $_parent;
275
        }
276
        // line 87
277
        echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_source_link((isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 87, $this->getSourceContext()); })()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 87, $this->getSourceContext()); })()));
278
        echo "
279
";
280
    }
281
282
    // line 90
283
    public function block_method_signature($context, array $blocks = array())
284
    {
285
        // line 91
286 View Code Duplication
        if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 91, $this->getSourceContext()); })()), "final", array())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
287
            echo "final";
288
        }
289
        // line 92
290
        echo "    ";
291 View Code Duplication
        if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 92, $this->getSourceContext()); })()), "abstract", array())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
292
            echo "abstract";
293
        }
294
        // line 93
295
        echo "    ";
296 View Code Duplication
        if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 93, $this->getSourceContext()); })()), "static", array())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
297
            echo "static";
298
        }
299
        // line 94
300
        echo "    ";
301 View Code Duplication
        if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 94, $this->getSourceContext()); })()), "protected", array())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
302
            echo "protected";
303
        }
304
        // line 95
305
        echo "    ";
306 View Code Duplication
        if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 95, $this->getSourceContext()); })()), "private", array())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
307
            echo "private";
308
        }
309
        // line 96
310
        echo "    ";
311
        echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_hint_link(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 96, $this->getSourceContext()); })()), "hint", array()));
312
        echo "
313
    <strong>";
314
        // line 97
315
        echo twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 97, $this->getSourceContext()); })()), "name", array());
316
        echo "</strong>";
317
        $this->displayBlock("method_parameters_signature", $context, $blocks);
318
    }
319
320
    // line 100
321
    public function block_method_parameters_signature($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
322
    {
323
        // line 101
324
        $context["__internal_e5526c505280ad0bbf95d58362fb9bb28353f075e956801d475b1e1d91892a94"] = $this->loadTemplate("macros.twig", "class.twig", 101);
325
        // line 102
326
        echo $context["__internal_e5526c505280ad0bbf95d58362fb9bb28353f075e956801d475b1e1d91892a94"]->macro_method_parameters_signature((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 102, $this->getSourceContext()); })()));
327
        echo "
328
    ";
329
        // line 103
330
        echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_deprecated((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 103, $this->getSourceContext()); })()));
331
    }
332
333
    // line 106
334
    public function block_parameters($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
335
    {
336
        // line 107
337
        echo "    <table class=\"table table-condensed\">
338
        ";
339
        // line 108
340
        $context['_parent'] = $context;
341
        $context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 108, $this->getSourceContext()); })()), "parameters", array()));
342
        foreach ($context['_seq'] as $context["_key"] => $context["parameter"]) {
343
            // line 109
344
            echo "            <tr>
345
                <td>";
346
            // line 110
347 View Code Duplication
            if (twig_get_attribute($this->env, $this->getSourceContext(), $context["parameter"], "hint", array())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
348
                echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_hint_link(twig_get_attribute($this->env, $this->getSourceContext(), $context["parameter"], "hint", array()));
349
            }
350
            echo "</td>
351
                <td>\$";
352
            // line 111
353
            echo twig_get_attribute($this->env, $this->getSourceContext(), $context["parameter"], "name", array());
354
            echo "</td>
355
                <td>";
356
            // line 112
357
            echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), $context["parameter"], "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 112, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
358
            echo "</td>
359
            </tr>
360
        ";
361
        }
362
        $_parent = $context['_parent'];
363
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['parameter'], $context['_parent'], $context['loop']);
364
        $context = array_intersect_key($context, $_parent) + $_parent;
0 ignored issues
show
Unused Code introduced by
$context is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
365
        // line 115
366
        echo "    </table>
367
";
368
    }
369
370
    // line 118
371
    public function block_return($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
372
    {
373
        // line 119
374
        echo "    <table class=\"table table-condensed\">
375
        <tr>
376
            <td>";
377
        // line 121
378
        echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_hint_link(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 121, $this->getSourceContext()); })()), "hint", array()));
379
        echo "</td>
380
            <td>";
381
        // line 122
382
        echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 122, $this->getSourceContext()); })()), "hintDesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 122, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
383
        echo "</td>
384
        </tr>
385
    </table>
386
";
387
    }
388
389
    // line 127
390
    public function block_exceptions($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
391
    {
392
        // line 128
393
        echo "    <table class=\"table table-condensed\">
394
        ";
395
        // line 129
396
        $context['_parent'] = $context;
397
        $context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 129, $this->getSourceContext()); })()), "exceptions", array()));
398
        foreach ($context['_seq'] as $context["_key"] => $context["exception"]) {
399
            // line 130
400
            echo "            <tr>
401
                <td>";
402
            // line 131
403
            echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_class_link(twig_get_attribute($this->env, $this->getSourceContext(), $context["exception"], 0, array(), "array"));
404
            echo "</td>
405
                <td>";
406
            // line 132
407
            echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), $context["exception"], 1, array(), "array"), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 132, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
408
            echo "</td>
409
            </tr>
410
        ";
411
        }
412
        $_parent = $context['_parent'];
413
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['exception'], $context['_parent'], $context['loop']);
414
        $context = array_intersect_key($context, $_parent) + $_parent;
0 ignored issues
show
Unused Code introduced by
$context is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
415
        // line 135
416
        echo "    </table>
417
";
418
    }
419
420
    // line 138
421
    public function block_see($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
422
    {
423
        // line 139
424
        echo "    <table class=\"table table-condensed\">
425
        ";
426
        // line 140
427
        $context['_parent'] = $context;
428
        $context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 140, $this->getSourceContext()); })()), "tags", array(0 => "see"), "method"));
429 View Code Duplication
        foreach ($context['_seq'] as $context["_key"] => $context["tag"]) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
430
            // line 141
431
            echo "            <tr>
432
                <td>";
433
            // line 142
434
            echo twig_get_attribute($this->env, $this->getSourceContext(), $context["tag"], 0, array(), "array");
435
            echo "</td>
436
                <td>";
437
            // line 143
438
            echo twig_join_filter(twig_slice($this->env, $context["tag"], 1, null), " ");
0 ignored issues
show
Bug introduced by
It seems like twig_slice($this->env, $context['tag'], 1, null) targeting twig_slice() can also be of type string; however, twig_join_filter() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
439
            echo "</td>
440
            </tr>
441
        ";
442
        }
443
        $_parent = $context['_parent'];
444
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['tag'], $context['_parent'], $context['loop']);
445
        $context = array_intersect_key($context, $_parent) + $_parent;
0 ignored issues
show
Unused Code introduced by
$context is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
446
        // line 146
447
        echo "    </table>
448
";
449
    }
450
451
    // line 149
452
    public function block_constants($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
453
    {
454
        // line 150
455
        echo "    <table class=\"table table-condensed\">
456
        ";
457
        // line 151
458
        $context['_parent'] = $context;
459
        $context['_seq'] = twig_ensure_traversable((isset($context["constants"]) || array_key_exists("constants", $context) ? $context["constants"] : (function () { throw new Twig_Error_Runtime('Variable "constants" does not exist.', 151, $this->getSourceContext()); })()));
460
        foreach ($context['_seq'] as $context["_key"] => $context["constant"]) {
461
            // line 152
462
            echo "            <tr>
463
                <td>";
464
            // line 153
465
            echo twig_get_attribute($this->env, $this->getSourceContext(), $context["constant"], "name", array());
466
            echo "</td>
467
                <td class=\"last\">
468
                    <p><em>";
469
            // line 155
470
            echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), $context["constant"], "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 155, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
471
            echo "</em></p>
472
                    <p>";
473
            // line 156
474
            echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), $context["constant"], "longdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 156, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
475
            echo "</p>
476
                </td>
477
            </tr>
478
        ";
479
        }
480
        $_parent = $context['_parent'];
481
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['constant'], $context['_parent'], $context['loop']);
482
        $context = array_intersect_key($context, $_parent) + $_parent;
0 ignored issues
show
Unused Code introduced by
$context is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
483
        // line 160
484
        echo "    </table>
485
";
486
    }
487
488
    // line 163
489
    public function block_properties($context, array $blocks = array())
0 ignored issues
show
Unused Code introduced by
The parameter $blocks is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
490
    {
491
        // line 164
492
        echo "    <table class=\"table table-condensed\">
493
        ";
494
        // line 165
495
        $context['_parent'] = $context;
496
        $context['_seq'] = twig_ensure_traversable((isset($context["properties"]) || array_key_exists("properties", $context) ? $context["properties"] : (function () { throw new Twig_Error_Runtime('Variable "properties" does not exist.', 165, $this->getSourceContext()); })()));
497
        foreach ($context['_seq'] as $context["_key"] => $context["property"]) {
498
            // line 166
499
            echo "            <tr>
500
                <td class=\"type\" id=\"property_";
501
            // line 167
502
            echo twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "name", array());
503
            echo "\">
504
                    ";
505
            // line 168
506
            if (twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "static", array())) {
507
                echo "static";
508
            }
509
            // line 169
510
            echo "                    ";
511
            if (twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "protected", array())) {
512
                echo "protected";
513
            }
514
            // line 170
515
            echo "                    ";
516
            if (twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "private", array())) {
517
                echo "private";
518
            }
519
            // line 171
520
            echo "                    ";
521
            echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_hint_link(twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "hint", array()));
522
            echo "
523
                </td>
524
                <td>\$";
525
            // line 173
526
            echo twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "name", array());
527
            echo "</td>
528
                <td class=\"last\">";
529
            // line 174
530
            echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 174, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
531
            echo "</td>
532
                <td>";
533
            // line 176
534 View Code Duplication
            if ( !(twig_get_attribute($this->env, $this->getSourceContext(), $context["property"], "class", array()) === (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 176, $this->getSourceContext()); })()))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
535
                // line 177
536
                echo "<small>from&nbsp;";
537
                echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_property_link($context["property"], false, true);
538
                echo "</small>";
539
            }
540
            // line 179
541
            echo "</td>
542
            </tr>
543
        ";
544
        }
545
        $_parent = $context['_parent'];
546
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['property'], $context['_parent'], $context['loop']);
547
        $context = array_intersect_key($context, $_parent) + $_parent;
0 ignored issues
show
Unused Code introduced by
$context is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
548
        // line 182
549
        echo "    </table>
550
";
551
    }
552
553
    // line 185
554
    public function block_methods($context, array $blocks = array())
555
    {
556
        // line 186
557
        echo "    <div class=\"container-fluid underlined\">
558
        ";
559
        // line 187
560
        $context['_parent'] = $context;
561
        $context['_seq'] = twig_ensure_traversable((isset($context["methods"]) || array_key_exists("methods", $context) ? $context["methods"] : (function () { throw new Twig_Error_Runtime('Variable "methods" does not exist.', 187, $this->getSourceContext()); })()));
562
        $context['loop'] = array(
563
          'parent' => $context['_parent'],
564
          'index0' => 0,
565
          'index'  => 1,
566
          'first'  => true,
567
        );
568 View Code Duplication
        if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof Countable)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
569
            $length = count($context['_seq']);
570
            $context['loop']['revindex0'] = $length - 1;
571
            $context['loop']['revindex'] = $length;
572
            $context['loop']['length'] = $length;
573
            $context['loop']['last'] = 1 === $length;
574
        }
575
        foreach ($context['_seq'] as $context["_key"] => $context["method"]) {
0 ignored issues
show
Bug introduced by
The expression $context['_seq'] of type array|object<Countable> is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
576
            // line 188
577
            echo "            <div class=\"row\">
578
                <div class=\"col-md-2 type\">
579
                    ";
580
            // line 190
581
            if (twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "static", array())) {
582
                echo "static&nbsp;";
583
            }
584
            echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_hint_link(twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "hint", array()));
585
            echo "
586
                </div>
587
                <div class=\"col-md-8 type\">
588
                    <a href=\"#method_";
589
            // line 193
590
            echo twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "name", array());
591
            echo "\">";
592
            echo twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "name", array());
593
            echo "</a>";
594
            $this->displayBlock("method_parameters_signature", $context, $blocks);
595
            echo "
596
                    ";
597
            // line 194
598 View Code Duplication
            if ( !twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "shortdesc", array())) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
599
                // line 195
600
                echo "                        <p class=\"no-description\">No description</p>
601
                    ";
602
            } else {
603
                // line 197
604
                echo "                        <p>";
605
                echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 197, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
606
                echo "</p>";
607
            }
608
            // line 199
609
            echo "                </div>
610
                <div class=\"col-md-2\">";
611
            // line 201
612 View Code Duplication
            if ( !(twig_get_attribute($this->env, $this->getSourceContext(), $context["method"], "class", array()) === (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 201, $this->getSourceContext()); })()))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
613
                // line 202
614
                echo "<small>from&nbsp;";
615
                echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_method_link($context["method"], false, true);
616
                echo "</small>";
617
            }
618
            // line 204
619
            echo "</div>
620
            </div>
621
        ";
622
            ++$context['loop']['index0'];
623
            ++$context['loop']['index'];
624
            $context['loop']['first'] = false;
625 View Code Duplication
            if (isset($context['loop']['length'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
626
                --$context['loop']['revindex0'];
627
                --$context['loop']['revindex'];
628
                $context['loop']['last'] = 0 === $context['loop']['revindex0'];
629
            }
630
        }
631
        $_parent = $context['_parent'];
632
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['method'], $context['_parent'], $context['loop']);
633
        $context = array_intersect_key($context, $_parent) + $_parent;
0 ignored issues
show
Unused Code introduced by
$context is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
634
        // line 207
635
        echo "    </div>
636
";
637
    }
638
639
    // line 210
640
    public function block_methods_details($context, array $blocks = array())
641
    {
642
        // line 211
643
        echo "    <div id=\"method-details\">
644
        ";
645
        // line 212
646
        $context['_parent'] = $context;
647
        $context['_seq'] = twig_ensure_traversable((isset($context["methods"]) || array_key_exists("methods", $context) ? $context["methods"] : (function () { throw new Twig_Error_Runtime('Variable "methods" does not exist.', 212, $this->getSourceContext()); })()));
648
        $context['loop'] = array(
649
          'parent' => $context['_parent'],
650
          'index0' => 0,
651
          'index'  => 1,
652
          'first'  => true,
653
        );
654 View Code Duplication
        if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof Countable)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
655
            $length = count($context['_seq']);
656
            $context['loop']['revindex0'] = $length - 1;
657
            $context['loop']['revindex'] = $length;
658
            $context['loop']['length'] = $length;
659
            $context['loop']['last'] = 1 === $length;
660
        }
661
        foreach ($context['_seq'] as $context["_key"] => $context["method"]) {
0 ignored issues
show
Bug introduced by
The expression $context['_seq'] of type array|object<Countable> is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
662
            // line 213
663
            echo "            <div class=\"method-item\">
664
                ";
665
            // line 214
666
            $this->displayBlock("method", $context, $blocks);
667
            echo "
668
            </div>
669
        ";
670
            ++$context['loop']['index0'];
671
            ++$context['loop']['index'];
672
            $context['loop']['first'] = false;
673 View Code Duplication
            if (isset($context['loop']['length'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
674
                --$context['loop']['revindex0'];
675
                --$context['loop']['revindex'];
676
                $context['loop']['last'] = 0 === $context['loop']['revindex0'];
677
            }
678
        }
679
        $_parent = $context['_parent'];
680
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['method'], $context['_parent'], $context['loop']);
681
        $context = array_intersect_key($context, $_parent) + $_parent;
0 ignored issues
show
Unused Code introduced by
$context is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
682
        // line 217
683
        echo "    </div>
684
";
685
    }
686
687
    // line 220
688
    public function block_method($context, array $blocks = array())
689
    {
690
        // line 221
691
        echo "    <h3 id=\"method_";
692
        echo twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 221, $this->getSourceContext()); })()), "name", array());
693
        echo "\">
694
        <div class=\"location\">";
695
        // line 222
696
        if ( !(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 222, $this->getSourceContext()); })()), "class", array()) === (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 222, $this->getSourceContext()); })()))) {
697
            echo "in ";
698
            echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_method_link((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 222, $this->getSourceContext()); })()), false, true);
699
            echo " ";
700
        }
701
        echo "at ";
702
        echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_method_source_link((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 222, $this->getSourceContext()); })()));
703
        echo "</div>
704
        <code>";
705
        // line 223
706
        $this->displayBlock("method_signature", $context, $blocks);
707
        echo "</code>
708
    </h3>
709
    <div class=\"details\">
710
        ";
711
        // line 226
712
        echo $context["__internal_44e5e6177e45d071724fe0d806624d3473537ea7355a32a2b1910210ba605d22"]->macro_deprecations((isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 226, $this->getSourceContext()); })()));
713
        echo "
714
715
        ";
716
        // line 228
717
        if ((twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 228, $this->getSourceContext()); })()), "shortdesc", array()) || twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 228, $this->getSourceContext()); })()), "longdesc", array()))) {
718
            // line 229
719
            echo "            <div class=\"method-description\">
720
                ";
721
            // line 230
722 View Code Duplication
            if (( !twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 230, $this->getSourceContext()); })()), "shortdesc", array()) &&  !twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 230, $this->getSourceContext()); })()), "longdesc", array()))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
723
                // line 231
724
                echo "                    <p class=\"no-description\">No description</p>
725
                ";
726
            } else {
727
                // line 233
728
                echo "                    ";
729
                if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 233, $this->getSourceContext()); })()), "shortdesc", array())) {
730
                    // line 234
731
                    echo "<p>";
732
                    echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 234, $this->getSourceContext()); })()), "shortdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 234, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
733
                    echo "</p>";
734
                }
735
                // line 236
736
                echo "                    ";
737
                if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 236, $this->getSourceContext()); })()), "longdesc", array())) {
738
                    // line 237
739
                    echo "<p>";
740
                    echo $this->env->getExtension('Sami\Renderer\TwigExtension')->parseDesc($context, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 237, $this->getSourceContext()); })()), "longdesc", array()), (isset($context["class"]) || array_key_exists("class", $context) ? $context["class"] : (function () { throw new Twig_Error_Runtime('Variable "class" does not exist.', 237, $this->getSourceContext()); })()));
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Twig_ExtensionInterface as the method parseDesc() does only exist in the following implementations of said interface: Sami\Renderer\TwigExtension.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
741
                    echo "</p>";
742
                }
743
            }
744
            // line 240
745
            echo "            </div>
746
        ";
747
        }
748
        // line 242
749
        echo "        <div class=\"tags\">
750
            ";
751
        // line 243
752
        if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 243, $this->getSourceContext()); })()), "parameters", array())) {
753
            // line 244
754
            echo "                <h4>Parameters</h4>
755
756
                ";
757
            // line 246
758
            $this->displayBlock("parameters", $context, $blocks);
759
            echo "
760
            ";
761
        }
762
        // line 248
763
        echo "
764
            ";
765
        // line 249
766 View Code Duplication
        if ((twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 249, $this->getSourceContext()); })()), "hintDesc", array()) || twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 249, $this->getSourceContext()); })()), "hint", array()))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
767
            // line 250
768
            echo "                <h4>Return Value</h4>
769
770
                ";
771
            // line 252
772
            $this->displayBlock("return", $context, $blocks);
773
            echo "
774
            ";
775
        }
776
        // line 254
777
        echo "
778
            ";
779
        // line 255
780
        if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 255, $this->getSourceContext()); })()), "exceptions", array())) {
781
            // line 256
782
            echo "                <h4>Exceptions</h4>
783
784
                ";
785
            // line 258
786
            $this->displayBlock("exceptions", $context, $blocks);
787
            echo "
788
            ";
789
        }
790
        // line 260
791
        echo "
792
            ";
793
        // line 261
794
        if (twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["method"]) || array_key_exists("method", $context) ? $context["method"] : (function () { throw new Twig_Error_Runtime('Variable "method" does not exist.', 261, $this->getSourceContext()); })()), "tags", array(0 => "see"), "method")) {
795
            // line 262
796
            echo "                <h4>See also</h4>
797
798
                ";
799
            // line 264
800
            $this->displayBlock("see", $context, $blocks);
801
            echo "
802
            ";
803
        }
804
        // line 266
805
        echo "        </div>
806
    </div>
807
";
808
    }
809
810
    public function getTemplateName()
811
    {
812
        return "class.twig";
813
    }
814
815
    public function isTraitable()
816
    {
817
        return false;
818
    }
819
820
    public function getDebugInfo()
821
    {
822
        return array (  805 => 266,  800 => 264,  796 => 262,  794 => 261,  791 => 260,  786 => 258,  782 => 256,  780 => 255,  777 => 254,  772 => 252,  768 => 250,  766 => 249,  763 => 248,  758 => 246,  754 => 244,  752 => 243,  749 => 242,  745 => 240,  739 => 237,  736 => 236,  731 => 234,  728 => 233,  724 => 231,  722 => 230,  719 => 229,  717 => 228,  712 => 226,  706 => 223,  696 => 222,  691 => 221,  688 => 220,  683 => 217,  666 => 214,  663 => 213,  646 => 212,  643 => 211,  640 => 210,  635 => 207,  619 => 204,  614 => 202,  612 => 201,  609 => 199,  604 => 197,  600 => 195,  598 => 194,  590 => 193,  581 => 190,  577 => 188,  560 => 187,  557 => 186,  554 => 185,  549 => 182,  541 => 179,  536 => 177,  534 => 176,  530 => 174,  526 => 173,  520 => 171,  515 => 170,  510 => 169,  506 => 168,  502 => 167,  499 => 166,  495 => 165,  492 => 164,  489 => 163,  484 => 160,  474 => 156,  470 => 155,  465 => 153,  462 => 152,  458 => 151,  455 => 150,  452 => 149,  447 => 146,  438 => 143,  434 => 142,  431 => 141,  427 => 140,  424 => 139,  421 => 138,  416 => 135,  407 => 132,  403 => 131,  400 => 130,  396 => 129,  393 => 128,  390 => 127,  382 => 122,  378 => 121,  374 => 119,  371 => 118,  366 => 115,  357 => 112,  353 => 111,  347 => 110,  344 => 109,  340 => 108,  337 => 107,  334 => 106,  330 => 103,  326 => 102,  324 => 101,  321 => 100,  315 => 97,  310 => 96,  305 => 95,  300 => 94,  295 => 93,  290 => 92,  286 => 91,  283 => 90,  277 => 87,  260 => 84,  258 => 83,  241 => 82,  238 => 81,  236 => 80,  232 => 78,  230 => 77,  227 => 76,  222 => 75,  218 => 74,  215 => 73,  210 => 70,  205 => 68,  198 => 64,  194 => 62,  192 => 61,  189 => 60,  184 => 58,  180 => 56,  178 => 55,  175 => 54,  170 => 52,  166 => 50,  164 => 49,  161 => 48,  156 => 46,  152 => 44,  150 => 43,  147 => 42,  143 => 40,  138 => 38,  135 => 37,  130 => 35,  128 => 34,  125 => 33,  123 => 32,  118 => 30,  113 => 28,  106 => 24,  102 => 23,  97 => 20,  94 => 19,  85 => 13,  81 => 12,  77 => 11,  73 => 9,  70 => 8,  67 => 7,  61 => 5,  55 => 4,  47 => 3,  43 => 1,  41 => 2,  11 => 1,);
823
    }
824
825
    public function getSourceContext()
826
    {
827
        return new Twig_Source("{% extends \"layout/layout.twig\" %}
828
{% from \"macros.twig\" import render_classes, breadcrumbs, namespace_link, class_link, property_link, method_link, hint_link, source_link, method_source_link, deprecated, deprecations %}
829
{% block title %}{{ class|raw }} | {{ parent() }}{% endblock %}
830
{% block body_class 'class' %}
831
{% block page_id 'class:' ~ (class.name|replace({'\\\\': '_'})) %}
832
833
{% block below_menu %}
834
    {% if class.namespace %}
835
        <div class=\"namespace-breadcrumbs\">
836
            <ol class=\"breadcrumb\">
837
                <li><span class=\"label label-default\">{{ class.categoryName|raw }}</span></li>
838
                {{ breadcrumbs(class.namespace) }}
839
                <li>{{ class.shortname|raw }}</li>
840
            </ol>
841
        </div>
842
    {% endif %}
843
{% endblock %}
844
845
{% block page_content %}
846
847
    <div class=\"page-header\">
848
        <h1>
849
            {{ class.name|split('\\\\')|last|raw }}
850
            {{ deprecated(class) }}
851
        </h1>
852
    </div>
853
854
    <p>{{ block('class_signature') }}</p>
855
856
    {{ deprecations(class) }}
857
858
    {% if class.shortdesc or class.longdesc %}
859
        <div class=\"description\">
860
            {% if class.shortdesc -%}
861
                <p>{{ class.shortdesc|desc(class) }}</p>
862
            {%- endif %}
863
            {% if class.longdesc -%}
864
                <p>{{ class.longdesc|desc(class) }}</p>
865
            {%- endif %}
866
        </div>
867
    {% endif %}
868
869
    {% if traits %}
870
        <h2>Traits</h2>
871
872
        {{ render_classes(traits) }}
873
    {% endif %}
874
875
    {% if constants %}
876
        <h2>Constants</h2>
877
878
        {{ block('constants') }}
879
    {% endif %}
880
881
    {% if properties %}
882
        <h2>Properties</h2>
883
884
        {{ block('properties') }}
885
    {% endif %}
886
887
    {% if methods %}
888
        <h2>Methods</h2>
889
890
        {{ block('methods') }}
891
892
        <h2>Details</h2>
893
894
        {{ block('methods_details') }}
895
    {% endif %}
896
897
{% endblock %}
898
899
{% block class_signature -%}
900
    {% if not class.interface and class.abstract %}abstract {% endif %}
901
    {{ class.categoryName|raw }}
902
    <strong>{{ class.shortname|raw }}</strong>
903
    {%- if class.parent %}
904
        extends {{ class_link(class.parent) }}
905
    {%- endif %}
906
    {%- if class.interfaces|length > 0 %}
907
        implements
908
        {% for interface in class.interfaces %}
909
            {{- class_link(interface) }}
910
            {%- if not loop.last %}, {% endif %}
911
        {%- endfor %}
912
    {%- endif %}
913
    {{- source_link(project, class) }}
914
{% endblock %}
915
916
{% block method_signature -%}
917
    {% if method.final %}final{% endif %}
918
    {% if method.abstract %}abstract{% endif %}
919
    {% if method.static %}static{% endif %}
920
    {% if method.protected %}protected{% endif %}
921
    {% if method.private %}private{% endif %}
922
    {{ hint_link(method.hint) }}
923
    <strong>{{ method.name|raw }}</strong>{{ block('method_parameters_signature') }}
924
{%- endblock %}
925
926
{% block method_parameters_signature -%}
927
    {%- from \"macros.twig\" import method_parameters_signature -%}
928
    {{ method_parameters_signature(method) }}
929
    {{ deprecated(method) }}
930
{%- endblock %}
931
932
{% block parameters %}
933
    <table class=\"table table-condensed\">
934
        {% for parameter in method.parameters %}
935
            <tr>
936
                <td>{% if parameter.hint %}{{ hint_link(parameter.hint) }}{% endif %}</td>
937
                <td>\${{ parameter.name|raw }}</td>
938
                <td>{{ parameter.shortdesc|desc(class) }}</td>
939
            </tr>
940
        {% endfor %}
941
    </table>
942
{% endblock %}
943
944
{% block return %}
945
    <table class=\"table table-condensed\">
946
        <tr>
947
            <td>{{ hint_link(method.hint) }}</td>
948
            <td>{{ method.hintDesc|desc(class) }}</td>
949
        </tr>
950
    </table>
951
{% endblock %}
952
953
{% block exceptions %}
954
    <table class=\"table table-condensed\">
955
        {% for exception in method.exceptions %}
956
            <tr>
957
                <td>{{ class_link(exception[0]) }}</td>
958
                <td>{{ exception[1]|desc(class) }}</td>
959
            </tr>
960
        {% endfor %}
961
    </table>
962
{% endblock %}
963
964
{% block see %}
965
    <table class=\"table table-condensed\">
966
        {% for tag in method.tags('see') %}
967
            <tr>
968
                <td>{{ tag[0]|raw }}</td>
969
                <td>{{ tag[1:]|join(' ')|raw }}</td>
970
            </tr>
971
        {% endfor %}
972
    </table>
973
{% endblock %}
974
975
{% block constants %}
976
    <table class=\"table table-condensed\">
977
        {% for constant in constants %}
978
            <tr>
979
                <td>{{ constant.name|raw }}</td>
980
                <td class=\"last\">
981
                    <p><em>{{ constant.shortdesc|desc(class) }}</em></p>
982
                    <p>{{ constant.longdesc|desc(class) }}</p>
983
                </td>
984
            </tr>
985
        {% endfor %}
986
    </table>
987
{% endblock %}
988
989
{% block properties %}
990
    <table class=\"table table-condensed\">
991
        {% for property in properties %}
992
            <tr>
993
                <td class=\"type\" id=\"property_{{ property.name|raw }}\">
994
                    {% if property.static %}static{% endif %}
995
                    {% if property.protected %}protected{% endif %}
996
                    {% if property.private %}private{% endif %}
997
                    {{ hint_link(property.hint) }}
998
                </td>
999
                <td>\${{ property.name|raw }}</td>
1000
                <td class=\"last\">{{ property.shortdesc|desc(class) }}</td>
1001
                <td>
1002
                    {%- if property.class is not same as(class) -%}
1003
                        <small>from&nbsp;{{ property_link(property, false, true) }}</small>
1004
                    {%- endif -%}
1005
                </td>
1006
            </tr>
1007
        {% endfor %}
1008
    </table>
1009
{% endblock %}
1010
1011
{% block methods %}
1012
    <div class=\"container-fluid underlined\">
1013
        {% for method in methods %}
1014
            <div class=\"row\">
1015
                <div class=\"col-md-2 type\">
1016
                    {% if method.static %}static&nbsp;{% endif %}{{ hint_link(method.hint) }}
1017
                </div>
1018
                <div class=\"col-md-8 type\">
1019
                    <a href=\"#method_{{ method.name|raw }}\">{{ method.name|raw }}</a>{{ block('method_parameters_signature') }}
1020
                    {% if not method.shortdesc %}
1021
                        <p class=\"no-description\">No description</p>
1022
                    {% else %}
1023
                        <p>{{ method.shortdesc|desc(class) }}</p>
1024
                    {%- endif %}
1025
                </div>
1026
                <div class=\"col-md-2\">
1027
                    {%- if method.class is not same as(class) -%}
1028
                        <small>from&nbsp;{{ method_link(method, false, true) }}</small>
1029
                    {%- endif -%}
1030
                </div>
1031
            </div>
1032
        {% endfor %}
1033
    </div>
1034
{% endblock %}
1035
1036
{% block methods_details %}
1037
    <div id=\"method-details\">
1038
        {% for method in methods %}
1039
            <div class=\"method-item\">
1040
                {{ block('method') }}
1041
            </div>
1042
        {% endfor %}
1043
    </div>
1044
{% endblock %}
1045
1046
{% block method %}
1047
    <h3 id=\"method_{{ method.name|raw }}\">
1048
        <div class=\"location\">{% if method.class is not same as(class) %}in {{ method_link(method, false, true) }} {% endif %}at {{ method_source_link(method) }}</div>
1049
        <code>{{ block('method_signature') }}</code>
1050
    </h3>
1051
    <div class=\"details\">
1052
        {{ deprecations(method) }}
1053
1054
        {% if method.shortdesc or method.longdesc %}
1055
            <div class=\"method-description\">
1056
                {% if not method.shortdesc and not method.longdesc %}
1057
                    <p class=\"no-description\">No description</p>
1058
                {% else %}
1059
                    {% if method.shortdesc -%}
1060
                    <p>{{ method.shortdesc|desc(class) }}</p>
1061
                    {%- endif %}
1062
                    {% if method.longdesc -%}
1063
                    <p>{{ method.longdesc|desc(class) }}</p>
1064
                    {%- endif %}
1065
                {%- endif %}
1066
            </div>
1067
        {% endif %}
1068
        <div class=\"tags\">
1069
            {% if method.parameters %}
1070
                <h4>Parameters</h4>
1071
1072
                {{ block('parameters') }}
1073
            {% endif %}
1074
1075
            {% if method.hintDesc or method.hint %}
1076
                <h4>Return Value</h4>
1077
1078
                {{ block('return') }}
1079
            {% endif %}
1080
1081
            {% if method.exceptions %}
1082
                <h4>Exceptions</h4>
1083
1084
                {{ block('exceptions') }}
1085
            {% endif %}
1086
1087
            {% if method.tags('see') %}
1088
                <h4>See also</h4>
1089
1090
                {{ block('see') }}
1091
            {% endif %}
1092
        </div>
1093
    </div>
1094
{% endblock %}
1095
", "class.twig", "phar:///Users/bobby/Dropbox/Sites/OpenSource/Slackify/sami.phar/Sami/Resources/themes/default/class.twig");
1096
    }
1097
}
1098