From c781540aa6e35f579c56d798f0a999d1e839f1e7 Mon Sep 17 00:00:00 2001 From: Jens True Date: Wed, 21 Feb 2024 14:02:35 +0000 Subject: [PATCH] rector: instanceOf, earlyReturn, strictBooleans --- rector.php | 4 ++-- src/Numerics/Matrix.php | 3 +-- src/PartialPlay.php | 2 +- src/Team.php | 9 ++++++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/rector.php b/rector.php index 7b2b846..6d4dbef 100644 --- a/rector.php +++ b/rector.php @@ -14,7 +14,7 @@ return RectorConfig::configure() ]) // uncomment to reach your current PHP version ->withPhpSets() - ->withPreparedSets(deadCode: true, codeQuality: true, codingStyle: true, typeDeclarations : true) + ->withPreparedSets(deadCode: true, codeQuality: true, codingStyle: true, typeDeclarations : true, privatization: true, naming: false, instanceOf: true, earlyReturn: true, strictBooleans: true) ->withSkip([ - LocallyCalledStaticMethodToNonStaticRector::class, + LocallyCalledStaticMethodToNonStaticRector::class ]);; diff --git a/src/Numerics/Matrix.php b/src/Numerics/Matrix.php index 9bd18da..fb446b1 100644 --- a/src/Numerics/Matrix.php +++ b/src/Numerics/Matrix.php @@ -301,9 +301,8 @@ class Matrix if ($isEven) { return $this->getMinorMatrix($rowToRemove, $columnToRemove)->getDeterminant(); - } else { - return -1.0 * $this->getMinorMatrix($rowToRemove, $columnToRemove)->getDeterminant(); } + return -1.0 * $this->getMinorMatrix($rowToRemove, $columnToRemove)->getDeterminant(); } public function equals(Matrix $otherMatrix): bool diff --git a/src/PartialPlay.php b/src/PartialPlay.php index eb39fc5..5d8cd4f 100644 --- a/src/PartialPlay.php +++ b/src/PartialPlay.php @@ -13,7 +13,7 @@ class PartialPlay // HACK to get around bug near 0 $smallestPercentage = 0.0001; if ($partialPlayPercentage < $smallestPercentage) { - $partialPlayPercentage = $smallestPercentage; + return $smallestPercentage; } return $partialPlayPercentage; diff --git a/src/Team.php b/src/Team.php index ec2a4e5..ff4cbdd 100644 --- a/src/Team.php +++ b/src/Team.php @@ -9,10 +9,13 @@ class Team extends RatingContainer public function __construct(Player $player = NULL, Rating $rating = NULL) { parent::__construct(); - - if ($player && $rating) { - $this->addPlayer($player, $rating); + if (!$player instanceof \DNW\Skills\Player) { + return; } + if (!$rating instanceof \DNW\Skills\Rating) { + return; + } + $this->addPlayer($player, $rating); } public function addPlayer(Player $player, Rating $rating): self