diff --git a/composer.json b/composer.json index a9cedea..845f1e1 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/src/Math.php b/src/Math.php index 399bea2..eee121e 100644 --- a/src/Math.php +++ b/src/Math.php @@ -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) ]; diff --git a/src/Vector3.php b/src/Vector3.php index 9830987..04a496f 100644 --- a/src/Vector3.php +++ b/src/Vector3.php @@ -25,6 +25,7 @@ use function abs; use function ceil; +use function floatval; use function floor; use function iterator_to_array; use function max; @@ -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); } /** diff --git a/src/VoxelRayTrace.php b/src/VoxelRayTrace.php index 7b4126d..b54c83b 100644 --- a/src/VoxelRayTrace.php +++ b/src/VoxelRayTrace.php @@ -23,6 +23,7 @@ namespace pocketmine\math; +use function floatval; use function floor; use const INF; @@ -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; @@ -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; }