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

Add Type::lookupName() shortcut method #6130

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

mvorisek
Copy link
Contributor

@mvorisek mvorisek commented Aug 15, 2023

Q A
Type feature
Fixed issues n/a

Summary

Type class has static methods for global TypeRegistry instance shorter access like Type::getType.

This feature adds a static method for TypeRegistry::lookupName.

Thanks to #6082, the reverse lookup is O(1) thus fine to be used massively - for ex. schema introspection returns type as object, and this method is needed to obtain a string name.

In DBAL 4.0, the method can be renamed to Type::getName(Type $type): string to be more consistent with Type::getType(string $name): Type.

@mvorisek mvorisek changed the title Add Type::lookupName() method Add Type::lookupName() shortcut method Aug 15, 2023
@derrabus
Copy link
Member

LGTM. The Type class has already become a static façade for the type registry, so we might as well add that one.

In DBAL 4.0, the method can be renamed to Type::getName(Type $type): string to be more consistent with Type::getType(string $name): Type.

I don't think we should do that. The current name is fine.

@derrabus derrabus added this to the 3.7.0 milestone Aug 22, 2023
@derrabus derrabus merged commit 0f3f92c into doctrine:3.7.x Aug 22, 2023
82 checks passed
@mvorisek mvorisek deleted the type_lookupname branch August 22, 2023 11:14
derrabus added a commit that referenced this pull request Aug 24, 2023
* 3.7.x:
  Support Symfony 7 by adding return types conditionally (#6136)
  Add Type::lookupName() shortcut method (#6130)
  fix: correct the deprecation method name
  fix: don't trigger deprecation if called internally
cgknx pushed a commit to cgknx/dbal that referenced this pull request Aug 30, 2023
|      Q       |   A
|------------- | -----------
| Type         | feature
| Fixed issues | n/a

#### Summary

`Type` class has static methods for global `TypeRegistry` instance
shorter access like `Type::getType`.

This feature adds a static method for `TypeRegistry::lookupName`.

Thanks to doctrine#6082, the reverse lookup
is O(1) thus fine to be used massively - for ex. schema introspection
returns type as object, and this method is needed to obtain a string
name.

In DBAL 4.0, the method can be renamed to `Type::getName(Type $type):
string` to be more consistent with `Type::getType(string $name): Type`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants