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 Viny; |
||
4 | |||
5 | /** |
||
6 | * Class Point |
||
7 | * @package Uello\ValueObject |
||
8 | */ |
||
9 | class Point |
||
10 | { |
||
11 | /** |
||
12 | * @param float $latitude |
||
13 | * @param float $longitude |
||
14 | */ |
||
15 | public function __construct(float $latitude, float $longitude) |
||
16 | { |
||
17 | $this->latitude = $latitude; |
||
0 ignored issues
–
show
|
|||
18 | $this->longitude = $longitude; |
||
0 ignored issues
–
show
The property
longitude does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @return float |
||
23 | */ |
||
24 | public function getLatitude(): float |
||
25 | { |
||
26 | return $this->latitude; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @return float |
||
31 | */ |
||
32 | public function getLongitude(): float |
||
33 | { |
||
34 | return $this->longitude; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return string |
||
39 | */ |
||
40 | public function __toString(): string |
||
41 | { |
||
42 | return sprintf('POINT(%f %f)', $this->latitude, $this->longitude); |
||
43 | } |
||
44 | } |
||
45 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: