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.
The return type of return array('form_has_e...e' => array('html')))); (array<string,Twig_Function_Method>) is incompatible with the return type declared by the interface Twig_ExtensionInterface::getFunctions of type Twig_SimpleFunction[].
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.
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
'form_has_errors' => new \Twig_Function_Method(
27
$this,
28
'formHasErrors',
29
array(
30
'is_safe' => array('html'),
31
)
32
),
33
'form_value' => new \Twig_Function_Method(
34
$this,
35
'formValue',
36
array(
37
'is_safe' => array('html'),
38
)
39
),
40
'form_checkbox_value' => new \Twig_Function_Method(
41
$this,
42
'formCheckboxValue',
43
array(
44
'is_safe' => array('html'),
45
)
46
),
47
);
48
}
49
50
/**
51
* @param boolean
52
*/
53
public function formHasErrors($form)
54
{
55
return count($form->vars['errors']) > 0;
56
}
57
58
/**
59
* @return mixed
60
*/
61
public function formValue($form, $fallback = null)
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:
Our function
my_functionexpects aPostobject, and outputs the author of the post. The base classPostreturns a simple string and outputting a simple string will work just fine. However, the child classBlogPostwhich is a sub-type ofPostinstead decided to return anobject, and is therefore violating the SOLID principles. If aBlogPostwere passed tomy_function, PHP would not complain, but ultimately fail when executing thestrtouppercall in its body.