Skip to content

Commit

Permalink
Static return type for fromArray method in Serrializable interface
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k3lm committed Oct 8, 2024
1 parent b419ee2 commit 9e0727f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/BusinessLogic/Domain/OrderReport/OrderReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ public function toArray(): array
public static function fromArray(array $array): Serializable
{
$entity = parent::fromArray($array);
// @phpstan-ignore-next-line
$entity->page = $array['page'];
// @phpstan-ignore-next-line
$entity->storeId = $array['storeId'];
$entity->page = intval($array['page']);
$entity->storeId = (string) $array['storeId'];

return $entity;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Serializer/Interfaces/Serializable.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Serializable extends \Serializable
*
* @param array<mixed> $array Data that is used to instantiate serializable object.
*
* @return Serializable
* @return static
* Instance of serialized object.
*/
public static function fromArray(array $array): Serializable;
Expand Down
5 changes: 4 additions & 1 deletion src/Infrastructure/TaskExecution/AsyncBatchStarter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use SeQura\Core\Infrastructure\TaskExecution\Interfaces\AsyncProcessService;
use SeQura\Core\Infrastructure\TaskExecution\Interfaces\Runnable;

/**
* @phpstan-consistent-constructor
*/
class AsyncBatchStarter implements Runnable
{
/**
Expand Down Expand Up @@ -76,7 +79,7 @@ public static function fromArray(array $array): Serializable
$subBatches[] = Serializer::unserialize($subBatch);
}

$instance = new self($array['batchSize'], $runners);
$instance = new static($array['batchSize'], $runners);
$instance->subBatches = $subBatches;
$instance->addIndex = $array['addIndex'];

Expand Down

0 comments on commit 9e0727f

Please sign in to comment.