File tree Expand file tree Collapse file tree 5 files changed +20
-23
lines changed Expand file tree Collapse file tree 5 files changed +20
-23
lines changed Original file line number Diff line number Diff line change 15
15
"require-dev" : {
16
16
"phpunit/phpunit" : " ^11" ,
17
17
"friendsofphp/php-cs-fixer" : " ^3.14" ,
18
- "php-coveralls/php-coveralls" : " ^2.5"
18
+ "php-coveralls/php-coveralls" : " ^2.5" ,
19
+ "phpstan/phpstan" : " ^2.1"
19
20
},
20
21
"autoload" : {
21
22
"psr-4" : {"ReCaptcha\\ " : " src/ReCaptcha" }
33
34
" vendor/bin/php-cs-fixer -vvv fix --using-cache=no ."
34
35
],
35
36
"test" : [
37
+ " vendor/bin/phpstan" ,
36
38
" vendor/bin/phpunit --display-phpunit-deprecations"
37
39
],
38
40
"serve-examples" : " @php -S localhost:8080 -t examples"
Original file line number Diff line number Diff line change
1
+ parameters :
2
+ level : 5
3
+ errorFormat : raw
4
+ editorUrl : ' %%file%% %%line%% %%column%%: %%error%%'
5
+ paths :
6
+ - src
7
+
Original file line number Diff line number Diff line change @@ -112,18 +112,6 @@ class ReCaptcha
112
112
*/
113
113
public const E_CHALLENGE_TIMEOUT = 'challenge-timeout ' ;
114
114
115
- /**
116
- * Shared secret for the site.
117
- * @var string
118
- */
119
- private string $ secret ;
120
-
121
- /**
122
- * Method used to communicate with service. Defaults to POST request.
123
- * @var RequestMethod
124
- */
125
- private ?RequestMethod $ requestMethod ;
126
-
127
115
private string $ hostname ;
128
116
private string $ apkPackageName ;
129
117
private string $ action ;
@@ -137,18 +125,15 @@ class ReCaptcha
137
125
* @param ?RequestMethod $requestMethod method used to send the request. Defaults to POST.
138
126
* @throws \RuntimeException if $secret is invalid
139
127
*/
140
- public function __construct (string $ secret , ?RequestMethod $ requestMethod = null )
128
+ public function __construct (private string $ secret , private ?RequestMethod $ requestMethod = null )
141
129
{
142
130
if (empty ($ secret )) {
143
131
throw new \RuntimeException ('No secret provided ' );
144
132
}
145
133
146
- if (! is_string ( $ secret )) {
147
- throw new \ RuntimeException ( ' The provided secret must be a string ' );
134
+ if (is_null ( $ requestMethod )) {
135
+ $ this -> requestMethod = new RequestMethod \ Post ( );
148
136
}
149
-
150
- $ this ->secret = $ secret ;
151
- $ this ->requestMethod = (is_null ($ requestMethod )) ? new RequestMethod \Post () : $ requestMethod ;
152
137
}
153
138
154
139
/**
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ class Curl
43
43
/**
44
44
* @see http://php.net/curl_init
45
45
*
46
- * @return resource cURL handle *
46
+ * @return \CurlHandle|false cURL handle *
47
47
*/
48
48
public function init (?string $ url = null )
49
49
{
@@ -52,7 +52,7 @@ public function init(?string $url = null)
52
52
53
53
/**
54
54
* @see http://php.net/curl_setopt_array
55
- * @param resource $ch
55
+ * @param \CurlHandle|false $ch
56
56
*/
57
57
public function setoptArray ($ ch , array $ options ): bool
58
58
{
@@ -61,7 +61,7 @@ public function setoptArray($ch, array $options): bool
61
61
62
62
/**
63
63
* @see http://php.net/curl_exec
64
- * @param resource $ch
64
+ * @param \CurlHandle|false $ch
65
65
*/
66
66
public function exec ($ ch ): mixed
67
67
{
@@ -70,7 +70,7 @@ public function exec($ch): mixed
70
70
71
71
/**
72
72
* @see http://php.net/curl_close
73
- * @param resource $ch
73
+ * @param \CurlHandle|false $ch
74
74
*/
75
75
public function close ($ ch ): void
76
76
{
Original file line number Diff line number Diff line change 41
41
*/
42
42
class Socket
43
43
{
44
+ /**
45
+ * @var resource|false
46
+ */
44
47
private $ handle = null ;
45
48
46
49
/**
You can’t perform that action at this time.
0 commit comments