Algo-Web / POData

OData for Poor PHP Devs
Other
28 stars 13 forks source link

Error: Value '24' is not part of the enum POData\Providers\Metadata\ResourcePropertyKind #279

Open kirill533 opened 3 years ago

kirill533 commented 3 years ago

Hi Guys, came back to your library after my code started to break with the latest version of myclabs/php-enum package.

I though, it will be fixed in your version, but seems like it is the same issue here.

If you do the composer update to the latest version of myclabs/php-enum package, the tests should start giving errors. Most common error is like this:

68) UnitTests\POData\Providers\Metadata\ResourceTypeTest::testisResourceKindValidForPropertyKind with data set #16 (24, 2, false)
UnexpectedValueException: Value '24' is not part of the enum POData\Providers\Metadata\ResourcePropertyKind

The reason is that myclabs/php-enum package has now extra validation here: \MyCLabs\Enum\Enum::assertValidValueReturningKey

I guess it expects the class ResourcePropertyKind to have a constant with number 24 (KEY | PRIMITIVE). And actually, adding extra constants helps to fix the errors on my side.

My PHP version: PHP 7.3.19-1+ubuntu18.04.1+deb.sury.org+1

One solution would be to adjust composer.json to support only myclabs/php-enum with version below 1.8.0. But, please, make it compatible with myclabs/php-enum 1.8 and higher to make the library easier to combine with other libraries.

RuslanMelnychenko commented 2 years ago

I fix it by add to composer.json require: "myclabs/php-enum": "1.7.6"