Skip to content

Commit c22fa06

Browse files
committed
Update PHPStan
1 parent ff4c395 commit c22fa06

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"php-64bit": "*"
99
},
1010
"require-dev": {
11-
"phpstan/phpstan": "~1.10.3",
11+
"phpstan/phpstan": "2.1.0",
1212
"phpstan/extension-installer": "^1.0",
13-
"phpstan/phpstan-strict-rules": "^1.0",
13+
"phpstan/phpstan-strict-rules": "^2.0",
1414
"phpunit/phpunit": "^10.0 || ^11.0"
1515
},
1616
"autoload": {

src/Math.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function solveQuadratic(float $a, float $b, float $c) : array{
6565
(-$b + $sqrtDiscriminant) / (2 * $a),
6666
(-$b - $sqrtDiscriminant) / (2 * $a)
6767
];
68-
}elseif($discriminant == 0){ //1 real root
68+
}elseif($discriminant === 0.0){ //1 real root
6969
return [
7070
-$b / (2 * $a)
7171
];

src/Vector3.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
use function abs;
2727
use function ceil;
28+
use function floatval;
2829
use function floor;
2930
use function iterator_to_array;
3031
use function max;
@@ -262,7 +263,10 @@ public function cross(Vector3 $v) : Vector3{
262263
}
263264

264265
public function equals(Vector3 $v) : bool{
265-
return $this->x == $v->x and $this->y == $v->y and $this->z == $v->z;
266+
return
267+
floatval($this->x) === floatval($v->x) and
268+
floatval($this->y) === floatval($v->y) and
269+
floatval($this->z) === floatval($v->z);
266270
}
267271

268272
/**

src/VoxelRayTrace.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
namespace pocketmine\math;
2525

26+
use function floatval;
2627
use function floor;
2728
use const INF;
2829

@@ -85,9 +86,9 @@ public static function betweenPoints(Vector3 $start, Vector3 $end) : \Generator{
8586
$tMaxZ = self::distanceFactorToBoundary($start->z, $directionVector->z);
8687

8788
//The change in t on each axis when taking a step on that axis (always positive).
88-
$tDeltaX = $directionVector->x == 0 ? 0 : $stepX / $directionVector->x;
89-
$tDeltaY = $directionVector->y == 0 ? 0 : $stepY / $directionVector->y;
90-
$tDeltaZ = $directionVector->z == 0 ? 0 : $stepZ / $directionVector->z;
89+
$tDeltaX = floatval($directionVector->x) === 0.0 ? 0 : $stepX / $directionVector->x;
90+
$tDeltaY = floatval($directionVector->y) === 0.0 ? 0 : $stepY / $directionVector->y;
91+
$tDeltaZ = floatval($directionVector->z) === 0.0 ? 0 : $stepZ / $directionVector->z;
9192

9293
while(true){
9394
yield $currentBlock;
@@ -132,7 +133,7 @@ public static function betweenPoints(Vector3 $start, Vector3 $end) : \Generator{
132133
* @return float Number of times $ds must be added to $s to change its whole-number component.
133134
*/
134135
private static function distanceFactorToBoundary(float $s, float $ds) : float{
135-
if($ds == 0){
136+
if($ds === 0.0){
136137
return INF;
137138
}
138139

0 commit comments

Comments
 (0)