Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Type hinting on autogenerated entities #361

Open
dblencowe opened this issue Dec 30, 2018 · 1 comment
Open

[QUESTION] Type hinting on autogenerated entities #361

dblencowe opened this issue Dec 30, 2018 · 1 comment

Comments

@dblencowe
Copy link

Package version, Laravel version

v2.6.3

Expected behaviour

Type hints to be generated on methods which have a scalar type set

Actual behaviour

No type hints generated on methods

Steps to reproduce the behaviour

  • Create a mapping configuration
  • Generate entities

Hi all, I've recently started to use the ORM package and can see there's logic for creating type hints on methods whilst generating entities via the artisan command (EntityGenerator.php, line 1383).

       if ($typeHint && ! isset($types[$typeHint])) {
            $variableType   =  '\\' . ltrim($variableType, '\\');
            $methodTypeHint =  '\\' . $typeHint . ' ';
        }

The above code seems to stop the entities generating as $types[$typeHint] is set, I've tested this using the following dd (dd($typeHint, isset($types[$typeHint]), $types);) which produces:

"string"
true
array:26 [
  "array" => "Doctrine\DBAL\Types\ArrayType"
  "simple_array" => "Doctrine\DBAL\Types\SimpleArrayType"
  "json_array" => "Doctrine\DBAL\Types\JsonArrayType"
  "json" => "LaravelDoctrine\ORM\Types\Json"
  "object" => "Doctrine\DBAL\Types\ObjectType"
  "boolean" => "Doctrine\DBAL\Types\BooleanType"
  "integer" => "Doctrine\DBAL\Types\IntegerType"
  "smallint" => "Doctrine\DBAL\Types\SmallIntType"
  "bigint" => "Doctrine\DBAL\Types\BigIntType"
  "string" => "Doctrine\DBAL\Types\StringType"
  "text" => "Doctrine\DBAL\Types\TextType"
  "datetime" => "Doctrine\DBAL\Types\DateTimeType"
  "datetime_immutable" => "Doctrine\DBAL\Types\DateTimeImmutableType"
  "datetimetz" => "Doctrine\DBAL\Types\DateTimeTzType"
  "datetimetz_immutable" => "Doctrine\DBAL\Types\DateTimeTzImmutableType"
  "date" => "Doctrine\DBAL\Types\DateType"
  "date_immutable" => "Doctrine\DBAL\Types\DateImmutableType"
  "time" => "Doctrine\DBAL\Types\TimeType"
  "time_immutable" => "Doctrine\DBAL\Types\TimeImmutableType"
  "decimal" => "Doctrine\DBAL\Types\DecimalType"
  "float" => "Doctrine\DBAL\Types\FloatType"
  "binary" => "Doctrine\DBAL\Types\BinaryType"
  "blob" => "Doctrine\DBAL\Types\BlobType"
  "guid" => "Doctrine\DBAL\Types\GuidType"
  "dateinterval" => "Doctrine\DBAL\Types\DateIntervalType"
  "uuid" => "Ramsey\Uuid\Doctrine\UuidType"
]

The package is acting as the logic expects, but I'm wondering if there's something else I need to do to get type hints on my entities, or a reason I wouldn't want them?

Thanks

@vv12131415
Copy link
Contributor

@dblencowe I think you should address this question to original doctrine devs here https://github.com/doctrine/orm since this package does not control the code of EntityGenerator.php

Also I need to mention that entity generation is deprecated and will be removed from v3.0 of doctrine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants