IndraGunawan / api-rate-limit-bundle

Rate limits protection for api-platform resources.
MIT License
66 stars 10 forks source link

Fix bug concerning null ApiRateLimit instance in RateLimitHandler #11

Closed baudev closed 5 years ago

baudev commented 5 years ago

When using the master version, the following error occurs:

Argument 2 passed to Indragunawan\\ApiRateLimitBundle\\Service\\RateLimitHandler::getThrottle() must be an instance of Indragunawan\\ApiRateLimitBundle\\Annotation\\ApiRateLimit, null given, called in /var/www/html/vendor/indragunawan/api-rate-limit-bundle/Service/RateLimitHandler.php on line 157

The responsible lines are:

https://github.com/IndraGunawan/api-rate-limit-bundle/blob/1096ebfe1b181d6b6e38ccf58884ab871b41c47b/Service/RateLimitHandler.php#L152-L156

Indeed, if $annotation is null, the getThrottle method fails. It's why creating a new instance of ApiRateLimit is required if this case.

baudev commented 5 years ago

By the way, it could be great adding friendsofphp/php-cs-fixer in the composer.json.

IndraGunawan commented 5 years ago

thanks @baudev !