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

TransitType enum not generated #4591

Open
razvanphp opened this issue Feb 5, 2024 · 4 comments
Open

TransitType enum not generated #4591

razvanphp opened this issue Feb 5, 2024 · 4 comments

Comments

@razvanphp
Copy link

razvanphp commented Feb 5, 2024

There might be are other missing enums, but this one stood out to me:
https://developers.google.com/wallet/reference/rest/v1/transitclass#TransitClass.TransitType

Since I'm the maintainer of eymengunay/php-passbook project and we will have this repo as dependancy, I would love to contribute this here for the whole community.

<?php

namespace Google\Service\Walletobjects;

/**
 * Enum for Transit Types.
 */
enum TransitType: string
{
    case TRANSIT_TYPE_UNSPECIFIED = 'TRANSIT_TYPE_UNSPECIFIED';
    
    case BUS = 'BUS';
    
    /**
     * @deprecated Legacy alias for BUS. Deprecated.
     */
    case bus = 'BUS';
    
    case RAIL = 'RAIL';
    
    /**
     * @deprecated Legacy alias for RAIL. Deprecated.
     */
    case rail = 'RAIL';
    
    case TRAM = 'TRAM';
    
    /**
     * @deprecated Legacy alias for TRAM. Deprecated.
     */
    case tram = 'TRAM';
    
    case FERRY = 'FERRY';
    
    /**
     * @deprecated Legacy alias for FERRY. Deprecated.
     */
    case ferry = 'FERRY';
    
    case OTHER = 'OTHER';
    
    /**
     * @deprecated Legacy alias for OTHER. Deprecated.
     */
    case other = 'OTHER';
}

LE: enum data type was introduced in version 8.1, so we should probably stick with class constants for now to support 7.4

But... not sure how to do it through the generator.... can I get some guidance at least? Maybe I could try it.

Also, on a more general note, it would be awesome to include those types as return types and parameter types as many other issues suggested, now that PHP 7.4 is the minimum supported version.

Thank you!

CC @bshaffer

@razvanphp
Copy link
Author

razvanphp commented Feb 5, 2024

It can be seen here and here:

       "transitType": {
          "enum": [
            "TRANSIT_TYPE_UNSPECIFIED",
            "BUS",
            "bus",
            "RAIL",
            "rail",
            "TRAM",
            "tram",
            "FERRY",
            "ferry",
            "OTHER",
            "other"
          ],
          "description": "Required. The type of transit this class represents, such as \"bus\".",
          "enumDeprecated": [
            false,
            false,
            true,
            false,
            true,
            false,
            true,
            false,
            true,
            false,
            true
          ],
          "type": "string",
          "enumDescriptions": [
            "",
            "",
            "Legacy alias for `BUS`. Deprecated.",
            "",
            "Legacy alias for `RAIL`. Deprecated.",
            "",
            "Legacy alias for `TRAM`. Deprecated.",
            "",
            "Legacy alias for `FERRY`. Deprecated.",
            "",
            "Legacy alias for `OTHER`. Deprecated."
          ]
        },

... but none of the enums get generated.

We should also add the text descriptions as DocBlocks, would be immensely helpful for anybody using this SDK.

@bshaffer
Copy link
Contributor

Hello @razvanphp

You're correct in identifying that this library does not generate enums.

This was a feature request in #563, but since this library is essentially in maintenance mode, we made the decision to not merge it.

@razvanphp
Copy link
Author

hey @bshaffer

While I understand this lib is pretty much outdated, the wallterobjects objects were added rather recently, but we cannot add those constants only for this because of the generators.

Isn't there a better way to do this without creating so many files, maybe using phpdoc types at least, so IDEs can alert? This can be done in the same files probably, but I'm not familiar with how the generator works to do it myself.

The use-case is obvious, makes no sense to define those in my lib, while depending on those classes anyway, everybody should use types in 2024, even in PHP 🙂

@bshaffer
Copy link
Contributor

bshaffer commented Jun 2, 2024

Hi @razvanphp , these are just strings, so extra classes or typing is not necessary. I do think adding these values to phpdoc is something we should look into.

Edit: it seems like there are a lot of options for this, and we should implement one of them.

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