-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplified code and PHP version checks
- Loading branch information
Showing
8 changed files
with
99 additions
and
120 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
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineTest\Laminas\Hydrator\Assets; | ||
|
||
class SimpleEntityWithEnumPhp81 | ||
{ | ||
protected int $id; | ||
|
||
protected ?SimpleEnumPhp81 $enum = null; | ||
|
||
public function setId(int $id): void | ||
{ | ||
$this->id = $id; | ||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function setEnum(?SimpleEnumPhp81 $enum = null): void | ||
{ | ||
$this->enum = $enum; | ||
} | ||
|
||
public function getEnum(): ?SimpleEnumPhp81 | ||
{ | ||
return $this->enum; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineTest\Laminas\Hydrator\Assets; | ||
|
||
enum SimpleEnumPhp81: int | ||
{ | ||
case One = 1; | ||
case Two = 2; | ||
} |
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineTest\Laminas\Hydrator\Assets; | ||
|
||
use Laminas\Hydrator\Strategy\StrategyInterface; | ||
|
||
class SimpleEnumStrategyPhp81 implements StrategyInterface | ||
{ | ||
/** | ||
* @param mixed $value | ||
*/ | ||
public function extract($value, ?object $object = null): ?int | ||
{ | ||
if ($value === null) { | ||
return null; | ||
} | ||
|
||
return SimpleEnumPhp81::tryFrom($value)->value; | ||
} | ||
|
||
/** | ||
* @param mixed $value | ||
* @param array<array-key, mixed>|null $data | ||
*/ | ||
public function hydrate($value, ?array $data): ?SimpleEnumPhp81 | ||
{ | ||
if ($value === null) { | ||
return null; | ||
} | ||
|
||
return SimpleEnumPhp81::tryFrom($value); | ||
} | ||
} |
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