diff --git a/CHANGELOG.md b/CHANGELOG.md index b7cf7b4..c10b24b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ See [GitHub releases](https://github.com/mll-lab/php-utils/releases). ## Unreleased +## v4.1.0 + +### Added + +- Add generics to `BaseRack` and its children + ## v4.0.0 ### Added diff --git a/src/Tecan/Rack/AlublockA.php b/src/Tecan/Rack/AlublockA.php index 03c39a1..52902b0 100644 --- a/src/Tecan/Rack/AlublockA.php +++ b/src/Tecan/Rack/AlublockA.php @@ -2,6 +2,11 @@ namespace MLL\Utils\Tecan\Rack; +/** + * @template TContent + * + * @extends BaseRack + */ class AlublockA extends BaseRack { public function type(): string diff --git a/src/Tecan/Rack/BaseRack.php b/src/Tecan/Rack/BaseRack.php index a8da99d..8607dab 100644 --- a/src/Tecan/Rack/BaseRack.php +++ b/src/Tecan/Rack/BaseRack.php @@ -4,11 +4,12 @@ use Illuminate\Support\Collection; +/** @template TContent */ abstract class BaseRack implements Rack { public const EMPTY_POSITION = null; - /** @var Collection */ + /** @var Collection */ public Collection $positions; public function __construct() @@ -31,13 +32,13 @@ public function toString(): string ]); } - /** @param mixed $content Anything goes, null is considered empty */ + /** @param TContent|null $content Anything goes, null is considered empty */ public function assignFirstEmptyPosition($content): int { return $this->assignPosition($content, $this->findFirstEmptyPosition()); } - /** @param mixed $content Anything goes, null is considered empty */ + /** @param TContent|null $content Anything goes, null is considered empty */ public function assignLastEmptyPosition($content): int { return $this->assignPosition($content, $this->findLastEmptyPosition()); @@ -71,7 +72,7 @@ public function findLastEmptyPosition(): int return $lastEmpty; } - /** @param mixed $content Anything goes, null is considered empty */ + /** @param TContent|null $content Anything goes, null is considered empty */ public function assignPosition($content, int $position): int { if (! $this->positions->has($position)) { diff --git a/src/Tecan/Rack/DestLC.php b/src/Tecan/Rack/DestLC.php index b0131c7..ce19fab 100644 --- a/src/Tecan/Rack/DestLC.php +++ b/src/Tecan/Rack/DestLC.php @@ -2,6 +2,11 @@ namespace MLL\Utils\Tecan\Rack; +/** + * @template TContent + * + * @extends BaseRack + */ class DestLC extends BaseRack { public function type(): string diff --git a/src/Tecan/Rack/DestPCR.php b/src/Tecan/Rack/DestPCR.php index 109518a..303ef75 100644 --- a/src/Tecan/Rack/DestPCR.php +++ b/src/Tecan/Rack/DestPCR.php @@ -2,6 +2,11 @@ namespace MLL\Utils\Tecan\Rack; +/** + * @template TContent + * + * @extends BaseRack + */ class DestPCR extends BaseRack { public function type(): string diff --git a/src/Tecan/Rack/DestTaqMan.php b/src/Tecan/Rack/DestTaqMan.php index c74e75d..9a89b7d 100644 --- a/src/Tecan/Rack/DestTaqMan.php +++ b/src/Tecan/Rack/DestTaqMan.php @@ -2,6 +2,11 @@ namespace MLL\Utils\Tecan\Rack; +/** + * @template TContent + * + * @extends BaseRack + */ class DestTaqMan extends BaseRack { public function type(): string diff --git a/src/Tecan/Rack/FluidXRack.php b/src/Tecan/Rack/FluidXRack.php index aa74628..3e9ebb5 100644 --- a/src/Tecan/Rack/FluidXRack.php +++ b/src/Tecan/Rack/FluidXRack.php @@ -2,6 +2,11 @@ namespace MLL\Utils\Tecan\Rack; +/** + * @template TContent + * + * @extends BaseRack + */ class FluidXRack extends BaseRack implements ScannedRack { public function type(): string diff --git a/src/Tecan/Rack/MPCDNA.php b/src/Tecan/Rack/MPCDNA.php index 3041e6e..6d5b806 100644 --- a/src/Tecan/Rack/MPCDNA.php +++ b/src/Tecan/Rack/MPCDNA.php @@ -2,6 +2,11 @@ namespace MLL\Utils\Tecan\Rack; +/** + * @template TContent + * + * @extends BaseRack + */ class MPCDNA extends BaseRack { public function type(): string diff --git a/src/Tecan/Rack/MPSample.php b/src/Tecan/Rack/MPSample.php index bc31fe2..b3a9f5d 100644 --- a/src/Tecan/Rack/MPSample.php +++ b/src/Tecan/Rack/MPSample.php @@ -2,6 +2,11 @@ namespace MLL\Utils\Tecan\Rack; +/** + * @template TContent + * + * @extends BaseRack + */ class MPSample extends BaseRack { public function type(): string diff --git a/src/Tecan/Rack/MPWater.php b/src/Tecan/Rack/MPWater.php index 5440feb..b74835c 100644 --- a/src/Tecan/Rack/MPWater.php +++ b/src/Tecan/Rack/MPWater.php @@ -2,6 +2,11 @@ namespace MLL\Utils\Tecan\Rack; +/** + * @template TContent + * + * @extends BaseRack + */ class MPWater extends BaseRack { public function type(): string diff --git a/src/Tecan/Rack/MasterMixRack.php b/src/Tecan/Rack/MasterMixRack.php index 481c581..26d368c 100644 --- a/src/Tecan/Rack/MasterMixRack.php +++ b/src/Tecan/Rack/MasterMixRack.php @@ -2,6 +2,11 @@ namespace MLL\Utils\Tecan\Rack; +/** + * @template TContent + * + * @extends BaseRack + */ class MasterMixRack extends BaseRack { public function type(): string diff --git a/tests/Tecan/Rack/RackTest.php b/tests/Tecan/Rack/RackTest.php index efab38e..2f37f7b 100644 --- a/tests/Tecan/Rack/RackTest.php +++ b/tests/Tecan/Rack/RackTest.php @@ -62,7 +62,7 @@ public function testThrowsExceptionForInvalidPosition(): void $rack->assignPosition('Sample', $lastPosition + 1); } - /** @return iterable */ + /** @return iterable, string, string, int}> */ public static function rackDataProvider(): iterable { yield 'MPCDNA' => [new MPCDNA(), 'MPCDNA', 'MP cDNA', 96]; @@ -76,7 +76,11 @@ public static function rackDataProvider(): iterable yield 'MPWater' => [new MPWater(), 'MPWasser', 'Trough 300ml MCA Portrait', 1]; } - /** @dataProvider rackDataProvider */ + /** + * @param BaseRack $rack + * + * @dataProvider rackDataProvider + */ #[DataProvider('rackDataProvider')] public function testRackProperties(BaseRack $rack, string $expectedName, string $expectedType, int $expectedPositionCount): void {