Skip to content

Add service-id-string type#421

Closed
mglaman wants to merge 1 commit intomainfrom
service-id-type
Closed

Add service-id-string type#421
mglaman wants to merge 1 commit intomainfrom
service-id-type

Conversation

@mglaman
Copy link
Copy Markdown
Owner

@mglaman mglaman commented Jun 1, 2022

Fixes #397

@mglaman mglaman force-pushed the service-id-type branch from 9c3de3b to cba6b7e Compare June 1, 2022 17:44
Comment on lines +10 to +15
/**
* @phpstan-param service-id-string $id
*/
public static function service($id) {
return static::getContainer()->get($id);
}
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to see if there is a way to get this testable as the allowed parameters.

@mglaman mglaman marked this pull request as draft July 12, 2022 19:15
@mglaman
Copy link
Copy Markdown
Owner Author

mglaman commented Apr 8, 2026

Closing this as a rabbit hole. The existing DrupalServiceDynamicReturnTypeExtension already handles the main use case well — literal service IDs get the correct return type, dynamic ones fall back to object and force type checks. The service-id-string type only adds meaningful value with generic template support (service-id-string<T>@return T), which is an open research question with no clear path forward. Not worth pursuing.

@mglaman mglaman closed this Apr 8, 2026
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

Successfully merging this pull request may close these issues.

Provide service-id-string for service ID parameters

1 participant