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

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 1
1
<?php
2
3
/* layout/layout.twig */
4
class __TwigTemplate_8dc554e06ac7b8da7535d92ae46df1bc01667c2245998ebb36403332e8a3a06e 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/base.twig", "layout/layout.twig", 1);
12
        $this->blocks = array(
13
            'content' => array($this, 'block_content'),
14
            'below_menu' => array($this, 'block_below_menu'),
15
            'page_content' => array($this, 'block_page_content'),
16
            'menu' => array($this, 'block_menu'),
17
            'leftnav' => array($this, 'block_leftnav'),
18
            'control_panel' => array($this, 'block_control_panel'),
19
            'footer' => array($this, 'block_footer'),
20
        );
21
    }
22
23
    protected function doGetParent(array $context)
24
    {
25
        return "layout/base.twig";
0 ignored issues
show
Bug Best Practice introduced by
The return type of return 'layout/base.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...
26
    }
27
28
    protected function doDisplay(array $context, array $blocks = array())
29
    {
30
        $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...
31
    }
32
33
    // line 3
34
    public function block_content($context, array $blocks = array())
35
    {
36
        // line 4
37
        echo "    <div id=\"content\">
38
        <div id=\"left-column\">
39
            ";
40
        // line 6
41
        $this->displayBlock("control_panel", $context, $blocks);
42
        echo "
43
            ";
44
        // line 7
45
        $this->displayBlock("leftnav", $context, $blocks);
46
        echo "
47
        </div>
48
        <div id=\"right-column\">
49
            ";
50
        // line 10
51
        $this->displayBlock("menu", $context, $blocks);
52
        echo "
53
            ";
54
        // line 11
55
        $this->displayBlock('below_menu', $context, $blocks);
56
        // line 12
57
        echo "            <div id=\"page-content\">
58
                ";
59
        // line 13
60
        $this->displayBlock('page_content', $context, $blocks);
61
        // line 14
62
        echo "            </div>
63
            ";
64
        // line 15
65
        $this->displayBlock("footer", $context, $blocks);
66
        echo "
67
        </div>
68
    </div>
69
";
70
    }
71
72
    // line 11
73
    public function block_below_menu($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...
74
    {
75
        echo "";
76
    }
77
78
    // line 13
79
    public function block_page_content($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...
80
    {
81
        echo "";
82
    }
83
84
    // line 20
85
    public function block_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...
86
    {
87
        // line 21
88
        echo "    <nav id=\"site-nav\" class=\"navbar navbar-default\" role=\"navigation\">
89
        <div class=\"container-fluid\">
90
            <div class=\"navbar-header\">
91
                <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\"#navbar-elements\">
92
                    <span class=\"sr-only\">Toggle navigation</span>
93
                    <span class=\"icon-bar\"></span>
94
                    <span class=\"icon-bar\"></span>
95
                    <span class=\"icon-bar\"></span>
96
                </button>
97
                <a class=\"navbar-brand\" href=\"";
98
        // line 30
99
        echo twig_escape_filter($this->env, $this->env->getExtension('Sami\Renderer\TwigExtension')->pathForStaticFile($context, "index.html"), "html", null, true);
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 pathForStaticFile() 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...
100
        echo "\">";
101
        echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 30, $this->getSourceContext()); })()), "config", array(0 => "title"), "method"), "html", null, true);
102
        echo "</a>
103
            </div>
104
            <div class=\"collapse navbar-collapse\" id=\"navbar-elements\">
105
                <ul class=\"nav navbar-nav\">
106
                    <li><a href=\"";
107
        // line 34
108
        echo twig_escape_filter($this->env, $this->env->getExtension('Sami\Renderer\TwigExtension')->pathForStaticFile($context, "classes.html"), "html", null, true);
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 pathForStaticFile() 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...
109
        echo "\">Classes</a></li>
110
                    ";
111
        // line 35
112
        if ((isset($context["has_namespaces"]) || array_key_exists("has_namespaces", $context) ? $context["has_namespaces"] : (function () { throw new Twig_Error_Runtime('Variable "has_namespaces" does not exist.', 35, $this->getSourceContext()); })())) {
113
            // line 36
114
            echo "                        <li><a href=\"";
115
            echo twig_escape_filter($this->env, $this->env->getExtension('Sami\Renderer\TwigExtension')->pathForStaticFile($context, "namespaces.html"), "html", null, true);
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 pathForStaticFile() 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...
116
            echo "\">Namespaces</a></li>
117
                    ";
118
        }
119
        // line 38
120
        echo "                    <li><a href=\"";
121
        echo twig_escape_filter($this->env, $this->env->getExtension('Sami\Renderer\TwigExtension')->pathForStaticFile($context, "interfaces.html"), "html", null, true);
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 pathForStaticFile() 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...
122
        echo "\">Interfaces</a></li>
123
                    <li><a href=\"";
124
        // line 39
125
        echo twig_escape_filter($this->env, $this->env->getExtension('Sami\Renderer\TwigExtension')->pathForStaticFile($context, "traits.html"), "html", null, true);
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 pathForStaticFile() 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...
126
        echo "\">Traits</a></li>
127
                    <li><a href=\"";
128
        // line 40
129
        echo twig_escape_filter($this->env, $this->env->getExtension('Sami\Renderer\TwigExtension')->pathForStaticFile($context, "doc-index.html"), "html", null, true);
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 pathForStaticFile() 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...
130
        echo "\">Index</a></li>
131
                    <li><a href=\"";
132
        // line 41
133
        echo twig_escape_filter($this->env, $this->env->getExtension('Sami\Renderer\TwigExtension')->pathForStaticFile($context, "search.html"), "html", null, true);
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 pathForStaticFile() 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...
134
        echo "\">Search</a></li>
135
                </ul>
136
            </div>
137
        </div>
138
    </nav>
139
";
140
    }
141
142
    // line 48
143
    public function block_leftnav($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...
144
    {
145
        // line 49
146
        echo "    <div id=\"api-tree\"></div>
147
";
148
    }
149
150
    // line 52
151
    public function block_control_panel($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...
152
    {
153
        // line 53
154
        echo "    <div id=\"control-panel\">
155
        ";
156
        // line 54
157
        if ((twig_length_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 54, $this->getSourceContext()); })()), "versions", array())) > 1)) {
158
            // line 55
159
            echo "            <form action=\"#\" method=\"GET\">
160
                <select id=\"version-switcher\" name=\"version\">
161
                    ";
162
            // line 57
163
            $context['_parent'] = $context;
164
            $context['_seq'] = twig_ensure_traversable(twig_get_attribute($this->env, $this->getSourceContext(), (isset($context["project"]) || array_key_exists("project", $context) ? $context["project"] : (function () { throw new Twig_Error_Runtime('Variable "project" does not exist.', 57, $this->getSourceContext()); })()), "versions", array()));
165
            foreach ($context['_seq'] as $context["_key"] => $context["version"]) {
166
                // line 58
167
                echo "                        <option value=\"";
168
                echo twig_escape_filter($this->env, $this->env->getExtension('Sami\Renderer\TwigExtension')->pathForStaticFile($context, (("../" . $context["version"]) . "/index.html")), "html", null, true);
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 pathForStaticFile() 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...
169
                echo "\" data-version=\"";
170
                echo twig_escape_filter($this->env, $context["version"], "html", null, true);
171
                echo "\">";
172
                echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->getSourceContext(), $context["version"], "longname", array()), "html", null, true);
173
                echo "</option>
174
                    ";
175
            }
176
            $_parent = $context['_parent'];
177
            unset($context['_seq'], $context['_iterated'], $context['_key'], $context['version'], $context['_parent'], $context['loop']);
178
            $context = array_intersect_key($context, $_parent) + $_parent;
179
            // line 60
180
            echo "                </select>
181
            </form>
182
        ";
183
        }
184
        // line 63
185
        echo "        <script>
186
            \$('option[data-version=\"'+window.projectVersion+'\"]').prop('selected', true);
187
        </script>
188
        <form id=\"search-form\" action=\"";
189
        // line 66
190
        echo twig_escape_filter($this->env, $this->env->getExtension('Sami\Renderer\TwigExtension')->pathForStaticFile($context, "search.html"), "html", null, true);
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 pathForStaticFile() 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...
191
        echo "\" method=\"GET\">
192
            <span class=\"glyphicon glyphicon-search\"></span>
193
            <input name=\"search\"
194
                   class=\"typeahead form-control\"
195
                   type=\"search\"
196
                   placeholder=\"Search\">
197
        </form>
198
    </div>
199
";
200
    }
201
202
    // line 76
203
    public function block_footer($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...
204
    {
205
        // line 77
206
        echo "    <div id=\"footer\">
207
        Generated by <a href=\"http://sami.sensiolabs.org/\">Sami, the API Documentation Generator</a>.
208
    </div>
209
";
210
    }
211
212
    public function getTemplateName()
213
    {
214
        return "layout/layout.twig";
215
    }
216
217
    public function isTraitable()
218
    {
219
        return false;
220
    }
221
222
    public function getDebugInfo()
223
    {
224
        return array (  206 => 77,  203 => 76,  190 => 66,  185 => 63,  180 => 60,  167 => 58,  163 => 57,  159 => 55,  157 => 54,  154 => 53,  151 => 52,  146 => 49,  143 => 48,  133 => 41,  129 => 40,  125 => 39,  120 => 38,  114 => 36,  112 => 35,  108 => 34,  99 => 30,  88 => 21,  85 => 20,  79 => 13,  73 => 11,  65 => 15,  62 => 14,  60 => 13,  57 => 12,  55 => 11,  51 => 10,  45 => 7,  41 => 6,  37 => 4,  34 => 3,  11 => 1,);
225
    }
226
227
    public function getSourceContext()
228
    {
229
        return new Twig_Source("{% extends \"layout/base.twig\" %}
230
231
{% block content %}
232
    <div id=\"content\">
233
        <div id=\"left-column\">
234
            {{ block('control_panel') }}
235
            {{ block('leftnav') }}
236
        </div>
237
        <div id=\"right-column\">
238
            {{ block('menu') }}
239
            {% block below_menu '' %}
240
            <div id=\"page-content\">
241
                {% block page_content '' %}
242
            </div>
243
            {{ block('footer') }}
244
        </div>
245
    </div>
246
{% endblock %}
247
248
{% block menu %}
249
    <nav id=\"site-nav\" class=\"navbar navbar-default\" role=\"navigation\">
250
        <div class=\"container-fluid\">
251
            <div class=\"navbar-header\">
252
                <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\"#navbar-elements\">
253
                    <span class=\"sr-only\">Toggle navigation</span>
254
                    <span class=\"icon-bar\"></span>
255
                    <span class=\"icon-bar\"></span>
256
                    <span class=\"icon-bar\"></span>
257
                </button>
258
                <a class=\"navbar-brand\" href=\"{{ path('index.html') }}\">{{ project.config('title') }}</a>
259
            </div>
260
            <div class=\"collapse navbar-collapse\" id=\"navbar-elements\">
261
                <ul class=\"nav navbar-nav\">
262
                    <li><a href=\"{{ path('classes.html') }}\">Classes</a></li>
263
                    {% if has_namespaces %}
264
                        <li><a href=\"{{ path('namespaces.html') }}\">Namespaces</a></li>
265
                    {% endif %}
266
                    <li><a href=\"{{ path('interfaces.html') }}\">Interfaces</a></li>
267
                    <li><a href=\"{{ path('traits.html') }}\">Traits</a></li>
268
                    <li><a href=\"{{ path('doc-index.html') }}\">Index</a></li>
269
                    <li><a href=\"{{ path('search.html') }}\">Search</a></li>
270
                </ul>
271
            </div>
272
        </div>
273
    </nav>
274
{% endblock %}
275
276
{% block leftnav %}
277
    <div id=\"api-tree\"></div>
278
{% endblock %}
279
280
{% block control_panel %}
281
    <div id=\"control-panel\">
282
        {% if project.versions|length > 1 %}
283
            <form action=\"#\" method=\"GET\">
284
                <select id=\"version-switcher\" name=\"version\">
285
                    {% for version in project.versions %}
286
                        <option value=\"{{ path('../' ~ version ~ '/index.html') }}\" data-version=\"{{ version }}\">{{ version.longname }}</option>
287
                    {% endfor %}
288
                </select>
289
            </form>
290
        {% endif %}
291
        <script>
292
            \$('option[data-version=\"'+window.projectVersion+'\"]').prop('selected', true);
293
        </script>
294
        <form id=\"search-form\" action=\"{{ path('search.html') }}\" method=\"GET\">
295
            <span class=\"glyphicon glyphicon-search\"></span>
296
            <input name=\"search\"
297
                   class=\"typeahead form-control\"
298
                   type=\"search\"
299
                   placeholder=\"Search\">
300
        </form>
301
    </div>
302
{% endblock %}
303
304
{% block footer %}
305
    <div id=\"footer\">
306
        Generated by <a href=\"http://sami.sensiolabs.org/\">Sami, the API Documentation Generator</a>.
307
    </div>
308
{% endblock %}
309
", "layout/layout.twig", "phar:///Users/bobby/Dropbox/Sites/OpenSource/Slackify/sami.phar/Sami/Resources/themes/default/layout/layout.twig");
310
    }
311
}
312