Skip to content

Commit

Permalink
Use typed properties wherever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Oct 29, 2021
1 parent 74a16af commit f1ee1fe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
22 changes: 8 additions & 14 deletions src/AxisAlignedBB.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,14 @@
use function abs;
use const PHP_INT_MAX;

class AxisAlignedBB{

/** @var float */
public $minX;
/** @var float */
public $minY;
/** @var float */
public $minZ;
/** @var float */
public $maxX;
/** @var float */
public $maxY;
/** @var float */
public $maxZ;
final class AxisAlignedBB{

public float $minX;
public float $minY;
public float $minZ;
public float $maxX;
public float $maxY;
public float $maxZ;

public function __construct(float $minX, float $minY, float $minZ, float $maxX, float $maxY, float $maxZ){
if($minX > $maxX){
Expand Down
6 changes: 2 additions & 4 deletions src/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
class Matrix implements \ArrayAccess{
/** @var float[][] */
private array $matrix = [];
/** @var int */
private $rows;
/** @var int */
private $columns;
private int $rows;
private int $columns;

public function offsetExists($offset){
return isset($this->matrix[(int) $offset]);
Expand Down
9 changes: 3 additions & 6 deletions src/RayTraceResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@
*/
class RayTraceResult{

/** @var AxisAlignedBB */
public $bb;
/** @var int */
public $hitFace;
/** @var Vector3 */
public $hitVector;
public AxisAlignedBB $bb;
public int $hitFace;
public Vector3 $hitVector;

/**
* @param int $hitFace one of the Facing::* constants
Expand Down
6 changes: 2 additions & 4 deletions src/Vector2.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
use function sqrt;

class Vector2{
/** @var float */
public $x;
/** @var float */
public $y;
public float $x;
public float $y;

public function __construct(float $x, float $y){
$this->x = $x;
Expand Down

0 comments on commit f1ee1fe

Please sign in to comment.