laravel-notification-channels / fcm

Firebase Cloud Messaging (FCM) notifications channel for Laravel
https://laravel-notification-channels.com/
MIT License
491 stars 126 forks source link

Enum Visibility issue #141

Closed DiedeGu closed 1 year ago

DiedeGu commented 1 year ago

When I run a TestCase using the Visibility Enum I get this error;

Error: Duplicate value in enum NotificationChannels\Fcm\Resources\Visibility for cases VISIBILITY_UNSPECIFIED and VISIBILITY_PRIVATE

Pliease update this line of code: case VISIBILITY_UNSPECIFIED = 'PRIVATE'; here to a different value since the current setup is not allowed according to the specs:

If an enumeration is marked as having a scalar equivalent, then all cases must have a unique scalar equivalent defined explicitly. There are no auto-generated scalar equivalents (e.g., sequential integers). Backed cases must be unique; two backed enum cases may not have the same scalar equivalent. However, a constant may refer to a case, effectively creating an alias. See Enumeration constants.

from: https://www.php.net/manual/en/language.enumerations.backed.php

You could change the value to contain a different value, you could remove the case altogether or you could setup a constant as described in the page for enum constants: https://www.php.net/manual/en/language.enumerations.constants.php. I think the latter would be the easiest because it causes all calls to Visibility::VISIBILITY_UNSPECIFIED to keep working, and in cases where someone save these value to a database it will stay equivalent to the saved value as well.

dwightwatson commented 1 year ago

Thanks for reporting this - could you please check that #142 looks to you?

DiedeGu commented 1 year ago

Done and thank you very much for the quick response