Completed
Push — master ( 3bb683...8cf661 )
by Korotkov
01:35
created

getSource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/* index.html.twig */
4
class __TwigTemplate_171da130139d640faff447a21ec7a6e817cf9e36962bd12541f247c91175573d 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.html.twig", "index.html.twig", 1);
12
        $this->blocks = array(
13
            'content' => array($this, 'block_content'),
14
        );
15
    }
16
17
    protected function doGetParent(array $context)
18
    {
19
        return "layout.html.twig";
0 ignored issues
show
Bug Best Practice introduced by
The return type of return 'layout.html.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...
20
    }
21
22
    protected function doDisplay(array $context, array $blocks = array())
23
    {
24
        $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...
25
    }
26
27
    // line 3
28
    public function block_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...
29
    {
30
        // line 4
31
        echo "
32
    <h1>Rudra Framework</h1>
33
34
";
35
    }
36
37
    public function getTemplateName()
38
    {
39
        return "index.html.twig";
40
    }
41
42
    public function isTraitable()
43
    {
44
        return false;
45
    }
46
47
    public function getDebugInfo()
48
    {
49
        return array (  31 => 4,  28 => 3,  11 => 1,);
50
    }
51
52
    /** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
53
    public function getSource()
54
    {
55
        @trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
56
57
        return $this->getSourceContext()->getCode();
58
    }
59
60
    public function getSourceContext()
61
    {
62
        return new Twig_Source("{% extends \"layout.html.twig\" %}
63
64
{% block content %}
65
66
    <h1>Rudra Framework</h1>
67
68
{% endblock %}", "index.html.twig", "F:\\OpenServer\\OSPanel\\domains\\github\\Rudra-Framework\\app\\resources\\twig\\view\\index.html.twig");
69
    }
70
}
71