Skip to content

Commit d6fc87e

Browse files
committed
Use num instead of double for Dart
1 parent 3807b25 commit d6fc87e

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/Language/Dart/DartClassFactoryGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private function resolveFactoryProperty(
7979
if ($collectionType instanceof PhpBaseType) {
8080
$dartType = match (true) {
8181
$collectionType->equalsTo(PhpBaseType::int()) => 'int',
82-
$collectionType->equalsTo(PhpBaseType::float()) => 'double',
82+
$collectionType->equalsTo(PhpBaseType::float()) => 'num',
8383
$collectionType->equalsTo(PhpBaseType::string()) => 'String',
8484
$collectionType->equalsTo(PhpBaseType::bool()) => 'bool',
8585
$collectionType->equalsTo(PhpBaseType::mixed()), $collectionType->equalsTo(PhpBaseType::iterable()), $collectionType->equalsTo(PhpBaseType::array()) => 'dynamic',

src/Language/Dart/DartGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private function getDartTypeFromPhp(PhpTypeInterface $type, DtoType $dto, DtoLis
116116
/** @var PhpBaseType $type */
117117
return match (true) {
118118
$type->equalsTo(PhpBaseType::int()) => 'int',
119-
$type->equalsTo(PhpBaseType::float()) => 'double',
119+
$type->equalsTo(PhpBaseType::float()) => 'num',
120120
$type->equalsTo(PhpBaseType::string()) => 'String',
121121
$type->equalsTo(PhpBaseType::bool()) => 'bool',
122122
$type->equalsTo(PhpBaseType::mixed()), $type->equalsTo(PhpBaseType::iterable()), $type->equalsTo(PhpBaseType::array()) => 'dynamic',

tests/__snapshots__/DartGeneratorTest__testDartWithEquitableAndFactory__1.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Recipe extends Equatable {
5959
final String? imageUrl;
6060
final String? url;
6161
final bool isCooked;
62-
final double weight;
62+
final num weight;
6363

6464
Recipe({
6565
required this.id,

tests/__snapshots__/DartGeneratorTest__testDart__1.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Recipe {
2525
final String? imageUrl;
2626
final String? url;
2727
final bool isCooked;
28-
final double weight;
28+
final num weight;
2929

3030
Recipe({
3131
required this.id,

0 commit comments

Comments
 (0)