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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"php": ">=8.3",
"nette/di": "v3.*",
"nette/database": "v3.*",
"nette/database": "^v3.2.7",
"ext-pdo": "*",
"ext-gettext": "*"
},
Expand Down
110 changes: 61 additions & 49 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Fykosak\NetteORM\ModelRelationsParser;
use Fykosak\NetteORM\Selection\TypedGroupedSelection;
use Fykosak\NetteORM\Selection\TypedSelection;
use Fykosak\NetteORM\Types\WGS84Point;
use Nette\Database\Table\ActiveRow;
use Nette\MemberAccessException;

Expand Down Expand Up @@ -54,6 +55,8 @@ public function &__get(string $key): mixed //phpcs:ignore
}
} elseif ($returnType->isSubclassOf(\BackedEnum::class)) {
$value = $returnType->getMethod('tryFrom')->invoke($returnType, $value);
} elseif ($returnType->name === WGS84Point::class) {
$value = $returnType->getMethod('fromBytes')->invoke($returnType, $value);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ModelRelationsParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ModelRelationsParser
{
/**
* @phpstan-param \ReflectionClass<Model> $modelReflection
* @phpstan-return array<string,array{type:Type,reflection:\ReflectionClass<Model>|null,property:string}>
* @phpstan-return array<string,array{type:Type,reflection:\ReflectionClass<mixed>|null,property:string}>
* @throws \ReflectionException
*/
public static function parseModelDoc(\ReflectionClass $modelReflection): ?array
Expand Down
2 changes: 1 addition & 1 deletion src/Selection/TypedGroupedSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Nette\Database\Table\Selection;

/**
* @template TModel of Model
* @phpstan-template-covariant TModel of Model
*/
class TypedGroupedSelection extends GroupedSelection
{
Expand Down
2 changes: 1 addition & 1 deletion src/Selection/TypedSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Nette\Database\Table\Selection;

/**
* @template TModel of Model
* @phpstan-template-covariant TModel of Model
* @phpstan-extends Selection<TModel>
* @phpstan-ignore-next-line
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Selection/TypedSelectionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Fykosak\NetteORM\Model\Model;

/**
* @template TModel of Model
* @phpstan-template-covariant TModel of Model
*/
trait TypedSelectionsTrait
{
Expand Down
5 changes: 4 additions & 1 deletion src/Service/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Fykosak\NetteORM\Mapper;
use Fykosak\NetteORM\Model\Model;
use Fykosak\NetteORM\Selection\TypedSelection;
use Fykosak\NetteORM\Types\WGS84Point;
use Nette\Database\Explorer;

/**
Expand Down Expand Up @@ -104,7 +105,9 @@ protected function filterData(array $data): array
$name = $column['name'];
if (array_key_exists($name, $data)) {
if ($data[$name] instanceof \BackedEnum) {
$result[$name] = $data[$name]->value;
$result[$name] = $data[$name]->value;
} elseif ($data[$name] instanceof WGS84Point) {
$result[$name] = $data[$name]->toString();
} else {
$result[$name] = $data[$name];
}
Expand Down
Loading
Loading