chrisyue /
php-m3u8
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Chrisyue\PhpM3u8\M3u8\Transformer; |
||
| 4 | |||
| 5 | use Chrisyue\PhpM3u8\M3u8\OptionsTrait; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * @Annotation |
||
| 9 | * @Target("PROPERTY") |
||
| 10 | */ |
||
| 11 | class Attribute implements AttributeValueTransformerInterface |
||
| 12 | { |
||
| 13 | use OptionsTrait; |
||
| 14 | |||
| 15 | public function transform($value) |
||
| 16 | { |
||
| 17 | foreach ($this->options['transformers'] as $transformer) { |
||
| 18 | $value = $transformer->transform($value); |
||
| 19 | } |
||
| 20 | |||
| 21 | return $value; |
||
| 22 | } |
||
| 23 | |||
| 24 | public function reverse($transformed) |
||
| 25 | { |
||
| 26 | foreach (array_reverse($this->options['transformers']) as $transformer) { |
||
| 27 | $value = $transformer->reverse($value); |
||
|
0 ignored issues
–
show
|
|||
| 28 | } |
||
| 29 | |||
| 30 | return $value; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function getName() |
||
| 34 | { |
||
| 35 | return $this->options['name']; |
||
| 36 | } |
||
| 37 | } |
||
| 38 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: