-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from sunrise-php/release/v3.1.0
v3.1.0
- Loading branch information
Showing
41 changed files
with
2,135 additions
and
709 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 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 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 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 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 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 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,61 @@ | ||
<?php | ||
|
||
/** | ||
* It's free open-source software released under the MIT License. | ||
* | ||
* @author Anatoly Nekhay <[email protected]> | ||
* @copyright Copyright (c) 2021, Anatoly Nekhay | ||
* @license https://github.com/sunrise-php/hydrator/blob/master/LICENSE | ||
* @link https://github.com/sunrise-php/hydrator | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sunrise\Hydrator\Annotation; | ||
|
||
use Attribute; | ||
|
||
/** | ||
* @Annotation | ||
* @Target({"PROPERTY"}) | ||
* @NamedArgumentConstructor | ||
* | ||
* @Attributes({ | ||
* @Attribute("name", type="string", required=true), | ||
* @Attribute("limit", type="integer", required=false), | ||
* }) | ||
* | ||
* @final See the {@see Relationship} class. | ||
* | ||
* @since 3.1.0 | ||
*/ | ||
#[Attribute(Attribute::TARGET_PROPERTY)] | ||
class Subtype | ||
{ | ||
|
||
/** | ||
* @var non-empty-string | ||
* | ||
* @readonly | ||
*/ | ||
public string $name; | ||
|
||
/** | ||
* @var int<0, max>|null | ||
* | ||
* @readonly | ||
*/ | ||
public ?int $limit; | ||
|
||
/** | ||
* Constructor of the class | ||
* | ||
* @param non-empty-string $name | ||
* @param int<0, max>|null $limit | ||
*/ | ||
public function __construct(string $name, ?int $limit = null) | ||
{ | ||
$this->name = $name; | ||
$this->limit = $limit; | ||
} | ||
} |
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,60 @@ | ||
<?php | ||
|
||
/** | ||
* It's free open-source software released under the MIT License. | ||
* | ||
* @author Anatoly Nekhay <[email protected]> | ||
* @copyright Copyright (c) 2021, Anatoly Nekhay | ||
* @license https://github.com/sunrise-php/hydrator/blob/master/LICENSE | ||
* @link https://github.com/sunrise-php/hydrator | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sunrise\Hydrator; | ||
|
||
use Generator; | ||
use LogicException; | ||
use ReflectionAttribute; | ||
use ReflectionProperty; | ||
|
||
use function sprintf; | ||
|
||
use const PHP_MAJOR_VERSION; | ||
|
||
/** | ||
* @since 3.1.0 | ||
*/ | ||
final class AnnotationReader implements AnnotationReaderInterface | ||
{ | ||
|
||
/** | ||
* Constructor of the class | ||
* | ||
* @throws LogicException If PHP version less than 8.0. | ||
*/ | ||
public function __construct() | ||
{ | ||
if (PHP_MAJOR_VERSION < 8) { | ||
throw new LogicException(sprintf( | ||
'The annotation reader {%s} requires PHP version greater than or equal to 8.0.', | ||
__CLASS__, | ||
)); | ||
} | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getAnnotations(ReflectionProperty $target, string $name): Generator | ||
{ | ||
if (PHP_MAJOR_VERSION < 8) { | ||
return; | ||
} | ||
|
||
$attributes = $target->getAttributes($name, ReflectionAttribute::IS_INSTANCEOF); | ||
foreach ($attributes as $attribute) { | ||
yield $attribute->newInstance(); | ||
} | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
/** | ||
* It's free open-source software released under the MIT License. | ||
* | ||
* @author Anatoly Nekhay <[email protected]> | ||
* @copyright Copyright (c) 2021, Anatoly Nekhay | ||
* @license https://github.com/sunrise-php/hydrator/blob/master/LICENSE | ||
* @link https://github.com/sunrise-php/hydrator | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sunrise\Hydrator; | ||
|
||
/** | ||
* @since 3.1.0 | ||
*/ | ||
interface AnnotationReaderAwareInterface | ||
{ | ||
|
||
/** | ||
* Sets the given annotation reader | ||
* | ||
* @param AnnotationReaderInterface $annotationReader | ||
* | ||
* @return void | ||
*/ | ||
public function setAnnotationReader(AnnotationReaderInterface $annotationReader): void; | ||
} |
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,36 @@ | ||
<?php | ||
|
||
/** | ||
* It's free open-source software released under the MIT License. | ||
* | ||
* @author Anatoly Nekhay <[email protected]> | ||
* @copyright Copyright (c) 2021, Anatoly Nekhay | ||
* @license https://github.com/sunrise-php/hydrator/blob/master/LICENSE | ||
* @link https://github.com/sunrise-php/hydrator | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sunrise\Hydrator; | ||
|
||
use Generator; | ||
use ReflectionProperty; | ||
|
||
/** | ||
* @since 3.1.0 | ||
*/ | ||
interface AnnotationReaderInterface | ||
{ | ||
|
||
/** | ||
* Gets annotations from the given target by the given annotation name | ||
* | ||
* @param ReflectionProperty $target | ||
* @param class-string<T> $name | ||
* | ||
* @return Generator<mixed, T> | ||
* | ||
* @template T of object | ||
*/ | ||
public function getAnnotations(ReflectionProperty $target, string $name): Generator; | ||
} |
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,28 @@ | ||
<?php | ||
|
||
/** | ||
* It's free open-source software released under the MIT License. | ||
* | ||
* @author Anatoly Nekhay <[email protected]> | ||
* @copyright Copyright (c) 2021, Anatoly Nekhay | ||
* @license https://github.com/sunrise-php/hydrator/blob/master/LICENSE | ||
* @link https://github.com/sunrise-php/hydrator | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sunrise\Hydrator\Dictionary; | ||
|
||
/** | ||
* Built-in types | ||
* | ||
* @since 3.1.0 | ||
*/ | ||
final class BuiltinType | ||
{ | ||
public const BOOL = 'bool'; | ||
public const INT = 'int'; | ||
public const FLOAT = 'float'; | ||
public const STRING = 'string'; | ||
public const ARRAY = 'array'; | ||
} |
Oops, something went wrong.