Issues (125)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/svg/shape/Shape.php (35 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace nstdio\svg\shape;
3
4
use nstdio\svg\animation\BaseAnimation;
5
use nstdio\svg\ElementInterface;
6
use nstdio\svg\filter\BaseFilter;
7
use nstdio\svg\filter\DiffuseLighting;
8
use nstdio\svg\filter\Filter;
9
use nstdio\svg\filter\GaussianBlur;
10
use nstdio\svg\gradient\Gradient;
11
use nstdio\svg\gradient\UniformGradient;
12
use nstdio\svg\SVGElement;
13
use nstdio\svg\traits\StyleTrait;
14
use nstdio\svg\traits\TransformTrait;
15
use nstdio\svg\util\transform\Transform;
16
17
/**
18
 * Class Shape
19
 *
20
 * @property float  height      The height of shape.
21
 * @property float  width       The width of shape.
22
 * @property string stroke      Stroke color.
23
 * @property float  strokeWidth Width of stroke.
24
 * @property string strokeLocation
25
 * @property string style
26
 * @property string fill
27
 * @property string fillUrl     The id part of fill attribute.
28
 * @property float  fillOpacity specifies the opacity of the painting operation used to paint the interior the
29
 *           current
30
 * @property string filter
31
 * @property string filterUrl   The id part of filter attribute.
32
 * @property string transform
33
 * @package nstdio\svg\shape
34
 * @author  Edgar Asatryan <[email protected]>
35
 */
36
abstract class Shape extends SVGElement implements ShapeInterface
37
{
38
    use StyleTrait, TransformTrait;
39
40 74
    public function __construct(ElementInterface $parent)
41
    {
42 74
        parent::__construct($parent);
43
44 74
        $this->transformImpl = Transform::newInstance($this->getTransformAttribute());
45 74
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50 74
    public function getTransformAttribute()
51
    {
52 74
        return $this->transform;
53
    }
54
55
    abstract public function getBoundingBox();
56
57 1
    public function setTransformAttribute($transformList)
58
    {
59 1
        $this->transform = $transformList;
60
61 1
        return $this;
62
    }
63
64 1
    public function animate(BaseAnimation $animation)
65
    {
66 1
        $this->element->appendChild($animation->getElement());
0 ignored issues
show
It seems like $animation->getElement() targeting nstdio\svg\SVGElement::getElement() can also be of type object<DOMElement> or object<nstdio\svg\container\ContainerInterface>; however, nstdio\svg\XMLDocumentInterface::appendChild() does only seem to accept object<nstdio\svg\XMLDocumentInterface>, 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...
67
68 1
        return $this;
69
    }
70
71 2
    public function filterGaussianBlur($stdDeviation, $in = null, $filterId = null)
72
    {
73 2
        $filter = new Filter($this->getRoot(), $filterId);
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\ElementInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
74 2
        $blur = new GaussianBlur($filter);
75 2
        $blur->stdDeviation = $stdDeviation;
76 2
        $blur->in = $in;
77
78 2
        $this->applyFilter($filter);
79
80 2
        return $this;
81
    }
82
83 3
    public function applyFilter(BaseFilter $filter)
84
    {
85 3
        $svg = $this->getSVG();
86 3
        if ($this->filter === null) {
87 3
            $this->filterUrl = $filter->id;
88 3
            $defs = $svg->getFirstChild();
89 3
            $filter->selfRemove();
90 3
            $defs->append($filter);
91 3
        } else {
92 1
            $currentFilter = $svg->getFirstChild()->getChildById($this->filterUrl);
93 1
            if ($currentFilter !== null) {
94 1
                foreach ($filter->getChildren() as $child) {
95 1
                    $currentFilter->append($child);
96 1
                }
97 1
                $filter->selfRemove();
98 1
            }
99
        }
100
101 3
        return $this;
102
    }
103
104 1
    public function diffusePointLight(array $pointLightConfig = [], array $diffuseLightingConfig = [], $filterId = null)
105
    {
106
        $pointConfig = [
107 1
            'x' => $this->getCenterX(),
108 1
            'y' => $this->getCenterY(),
109 1
            'z' => 25,
110 1
        ];
111 1
        foreach ($pointConfig as $key => $value) {
112 1
            if (isset($pointLightConfig[$key])) {
113 1
                $pointConfig[$key] = $value + $pointLightConfig[$key];
114 1
            }
115 1
        }
116 1
        $filter = DiffuseLighting::diffusePointLight($this->getRoot(), $pointConfig, $diffuseLightingConfig, $filterId);
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
117 1
        $this->applyFilter($filter);
118
119 1
        return $this;
120
    }
121
122
    abstract protected function getCenterX();
123
124
    abstract protected function getCenterY();
125
126 1
    public function linearGradientFromTop(array $colors, $id = null)
127
    {
128 1
        return $this->applyGradient(UniformGradient::verticalFromTop($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
129
    }
130
131 17
    public function applyGradient(Gradient $gradient)
132
    {
133 17
        $this->fillUrl = $gradient->id;
134
135 17
        return $this;
136
    }
137
138 1
    public function linearGradientFromBottom(array $colors, $id = null)
139
    {
140 1
        return $this->applyGradient(UniformGradient::verticalFromBottom($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
141
    }
142
143 1
    public function linearGradientFromLeft(array $colors, $id = null)
144
    {
145 1
        return $this->applyGradient(UniformGradient::horizontalFromLeft($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
146
    }
147
148 1
    public function linearGradientFromRight(array $colors, $id = null)
149
    {
150 1
        return $this->applyGradient(UniformGradient::horizontalFromRight($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
151
    }
152
153 1
    public function linearGradientFromTopLeft(array $colors, $id = null)
154
    {
155 1
        return $this->applyGradient(UniformGradient::diagonalFromTopLeft($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
156
    }
157
158 1
    public function linearGradientFromTopRight(array $colors, $id = null)
159
    {
160 1
        return $this->applyGradient(UniformGradient::diagonalFromTopRight($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
161
    }
162
163 1
    public function linearGradientFromBottomLeft(array $colors, $id = null)
164
    {
165 1
        return $this->applyGradient(UniformGradient::diagonalFromBottomLeft($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
166
    }
167
168 1
    public function linearGradientFromBottomRight(array $colors, $id = null)
169
    {
170 1
        return $this->applyGradient(UniformGradient::diagonalFromBottomRight($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
171
    }
172
173 1
    public function radialGradientFromTopLeft(array $colors, $id = null)
174
    {
175 1
        return $this->applyGradient(UniformGradient::radialTopLeft($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
176
    }
177
178 1
    public function radialGradientFromTopRight(array $colors, $id = null)
179
    {
180 1
        return $this->applyGradient(UniformGradient::radialTopRight($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
181
    }
182
183 1
    public function radialGradientFromBottomLeft(array $colors, $id = null)
184
    {
185 1
        return $this->applyGradient(UniformGradient::radialBottomLeft($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
186
    }
187
188 1
    public function radialGradientFromBottomRight(array $colors, $id = null)
189
    {
190 1
        return $this->applyGradient(UniformGradient::radialBottomRight($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
191
    }
192
193 1
    public function radialGradientFromTopCenter(array $colors, $id = null)
194
    {
195 1
        return $this->applyGradient(UniformGradient::radialTopCenter($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
196
    }
197
198 1
    public function radialGradientFromLeftCenter(array $colors, $id = null)
199
    {
200 1
        return $this->applyGradient(UniformGradient::radialLeftCenter($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
201
    }
202
203 1
    public function radialGradientFromBottomCenter(array $colors, $id = null)
204
    {
205 1
        return $this->applyGradient(UniformGradient::radialBottomCenter($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
206
    }
207
208 1
    public function radialGradientFromRightCenter(array $colors, $id = null)
209
    {
210 1
        return $this->applyGradient(UniformGradient::radialRightCenter($this->getRoot(), $colors, $id));
0 ignored issues
show
$this->getRoot() is of type object<nstdio\svg\XMLDocumentInterface>, but the function expects a object<nstdio\svg\container\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
\nstdio\svg\gradient\Uni...etRoot(), $colors, $id) of type object<nstdio\svg\ElementInterface> is not a sub-type of object<nstdio\svg\gradient\Gradient>. It seems like you assume a concrete implementation of the interface nstdio\svg\ElementInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
211
    }
212
}