8000 Allow doctrine custom types to register their php class to makerbundle for generating Type Hint · Issue #1002 · symfony/maker-bundle · GitHub
[go: up one dir, main page]

Skip to content

Allow doctrine custom types to register their php class to makerbundle for generating Type Hint #1002

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

Closed
sarim opened this issue Oct 29, 2021 · 0 comments · Fixed by #1413
Closed

Comments

@sarim
Copy link
sarim commented Oct 29, 2021

Right now its hardcoded in

private function getEntityTypeHint($doctrineType): ?string
{
switch ($doctrineType) {
case 'string':
case 'text':
case 'guid':
case 'bigint':
case 'decimal':
return 'string';
case 'array':
case 'simple_array':
case 'json':
case 'json_array':
return 'array';
case 'boolean':
return 'bool';
case 'integer':
case 'smallint':
return 'int';
case 'float':
return 'float';
case 'datetime':
case 'datetimetz':
case 'date':
case 'time':
return '\\'.\DateTimeInterface::class;
case 'datetime_immutable':
case 'datetimetz_immutable':
case 'date_immutable':
case 'time_immutable':
return '\\'.\DateTimeImmutable::class;
case 'dateinterval':
return '\\'.\DateInterval::class;
case 'object':
case 'binary':
case 'blob':
default:
return null;
}
}

It would be useful to allow a configuration or any other way to allow user code to extend this type hint mappings. Right now for any fields of doctrine custom types, maker bundle does not generate any type hint for getter and setter methods. Which is expected as Doctrine\DBAL\Types\Type does not have any way to convey php object's type. Its cumbersome to manually add type hint to getter and setter, and its pointless as when regenerating entity (make:entity --regenerate --overwrite) its wiped out anyways.

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