Skip to content

Commit

Permalink
Update PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Jan 3, 2025
1 parent ff4c395 commit c22fa06
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"php-64bit": "*"
},
"require-dev": {
"phpstan/phpstan": "~1.10.3",
"phpstan/phpstan": "2.1.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^10.0 || ^11.0"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/Math.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function solveQuadratic(float $a, float $b, float $c) : array{
(-$b + $sqrtDiscriminant) / (2 * $a),
(-$b - $sqrtDiscriminant) / (2 * $a)
];
}elseif($discriminant == 0){ //1 real root
}elseif($discriminant === 0.0){ //1 real root
return [
-$b / (2 * $a)
];
Expand Down
6 changes: 5 additions & 1 deletion src/Vector3.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

use function abs;
use function ceil;
use function floatval;
use function floor;
use function iterator_to_array;
use function max;
Expand Down Expand Up @@ -262,7 +263,10 @@ public function cross(Vector3 $v) : Vector3{
}

public function equals(Vector3 $v) : bool{
return $this->x == $v->x and $this->y == $v->y and $this->z == $v->z;
return
floatval($this->x) === floatval($v->x) and
floatval($this->y) === floatval($v->y) and
floatval($this->z) === floatval($v->z);
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/VoxelRayTrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

namespace pocketmine\math;

use function floatval;
use function floor;
use const INF;

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

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

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

Expand Down

0 comments on commit c22fa06

Please sign in to comment.