From a7c23dfa0c34c0e5836b86b4b17ea9d9be333bd0 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Tue, 21 May 2024 22:42:16 +0200 Subject: [PATCH] Force typehint --- lib/GaletteAuto/AbstractObject.php | 4 ++-- lib/GaletteAuto/Auto.php | 4 ++-- lib/GaletteAuto/Autos.php | 2 +- lib/GaletteAuto/Model.php | 2 +- lib/GaletteAuto/Repository/Models.php | 2 +- tests/GaletteAuto/tests/units/Auto.php | 8 ++++---- tests/GaletteAuto/tests/units/Body.php | 2 +- tests/GaletteAuto/tests/units/Brand.php | 2 +- tests/GaletteAuto/tests/units/Color.php | 2 +- tests/GaletteAuto/tests/units/Finition.php | 2 +- tests/GaletteAuto/tests/units/State.php | 2 +- tests/GaletteAuto/tests/units/Transmission.php | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/GaletteAuto/AbstractObject.php b/lib/GaletteAuto/AbstractObject.php index 86718f8..3886dcd 100644 --- a/lib/GaletteAuto/AbstractObject.php +++ b/lib/GaletteAuto/AbstractObject.php @@ -119,7 +119,7 @@ public function load(int $id): bool $results = $this->zdb->execute($select); $result = $results->current(); $pk = $this->pk; - $this->id = $result->$pk; + $this->id = (int)$result->$pk; $field = $this->field; $this->value = $result->$field; @@ -402,7 +402,7 @@ private function proceedCount(Select $select): void //@phpstan-ignore-next-line $k = static::PK; - $this->count = $result->$k; + $this->count = (int)$result->$k; if ($this->count > 0 && isset($this->filters)) { $this->filters->setCounter($this->count); diff --git a/lib/GaletteAuto/Auto.php b/lib/GaletteAuto/Auto.php index 053b848..2f17e07 100644 --- a/lib/GaletteAuto/Auto.php +++ b/lib/GaletteAuto/Auto.php @@ -249,7 +249,7 @@ public function load(int $id): bool private function loadFromRS(ArrayObject $r): void { $pk = self::PK; - $this->id = $r->$pk; + $this->id = (int)$r->$pk; $this->registration = $r->car_registration; $this->name = $r->car_name; $this->first_registration_date = $r->car_first_registration_date; @@ -261,7 +261,7 @@ private function loadFromRS(ArrayObject $r): void $this->horsepower = $r->car_horsepower; $this->engine_size = $r->car_engine_size; $this->creation_date = $r->car_creation_date; - $this->fuel = $r->car_fuel; + $this->fuel = (int)$r->car_fuel; //External objects $this->picture = new Picture($this->plugins, (int)$this->id); $fpk = Finition::PK; diff --git a/lib/GaletteAuto/Autos.php b/lib/GaletteAuto/Autos.php index b500d6f..c80842e 100644 --- a/lib/GaletteAuto/Autos.php +++ b/lib/GaletteAuto/Autos.php @@ -298,7 +298,7 @@ private function proceedCount(Select $select, ?AutosList $filters): void } $results = $this->zdb->execute($countSelect); - $this->count = $results->current()->count; + $this->count = (int)$results->current()->count; if ($this->count > 0 && $filters !== null) { $filters->setCounter($this->count); } diff --git a/lib/GaletteAuto/Model.php b/lib/GaletteAuto/Model.php index 2b58ad1..c7b8bf6 100644 --- a/lib/GaletteAuto/Model.php +++ b/lib/GaletteAuto/Model.php @@ -112,7 +112,7 @@ public function load(int $id): bool */ private function loadFromRS(ArrayObject $r): void { - $this->id = $r->id_model; + $this->id = (int)$r->id_model; $this->model = $r->model; $id_brand = Brand::PK; $this->brand->load((int)$r->$id_brand); diff --git a/lib/GaletteAuto/Repository/Models.php b/lib/GaletteAuto/Repository/Models.php index 8e9c47c..bc86d0b 100644 --- a/lib/GaletteAuto/Repository/Models.php +++ b/lib/GaletteAuto/Repository/Models.php @@ -169,7 +169,7 @@ private function proceedCount(Select $select): void $result = $results->current(); $k = self::PK; - $this->count = $result->$k; + $this->count = (int)$result->$k; if ($this->count > 0) { $this->filters->setCounter($this->count); diff --git a/tests/GaletteAuto/tests/units/Auto.php b/tests/GaletteAuto/tests/units/Auto.php index b3b980b..ad82ec0 100644 --- a/tests/GaletteAuto/tests/units/Auto.php +++ b/tests/GaletteAuto/tests/units/Auto.php @@ -210,8 +210,8 @@ public function testCrud(): void array_keys($entry) ); - $this->assertSame($auto->id, $entry['id_car']); - $this->assertSame($adh->id, $entry['id_adh']); + $this->assertSame($auto->id, (int)$entry['id_car']); + $this->assertSame($adh->id, (int)$entry['id_adh']); $this->assertSame('GA-123-TE', $entry['car_registration']); $this->assertSame('Grey', $entry['color']); $this->assertSame('Correct', $entry['state']); @@ -255,8 +255,8 @@ public function testCrud(): void $this->assertCount(2, $history->getEntries()); $entry = $history->getEntries()[1]; - $this->assertSame($auto->id, $entry['id_car']); - $this->assertSame($adh2->id, $entry['id_adh']); + $this->assertSame($auto->id, (int)$entry['id_car']); + $this->assertSame($adh2->id, (int)$entry['id_adh']); $this->assertSame('GA-123-TE', $entry['car_registration']); $this->assertSame('Yellow', $entry['color']); $this->assertSame('Correct', $entry['state']); diff --git a/tests/GaletteAuto/tests/units/Body.php b/tests/GaletteAuto/tests/units/Body.php index 33f001d..5c5c946 100644 --- a/tests/GaletteAuto/tests/units/Body.php +++ b/tests/GaletteAuto/tests/units/Body.php @@ -103,7 +103,7 @@ public function testCrud(): void $list = $body->getList(); $this->assertCount(1, $list); $last_body = $list[0]; - $this->assertSame($id, $last_body->id_body); + $this->assertSame($id, (int)$last_body->id_body); } /** diff --git a/tests/GaletteAuto/tests/units/Brand.php b/tests/GaletteAuto/tests/units/Brand.php index a86807f..0c78f6a 100644 --- a/tests/GaletteAuto/tests/units/Brand.php +++ b/tests/GaletteAuto/tests/units/Brand.php @@ -103,7 +103,7 @@ public function testCrud(): void $list = $brand->getList(); $this->assertCount(1, $list); $last_brand = $list[0]; - $this->assertSame($id, $last_brand->id_brand); + $this->assertSame($id, (int)$last_brand->id_brand); } /** diff --git a/tests/GaletteAuto/tests/units/Color.php b/tests/GaletteAuto/tests/units/Color.php index fc096cc..6254a5f 100644 --- a/tests/GaletteAuto/tests/units/Color.php +++ b/tests/GaletteAuto/tests/units/Color.php @@ -103,7 +103,7 @@ public function testCrud(): void $list = $color->getList(); $this->assertCount(1, $list); $last_color = $list[0]; - $this->assertSame($id, $last_color->id_color); + $this->assertSame($id, (int)$last_color->id_color); } /** diff --git a/tests/GaletteAuto/tests/units/Finition.php b/tests/GaletteAuto/tests/units/Finition.php index 516a9f4..ca4cee8 100644 --- a/tests/GaletteAuto/tests/units/Finition.php +++ b/tests/GaletteAuto/tests/units/Finition.php @@ -103,7 +103,7 @@ public function testCrud(): void $list = $finition->getList(); $this->assertCount(1, $list); $last_finition = $list[0]; - $this->assertSame($id, $last_finition->id_finition); + $this->assertSame($id, (int)$last_finition->id_finition); } /** diff --git a/tests/GaletteAuto/tests/units/State.php b/tests/GaletteAuto/tests/units/State.php index 554a79b..4e3acfb 100644 --- a/tests/GaletteAuto/tests/units/State.php +++ b/tests/GaletteAuto/tests/units/State.php @@ -103,7 +103,7 @@ public function testCrud(): void $list = $state->getList(); $this->assertCount(1, $list); $last_state = $list[0]; - $this->assertSame($id, $last_state->id_state); + $this->assertSame($id, (int)$last_state->id_state); } /** diff --git a/tests/GaletteAuto/tests/units/Transmission.php b/tests/GaletteAuto/tests/units/Transmission.php index e3a8596..e277a93 100644 --- a/tests/GaletteAuto/tests/units/Transmission.php +++ b/tests/GaletteAuto/tests/units/Transmission.php @@ -103,7 +103,7 @@ public function testCrud(): void $list = $transmission->getList(); $this->assertCount(1, $list); $last_transmission = $list[0]; - $this->assertSame($id, $last_transmission->id_transmission); + $this->assertSame($id, (int)$last_transmission->id_transmission); } /**