Skip to content

Commit

Permalink
Force typehint
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed May 21, 2024
1 parent a9c0075 commit a7c23df
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions lib/GaletteAuto/AbstractObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/GaletteAuto/Auto.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/GaletteAuto/Autos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/GaletteAuto/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/GaletteAuto/Repository/Models.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tests/GaletteAuto/tests/units/Auto.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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']);
Expand Down
2 changes: 1 addition & 1 deletion tests/GaletteAuto/tests/units/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/GaletteAuto/tests/units/Brand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/GaletteAuto/tests/units/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/GaletteAuto/tests/units/Finition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/GaletteAuto/tests/units/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/GaletteAuto/tests/units/Transmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit a7c23df

Please sign in to comment.