Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<testsuites>
<testsuite name="SergiX44/hydrator">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src</directory>
</include>
</source>
</phpunit>
8 changes: 6 additions & 2 deletions src/Annotation/ConcreteResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace SergiX44\Hydrator\Annotation;

use Attribute;
use RuntimeException;

/**
* @Annotation
* @Target({"CLASS"})
*/
#[Attribute(Attribute::TARGET_CLASS)]
abstract class ConcreteResolver
class ConcreteResolver
{
protected array $concretes = [];

Expand All @@ -19,7 +20,10 @@ abstract class ConcreteResolver
*
* @return string|null
*/
abstract public function concreteFor(array $data, array $all): ?string;
public function concreteFor(array $data, array $all): ?string
{
throw new RuntimeException('This class is meant to be extended to provide your own ConcreteResolver logic.');
}

/**
* @return array
Expand Down
8 changes: 6 additions & 2 deletions src/Annotation/UnionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
use ReflectionException;
use ReflectionNamedType;
use ReflectionType;
use RuntimeException;

/**
* @Annotation
* @Target({"PROPERTY"})
*/
#[Attribute(Attribute::TARGET_PROPERTY)]
abstract class UnionResolver
class UnionResolver
{
/**
* @param string $propertyName
Expand All @@ -23,5 +24,8 @@ abstract class UnionResolver
*
* @return ReflectionType
*/
abstract public function resolve(string $propertyName, array $propertyTypes, array $data): ReflectionType;
public function resolve(string $propertyName, array $propertyTypes, array $data): ReflectionType
{
throw new RuntimeException('This class is meant to be extended to provide your own UnionResolver logic.');
}
}
1 change: 0 additions & 1 deletion src/Exception/InvalidValueException.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function __construct(
) {
parent::__construct($message, $code, $previous);

$property->setAccessible(false);
$this->property = $property;
}

Expand Down
12 changes: 6 additions & 6 deletions tests/HydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function testHydrateBooleanProperty($value, $expected): void
$this->assertSame($expected, $object->value);
}

public function booleanValueProvider(): array
public static function booleanValueProvider(): array
{
return [
[true, true],
Expand Down Expand Up @@ -280,7 +280,7 @@ public function testHydrateIntegerProperty($value, $expected): void
$this->assertSame($expected, $object->value);
}

public function integerValueProvider(): array
public static function integerValueProvider(): array
{
return [
[42, 42],
Expand All @@ -306,7 +306,7 @@ public function testHydrateNumberProperty($value, $expected): void
$this->assertSame($expected, $object->value);
}

public function numberValueProvider(): array
public static function numberValueProvider(): array
{
return [
[42, 42.0],
Expand Down Expand Up @@ -438,7 +438,7 @@ public function testHydrateDateTimeImmutableProperty($value, $expected): void
$this->assertSame($expected, $object->value->format('Y-m-d'));
}

public function timestampValueProvider(): array
public static function timestampValueProvider(): array
{
return [
[1262304000, '2010-01-01'],
Expand Down Expand Up @@ -577,7 +577,7 @@ public function testHydrateStringableEnumProperty($value, $expected): void
$this->assertSame($expected, $object->value);
}

public function stringableEnumValueProvider(): array
public static function stringableEnumValueProvider(): array
{
return [
['c1200a7e-136e-4a11-9bc3-cc937046e90f', Fixtures\StringableEnum::foo],
Expand Down Expand Up @@ -615,7 +615,7 @@ public function testHydrateNumerableEnumProperty($value, $expected): void
$this->assertSame($expected, $object->value);
}

public function numerableEnumValueProvider(): array
public static function numerableEnumValueProvider(): array
{
return [
[1, Fixtures\NumerableEnum::foo],
Expand Down