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

RFC: deprecate AbstractPlatform::getName() #4749

Closed
greg0ire opened this issue Aug 19, 2021 · 6 comments · Fixed by #4755
Closed

RFC: deprecate AbstractPlatform::getName() #4749

greg0ire opened this issue Aug 19, 2021 · 6 comments · Fixed by #4755
Milestone

Comments

@greg0ire
Copy link
Member

I should have asked when reviewing https://github.com/doctrine/orm/pull/8870/files#diff-3e426fe47b58d2d4b970b1b7a0cbf5999af950e4f84e48dce4bee5061b57ed31R657 (cc @derrabus ), but what good is a getName() method when you can use instanceof? Isn't it more fragile?

In the past I remember Symfony deprecating form names, and recommending avoidance of services IDs that are not FQCN, and IMO this has makes things more clear. Should we get rid of AbstractPlatform::getName() as well?

@derrabus
Copy link
Member

I still like getName() and does it really hurt to keep it? We've just used it recently, see symfony/symfony#42011.

@derrabus
Copy link
Member

If I have to support multiple versions of DBAL, I would need to check for multiple base classes in order to detect a specific database engine. For instance, on DBAL 2.13, there is PostgreSQLPlatform, but that class is gone in DBAL 3.

@greg0ire
Copy link
Member Author

Oh so the possible values of getName is more stable than the hierarchy across DBAL versions? I didn't realize that… in that case yes, I think deprecating getName would be a bad idea. Still, there is a lot to dislike here, for instance when you use postgresql in client code, it's hard to understand where that magic string is defined. Also, unlike getName() in Symfony forms, the name is not unique, but shared, for instance PostgreSQL94Platform uses postgresql as a name. Maybe it should have been called family or something like that?

It might feel better to have a list of supported families defined as constants in an enum-like class looking like TrimMode.

<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Platforms;

final class PlatformFamily
{
    public const POSTGRESQL = 'postgresql';
    // …

    /**
     * @codeCoverageIgnore
     */
    private function __construct()
    {
    }
}

WDYT?

@derrabus
Copy link
Member

I don't see a big problem with magic strings here, but sure, having an enum might be helpful.

@morozov
Copy link
Member

morozov commented Aug 20, 2021

Should we get rid of AbstractPlatform::getName() as well?

Yes, it's been for a long time on my mind, just didn't ever get to it. We got rid of most of other getName()s previously.

@morozov morozov linked a pull request Aug 24, 2021 that will close this issue
@morozov morozov added this to the 3.2.0 milestone Aug 24, 2021
@morozov morozov closed this as completed Aug 27, 2021
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants