File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,18 +25,18 @@ use FriendsOfHyperf\ReCaptcha\Middleware\ReCaptchaMiddleware;
2525
2626class V3CaptchaMiddleware extends ReCaptchaMiddleware
2727{
28- protected $version = 'v3';
29- protected $action = 'register';
30- protected $score = 0.35;
31- protected $hostname;
28+ protected string $version = 'v3';
29+ protected string $action = 'register';
30+ protected float $score = 0.35;
31+ protected string $hostname;
3232}
3333
3434class V2CaptchaMiddleware extends ReCaptchaMiddleware
3535{
36- protected $version = 'v2';
37- protected $action = 'register';
38- protected $score = 0.35;
39- protected $hostname;
36+ protected string $version = 'v2';
37+ protected string $action = 'register';
38+ protected float $score = 0.35;
39+ protected string $hostname;
4040}
4141```
4242
@@ -53,11 +53,8 @@ use Hyperf\Validation\Contract\ValidatorFactoryInterface;
5353
5454class IndexController
5555{
56- /**
57- * @Inject()
58- * @var ValidatorFactoryInterface
59- */
60- protected $validationFactory;
56+ #[Inject]
57+ protected ValidatorFactoryInterface $validationFactory;
6158
6259 public function foo(RequestInterface $request)
6360 {
Original file line number Diff line number Diff line change @@ -27,11 +27,11 @@ abstract class ReCaptchaMiddleware implements MiddlewareInterface
2727{
2828 protected string $ version = 'v3 ' ;
2929
30- protected string $ action ;
30+ protected string $ action = '' ;
3131
3232 protected float $ score = 0.34 ;
3333
34- protected string $ hostname ;
34+ protected string $ hostname = '' ;
3535
3636 protected string $ inputName = 'g-recaptcha-response ' ;
3737
Original file line number Diff line number Diff line change 2121class ReCaptchaManager
2222{
2323 /**
24- * @var ReCaptcha[]
24+ * @var array<string, ReCaptcha>
2525 */
2626 protected array $ instances = [];
2727
@@ -43,7 +43,7 @@ public function get(?string $version = null): ReCaptcha
4343 throw new RuntimeException ('Not publish yet, please run \'php bin/hyperf.php vendor:publish friendsofhyperf/recaptcha \'' );
4444 }
4545
46- $ version ??= $ this ->config ->get ('recaptcha.default ' , 'v3 ' );
46+ $ version ??= ( string ) $ this ->config ->get ('recaptcha.default ' , 'v3 ' );
4747 $ secret = $ this ->config ->get (sprintf ('recaptcha.%s.secret_key ' , $ version ), '' );
4848
4949 return $ this ->instances [$ version ] = make (ReCaptcha::class, [
You can’t perform that action at this time.
0 commit comments