-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow object to define how they are mapped to array (#532)
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/Integration/Mapper/Fixtures/ObjectWithJsonSerialize.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Tempest\Integration\Mapper\Fixtures; | ||
|
||
use JsonSerializable; | ||
use Tempest\Mapper\Strict; | ||
|
||
#[Strict] | ||
final class ObjectWithJsonSerialize implements JsonSerializable | ||
{ | ||
public function __construct( | ||
public string $a, | ||
public string $b, | ||
) { | ||
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
return [ | ||
'c' => $this->a, | ||
'd' => $this->b, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters