1 | <?php |
||
8 | class Vector extends Tuple |
||
9 | { |
||
10 | /** |
||
11 | * Adds the given vector to this vector. |
||
12 | * |
||
13 | * @param Vector $vector The vector to add. |
||
14 | * @return Vector |
||
15 | * @throws InvalidArgumentException Thrown when the given vector is of a different length. |
||
16 | */ |
||
17 | 2 | public function add(Vector $vector) |
|
29 | |||
30 | /** |
||
31 | * Conjugates the vector. This is an alias of reverse(). |
||
32 | */ |
||
33 | 1 | public function conjugate() |
|
37 | |||
38 | /** |
||
39 | * Calculates the dot product between this vector and the given vector. |
||
40 | * |
||
41 | * @param Vector $vector The vector to calculate thet dot product with. |
||
42 | * @return float |
||
43 | */ |
||
44 | 3 | public function dotProduct(Vector $vector) |
|
61 | |||
62 | /** |
||
63 | * Gets the length of the vector. |
||
64 | * |
||
65 | * @return float |
||
66 | */ |
||
67 | 3 | public function getLength() |
|
71 | |||
72 | /** |
||
73 | * Gets the square of the vector's length. |
||
74 | * |
||
75 | * @return float |
||
76 | */ |
||
77 | 4 | public function getLengthSquared() |
|
88 | |||
89 | /** |
||
90 | * Gets the magnitude of the vector. This is an alias of getLength(). |
||
91 | * |
||
92 | * @return float |
||
93 | */ |
||
94 | 1 | public function getMagnitude() |
|
98 | |||
99 | /** |
||
100 | * Negates this vector. The vector has the same magnitude as before, but its direction is now opposite. |
||
101 | * |
||
102 | * @return Vector |
||
103 | */ |
||
104 | 3 | public function negate() |
|
112 | |||
113 | /** |
||
114 | * Normalizes the vector, making sure the length of the vector is 1 (a unit vector). |
||
115 | * |
||
116 | * @return Vector |
||
117 | */ |
||
118 | 1 | public function normalize() |
|
128 | |||
129 | /** |
||
130 | * Reverses the sign of the components. This is an alias of negate. |
||
131 | * |
||
132 | * @return Vector |
||
133 | */ |
||
134 | 2 | public function reverse() |
|
138 | |||
139 | /** |
||
140 | * Scales the vector. |
||
141 | * |
||
142 | * @param float $scale The scale factor. |
||
143 | * @return Vector |
||
144 | */ |
||
145 | 1 | public function scale($scale) |
|
153 | |||
154 | /** |
||
155 | * Subtracts the given vector from this vector. |
||
156 | * |
||
157 | * @param Vector $vector The vector to sutbract. |
||
158 | * @return Vector |
||
159 | * @throws InvalidArgumentException Thrown when the given vector is of a different length. |
||
160 | */ |
||
161 | 2 | public function subtract(Vector $vector) |
|
173 | } |
||
174 |
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: