ferdousulhaque / laravel-otp-validate

Laravel package for OTP validation with built-in features like max retry and resend mechanism. Both OTP/Security Code over SMS or Email or AWS SNS of your choice with template user-defined.
71 stars 13 forks source link

AWS SNS code requires a PHP version newer than the minimum in composer.json #9

Closed alex-ng-wesoft closed 2 years ago

alex-ng-wesoft commented 2 years ago

Issue

Currently the library's composer.json file claims that this library supports PHP v7.1.8 and up. A quick skim of the code base suggests this is mostly true, but there is a notable exception in SNSTransportService.php where type properties are used, which is something only available in PHP 7.4 or above.

Here are some quick commands to prove this:

$ docker run -it php:7.3.33-cli-alpine3.14 php -r 'class Foo {public string $bar;}'
> Parse error: syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in Command line code on line 1
$ docker run -it php:7.4.29-cli-alpine3.15 php -r 'class Foo {public string $bar;}'
> <No output>

As such, the composer.json PHP requirement is technically wrong.

Potential fixes

  1. Update the composer.json file to require PHP 7.4 or above.
  2. Update the SNS code to properly support PHP 7.1, 7.2, and 7.3.
  3. Document somewhere that SNS support requires PHP 7.4.

Considering even PHP 7.3 is (officially, at least) EOL since December of 2021 I strongly recommend option 1, but the other options are reasonable as well.

ferdousulhaque commented 2 years ago

@alex-ng-wesoft Well explained, thanks. Actually I have plans to fix the PHP version 7.4 and above, also to support PHP 8.0 and above same time. Thanks for the suggestion.