recaptcha icon indicating copy to clipboard operation
recaptcha copied to clipboard

PHP 8.4 deprecation

Open garak opened this issue 1 year ago • 3 comments

  1. /my_project/vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php:139 ReCaptcha\ReCaptcha::__construct(): Implicitly marking parameter $requestMethod as nullable is deprecated, the explicit nullable type must be used instead

The $requestMethod argument should accept null as value. The following change should be applied

diff --git a/src/ReCaptcha/ReCaptcha.php b/src/ReCaptcha/ReCaptcha.php
index d75ce1f..b928fc8 100644
--- a/src/ReCaptcha/ReCaptcha.php
+++ b/src/ReCaptcha/ReCaptcha.php
@@ -136,7 +136,7 @@ class ReCaptcha
      * @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
      * @throws \RuntimeException if $secret is invalid
      */
-    public function __construct($secret, RequestMethod $requestMethod = null)
+    public function __construct($secret, ?RequestMethod $requestMethod = null)
     {
         if (empty($secret)) {
             throw new \RuntimeException('No secret provided');

I can propose a PR.

garak avatar Nov 22 '24 17:11 garak

Deprecated: ReCaptcha\RequestMethod\CurlPost::__construct(): Implicitly marking parameter $curl as nullable is deprecated, the explicit nullable type must be used instead in /var/www/vhosts/domain.local/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/CurlPost.php on line 66

lxregistry avatar Dec 10 '24 06:12 lxregistry

Being addressed here: https://github.com/google/recaptcha/pull/563

cnizzardini avatar Dec 11 '24 16:12 cnizzardini

Looks like this project is no longer being supported by google. If you want a PHP 8.4 compatible library, check out:

phpfui/recaptcha

Should be a drop in replacement. Let me know of any issues.

phpfui avatar Jan 09 '25 22:01 phpfui

Solved in https://github.com/google/recaptcha/pull/575, this can be close

VincentLanglet avatar Jul 06 '25 15:07 VincentLanglet

Happy to see the issue addressed. We still need a release, tho.

garak avatar Jul 06 '25 17:07 garak

Happy to see the issue addressed. We still need a release, tho.

I don't think so, since there is a 1.3.1 tag https://github.com/google/recaptcha/releases/tag/1.3.1

VincentLanglet avatar Jul 06 '25 17:07 VincentLanglet