azuyalabs / yasumi

The easy PHP Library for calculating holidays
https://www.yasumi.dev
Other
1.05k stars 155 forks source link

Suggest switching from getShortName to getName for reflection class to gain compatibility #292

Closed SupraSmooth closed 1 year ago

SupraSmooth commented 2 years ago

Firstly, thank you for this great library. Since this month is themed by the Hacktoberfest a few months ago, I found a little bug working with this library, that I would like to fix.

We used a Symfony application with a lot of custom business logic and had the need to create a custom holiday provider to handle some application specific edge cases. Since this custom provider was located in our code, our namespace was obviously different from the one used in this library.

With this PR, I suggest switching to from getShortName() to getName() for the ReflectionClass created by the private method anotherTime() in the AbstractProvider.

We noticed that using getShortName() could result in a ProviderNotFoundException for some custom holiday providers, since the namespace is not fully qualified.

You can reproduce this bug by creating a custom holiday provider in a test project, where the namespace of the custom holiday provider differs in any way from the one used by this library. Next implement the next() or previous() methods from the AbstractProvider in your custom provider and see the application crash.

Greetings from Germany and keep contributing!

stelgenhof commented 1 year ago

@SupraSmooth Thanks for spotting this! I added a review to your PR.