Skip to content

Commit cac3042

Browse files
authored
Merge pull request google#517 from google/php8-updates
Update to PHP8
2 parents ed5645e + 9653520 commit cac3042

17 files changed

+56
-75
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/.php_cs.cache
22
/.phpunit.result.cache
3+
.phpunit.cache/
34
/build
45
/composer.lock
56
/examples/config.php

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
"source": "https://github.com/google/recaptcha"
1111
},
1212
"require": {
13-
"php": ">=5.5"
13+
"php": ">=8"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": "^4.8.36|^5.7.27|^6.59|^7.5.11",
17-
"friendsofphp/php-cs-fixer": "^2.2.20|^2.15",
18-
"php-coveralls/php-coveralls": "^2.1"
16+
"phpunit/phpunit": "^10",
17+
"friendsofphp/php-cs-fixer": "^3.14",
18+
"php-coveralls/php-coveralls": "^2.5"
1919
},
2020
"autoload": {
2121
"psr-4": {
@@ -28,9 +28,9 @@
2828
}
2929
},
3030
"scripts": {
31-
"lint": "vendor/bin/php-cs-fixer -vvv fix --using-cache=no --dry-run .",
32-
"lint-fix": "vendor/bin/php-cs-fixer -vvv fix --using-cache=no .",
33-
"test": "vendor/bin/phpunit --colors=always",
31+
"lint": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer -vvv fix --using-cache=no --dry-run .",
32+
"lint-fix": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer -vvv fix --using-cache=no .",
33+
"test": "XDEBUG_MODE=coverage vendor/bin/phpunit",
3434
"serve-examples": "@php -S localhost:8080 -t examples"
3535
},
3636
"config": {

examples/recaptcha-content-security-policy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<main>
104104
<?php
105105
if ($siteKey === '' || $secret === ''):
106-
?>
106+
?>
107107
<h2>Add your keys</h2>
108108
<p>If you do not have keys already then visit <kbd> <a href = "https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a></kbd> to generate them. Edit this file and set the respective keys in <kbd>$siteKey</kbd> and <kbd>$secret</kbd>. Reload the page after this.</p>
109109
<?php

examples/recaptcha-v2-checkbox-explicit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<main>
7474
<?php
7575
if ($siteKey === '' || $secret === ''):
76-
?>
76+
?>
7777
<h2>Add your keys</h2>
7878
<p>If you do not have keys already then visit <kbd> <a href = "https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a></kbd> to generate them. Edit this file and set the respective keys in the <kbd>config.php</kbd> file or directly to <kbd>$siteKey</kbd> and <kbd>$secret</kbd>. Reload the page after this.</p>
7979
<?php

examples/recaptcha-v2-checkbox.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
require __DIR__ . '/appengine-https.php';
3434

35-
// Initiate the autoloader. The file should be generated by Composer.
35+
// Initiate the autoloader. The file should be generated by Composer.
3636
// You will provide your own autoloader or require the files directly if you did
3737
// not install via Composer.
3838
require_once __DIR__ . '/../vendor/autoload.php';
@@ -73,7 +73,7 @@
7373
<main>
7474
<?php
7575
if ($siteKey === '' || $secret === ''):
76-
?>
76+
?>
7777
<h2>Add your keys</h2>
7878
<p>If you do not have keys already then visit <kbd> <a href = "https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a></kbd> to generate them. Edit this file and set the respective keys in the <kbd>config.php</kbd> file or directly to <kbd>$siteKey</kbd> and <kbd>$secret</kbd>. Reload the page after this.</p>
7979
<?php

examples/recaptcha-v2-invisible.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
require __DIR__ . '/appengine-https.php';
3434

35-
// Initiate the autoloader. The file should be generated by Composer.
35+
// Initiate the autoloader. The file should be generated by Composer.
3636
// You will provide your own autoloader or require the files directly if you did
3737
// not install via Composer.
3838
require_once __DIR__ . '/../vendor/autoload.php';
@@ -73,7 +73,7 @@
7373
<main>
7474
<?php
7575
if ($siteKey === '' || $secret === ''):
76-
?>
76+
?>
7777
<h2>Add your keys</h2>
7878
<p>If you do not have keys already then visit <kbd> <a href = "https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a></kbd> to generate them. Edit this file and set the respective keys in <kbd>$siteKey</kbd> and <kbd>$secret</kbd>. Reload the page after this.</p>
7979
<?php

examples/recaptcha-v3-request-scores.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<main>
7878
<?php
7979
if ($siteKey === '' || $secret === ''):
80-
?>
80+
?>
8181
<h2>Add your keys</h2>
8282
<p>If you do not have keys already then visit <kbd> <a href = "https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a></kbd> to generate them. Edit this file and set the respective keys in <kbd>$siteKey</kbd> and <kbd>$secret</kbd>. Reload the page after this.</p>
8383
<?php

phpunit.xml.dist

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.4/phpunit.xsd"
4-
colors="true"
5-
verbose="true"
6-
bootstrap="src/autoload.php">
7-
<testsuites>
8-
<testsuite name="reCAPTCHA Test Suite">
9-
<directory>tests/ReCaptcha/</directory>
10-
</testsuite>
11-
</testsuites>
12-
<filter>
13-
<whitelist>
14-
<directory suffix=".php">src/ReCaptcha/</directory>
15-
</whitelist>
16-
</filter>
17-
<logging>
18-
<log type="coverage-clover" target="build/logs/clover.xml"/>
19-
</logging>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" colors="true" bootstrap="src/autoload.php" cacheDirectory=".phpunit.cache">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/ReCaptcha/</directory>
6+
</include>
7+
<report>
8+
<clover outputFile="build/logs/clover.xml"/>
9+
</report>
10+
</coverage>
11+
<testsuites>
12+
<testsuite name="reCAPTCHA Test Suite">
13+
<directory>tests/ReCaptcha/</directory>
14+
</testsuite>
15+
</testsuites>
16+
<logging/>
2017
</phpunit>

src/ReCaptcha/ReCaptcha.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,73 +43,73 @@ class ReCaptcha
4343
* Version of this client library.
4444
* @const string
4545
*/
46-
const VERSION = 'php_1.2.4';
46+
public const VERSION = 'php_1.2.4';
4747

4848
/**
4949
* URL for reCAPTCHA siteverify API
5050
* @const string
5151
*/
52-
const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
52+
public const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
5353

5454
/**
5555
* Invalid JSON received
5656
* @const string
5757
*/
58-
const E_INVALID_JSON = 'invalid-json';
58+
public const E_INVALID_JSON = 'invalid-json';
5959

6060
/**
6161
* Could not connect to service
6262
* @const string
6363
*/
64-
const E_CONNECTION_FAILED = 'connection-failed';
64+
public const E_CONNECTION_FAILED = 'connection-failed';
6565

6666
/**
6767
* Did not receive a 200 from the service
6868
* @const string
6969
*/
70-
const E_BAD_RESPONSE = 'bad-response';
70+
public const E_BAD_RESPONSE = 'bad-response';
7171

7272
/**
7373
* Not a success, but no error codes received!
7474
* @const string
7575
*/
76-
const E_UNKNOWN_ERROR = 'unknown-error';
76+
public const E_UNKNOWN_ERROR = 'unknown-error';
7777

7878
/**
7979
* ReCAPTCHA response not provided
8080
* @const string
8181
*/
82-
const E_MISSING_INPUT_RESPONSE = 'missing-input-response';
82+
public const E_MISSING_INPUT_RESPONSE = 'missing-input-response';
8383

8484
/**
8585
* Expected hostname did not match
8686
* @const string
8787
*/
88-
const E_HOSTNAME_MISMATCH = 'hostname-mismatch';
88+
public const E_HOSTNAME_MISMATCH = 'hostname-mismatch';
8989

9090
/**
9191
* Expected APK package name did not match
9292
* @const string
9393
*/
94-
const E_APK_PACKAGE_NAME_MISMATCH = 'apk_package_name-mismatch';
94+
public const E_APK_PACKAGE_NAME_MISMATCH = 'apk_package_name-mismatch';
9595

9696
/**
9797
* Expected action did not match
9898
* @const string
9999
*/
100-
const E_ACTION_MISMATCH = 'action-mismatch';
100+
public const E_ACTION_MISMATCH = 'action-mismatch';
101101

102102
/**
103103
* Score threshold not met
104104
* @const string
105105
*/
106-
const E_SCORE_THRESHOLD_NOT_MET = 'score-threshold-not-met';
106+
public const E_SCORE_THRESHOLD_NOT_MET = 'score-threshold-not-met';
107107

108108
/**
109109
* Challenge timeout
110110
* @const string
111111
*/
112-
const E_CHALLENGE_TIMEOUT = 'challenge-timeout';
112+
public const E_CHALLENGE_TIMEOUT = 'challenge-timeout';
113113

114114
/**
115115
* Shared secret for the site.

src/ReCaptcha/RequestMethod.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
*/
4040
interface RequestMethod
4141
{
42-
4342
/**
4443
* Submit the request with the specified parameters.
4544
*

0 commit comments

Comments
 (0)