Skip to content

Commit 056de7d

Browse files
authored
Use default for Psalm ensureOverrideAttribute (php-curl-class#923)
* Use default for Psalm ensureOverrideAttribute * Fix missing Override attributes Error: ../src/Curl/CaseInsensitiveArray.php:66:5: MissingOverrideAttribute: Method Curl\CaseInsensitiveArray::offsetset should have the "Override" attribute (see https://psalm.dev/358)
1 parent 214cfe0 commit 056de7d

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

src/Curl/CaseInsensitiveArray.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function __construct(?array $initial = null)
6363
* @return void
6464
* @see https://secure.php.net/manual/en/arrayaccess.offsetset.php
6565
*/
66+
#[\Override]
6667
#[\ReturnTypeWillChange]
6768
public function offsetSet($offset, $value)
6869
{
@@ -85,6 +86,7 @@ public function offsetSet($offset, $value)
8586
* @return bool If the offset exists.
8687
* @see https://secure.php.net/manual/en/arrayaccess.offsetexists.php
8788
*/
89+
#[\Override]
8890
#[\ReturnTypeWillChange]
8991
public function offsetExists($offset)
9092
{
@@ -101,6 +103,7 @@ public function offsetExists($offset)
101103
* @return void
102104
* @see https://secure.php.net/manual/en/arrayaccess.offsetunset.php
103105
*/
106+
#[\Override]
104107
#[\ReturnTypeWillChange]
105108
public function offsetUnset($offset)
106109
{
@@ -119,6 +122,7 @@ public function offsetUnset($offset)
119122
* @return mixed The data stored at the offset.
120123
* @see https://secure.php.net/manual/en/arrayaccess.offsetget.php
121124
*/
125+
#[\Override]
122126
#[\ReturnTypeWillChange]
123127
public function offsetGet($offset)
124128
{
@@ -132,6 +136,7 @@ public function offsetGet($offset)
132136
* @return int The number of elements stored in the array.
133137
* @see https://secure.php.net/manual/en/countable.count.php
134138
*/
139+
#[\Override]
135140
#[\ReturnTypeWillChange]
136141
public function count()
137142
{
@@ -144,6 +149,7 @@ public function count()
144149
* @return mixed Data at the current position.
145150
* @see https://secure.php.net/manual/en/iterator.current.php
146151
*/
152+
#[\Override]
147153
#[\ReturnTypeWillChange]
148154
public function current()
149155
{
@@ -156,6 +162,7 @@ public function current()
156162
* @return void
157163
* @see https://secure.php.net/manual/en/iterator.next.php
158164
*/
165+
#[\Override]
159166
#[\ReturnTypeWillChange]
160167
public function next()
161168
{
@@ -168,6 +175,7 @@ public function next()
168175
* @return mixed Case-sensitive key at current position.
169176
* @see https://secure.php.net/manual/en/iterator.key.php
170177
*/
178+
#[\Override]
171179
#[\ReturnTypeWillChange]
172180
public function key()
173181
{
@@ -181,6 +189,7 @@ public function key()
181189
* @return bool If the current position is valid.
182190
* @see https://secure.php.net/manual/en/iterator.valid.php
183191
*/
192+
#[\Override]
184193
#[\ReturnTypeWillChange]
185194
public function valid()
186195
{
@@ -193,6 +202,7 @@ public function valid()
193202
* @return void
194203
* @see https://secure.php.net/manual/en/iterator.rewind.php
195204
*/
205+
#[\Override]
196206
#[\ReturnTypeWillChange]
197207
public function rewind()
198208
{

src/Curl/Curl.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ public function call()
236236
/**
237237
* Close
238238
*/
239+
#[\Override]
239240
public function close()
240241
{
241242
if (is_resource($this->curl) || $this->curl instanceof \CurlHandle) {
@@ -807,6 +808,7 @@ public function search($url, $data = [])
807808
* @param $key
808809
* @param $value
809810
*/
811+
#[\Override]
810812
public function setCookie($key, $value)
811813
{
812814
$this->setEncodedCookie($key, $value);
@@ -818,6 +820,7 @@ public function setCookie($key, $value)
818820
*
819821
* @param $cookies
820822
*/
823+
#[\Override]
821824
public function setCookies($cookies)
822825
{
823826
foreach ($cookies as $key => $value) {
@@ -868,6 +871,7 @@ public function setMaxFilesize($bytes)
868871
* @param $string
869872
* @return bool
870873
*/
874+
#[\Override]
871875
public function setCookieString($string)
872876
{
873877
return $this->setOpt(CURLOPT_COOKIE, $string);
@@ -879,6 +883,7 @@ public function setCookieString($string)
879883
* @param $cookie_file
880884
* @return bool
881885
*/
886+
#[\Override]
882887
public function setCookieFile($cookie_file)
883888
{
884889
return $this->setOpt(CURLOPT_COOKIEFILE, $cookie_file);
@@ -890,6 +895,7 @@ public function setCookieFile($cookie_file)
890895
* @param $cookie_jar
891896
* @return bool
892897
*/
898+
#[\Override]
893899
public function setCookieJar($cookie_jar)
894900
{
895901
return $this->setOpt(CURLOPT_COOKIEJAR, $cookie_jar);
@@ -996,6 +1002,7 @@ private function getDefaultUserAgent()
9961002
* @param $key
9971003
* @param $value
9981004
*/
1005+
#[\Override]
9991006
public function setHeader($key, $value)
10001007
{
10011008
$this->headers[$key] = $value;
@@ -1013,6 +1020,7 @@ public function setHeader($key, $value)
10131020
*
10141021
* @param $headers
10151022
*/
1023+
#[\Override]
10161024
public function setHeaders($headers)
10171025
{
10181026
if (ArrayUtil::isArrayAssoc($headers)) {
@@ -1043,6 +1051,7 @@ public function setHeaders($headers)
10431051
*
10441052
* @param $mixed boolean|callable
10451053
*/
1054+
#[\Override]
10461055
public function setJsonDecoder($mixed)
10471056
{
10481057
if ($mixed === false || is_callable($mixed)) {
@@ -1056,6 +1065,7 @@ public function setJsonDecoder($mixed)
10561065
*
10571066
* @param $mixed boolean|callable
10581067
*/
1068+
#[\Override]
10591069
public function setXmlDecoder($mixed)
10601070
{
10611071
if ($mixed === false || is_callable($mixed)) {
@@ -1071,6 +1081,7 @@ public function setXmlDecoder($mixed)
10711081
* @param $value
10721082
* @return bool
10731083
*/
1084+
#[\Override]
10741085
public function setOpt($option, $value)
10751086
{
10761087
$required_options = [
@@ -1096,6 +1107,7 @@ public function setOpt($option, $value)
10961107
* @param $value
10971108
* @return bool
10981109
*/
1110+
#[\Override]
10991111
protected function setOptInternal($option, $value)
11001112
{
11011113
$success = curl_setopt($this->curl, $option, $value);
@@ -1115,6 +1127,7 @@ protected function setOptInternal($option, $value)
11151127
* returned, ignoring any future options in the options array.
11161128
* Similar to curl_setopt_array().
11171129
*/
1130+
#[\Override]
11181131
public function setOpts($options)
11191132
{
11201133
if (!count($options)) {
@@ -1159,6 +1172,7 @@ private function setProtocolsInternal($protocols)
11591172
*
11601173
* @param $mixed
11611174
*/
1175+
#[\Override]
11621176
public function setRetry($mixed)
11631177
{
11641178
if (is_callable($mixed)) {
@@ -1193,6 +1207,7 @@ private function setRedirectProtocolsInternal($redirect_protocols)
11931207
* @param $url
11941208
* @param $mixed_data
11951209
*/
1210+
#[\Override]
11961211
public function setUrl($url, $mixed_data = '')
11971212
{
11981213
$built_url = Url::buildUrl($url, $mixed_data);
@@ -1235,6 +1250,7 @@ public function attemptRetry()
12351250
*
12361251
* @param $key
12371252
*/
1253+
#[\Override]
12381254
public function unsetHeader($key)
12391255
{
12401256
unset($this->headers[$key]);
@@ -2132,6 +2148,7 @@ private function setStopInternal($callback = null)
21322148
*
21332149
* Used by MultiCurl::stop() when making multiple parallel requests.
21342150
*/
2151+
#[\Override]
21352152
public function stop()
21362153
{
21372154
$this->headerCallbackData->stopRequest = true;

src/Curl/MultiCurl.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ public function addCurl(Curl $curl)
348348
/**
349349
* Close
350350
*/
351+
#[\Override]
351352
public function close()
352353
{
353354
foreach ($this->queuedCurls as $curl) {
@@ -376,6 +377,7 @@ public function setConcurrency($concurrency)
376377
* @param $key
377378
* @param $value
378379
*/
380+
#[\Override]
379381
public function setCookie($key, $value)
380382
{
381383
$this->cookies[$key] = $value;
@@ -386,6 +388,7 @@ public function setCookie($key, $value)
386388
*
387389
* @param $cookies
388390
*/
391+
#[\Override]
389392
public function setCookies($cookies)
390393
{
391394
foreach ($cookies as $key => $value) {
@@ -398,6 +401,7 @@ public function setCookies($cookies)
398401
*
399402
* @param $string
400403
*/
404+
#[\Override]
401405
public function setCookieString($string)
402406
{
403407
$this->setOpt(CURLOPT_COOKIE, $string);
@@ -408,6 +412,7 @@ public function setCookieString($string)
408412
*
409413
* @param $cookie_file
410414
*/
415+
#[\Override]
411416
public function setCookieFile($cookie_file)
412417
{
413418
$this->setOpt(CURLOPT_COOKIEFILE, $cookie_file);
@@ -418,6 +423,7 @@ public function setCookieFile($cookie_file)
418423
*
419424
* @param $cookie_jar
420425
*/
426+
#[\Override]
421427
public function setCookieJar($cookie_jar)
422428
{
423429
$this->setOpt(CURLOPT_COOKIEJAR, $cookie_jar);
@@ -431,6 +437,7 @@ public function setCookieJar($cookie_jar)
431437
* @param $key
432438
* @param $value
433439
*/
440+
#[\Override]
434441
public function setHeader($key, $value)
435442
{
436443
$this->headers[$key] = $value;
@@ -444,6 +451,7 @@ public function setHeader($key, $value)
444451
*
445452
* @param $headers
446453
*/
454+
#[\Override]
447455
public function setHeaders($headers)
448456
{
449457
if (ArrayUtil::isArrayAssoc($headers)) {
@@ -469,6 +477,7 @@ public function setHeaders($headers)
469477
*
470478
* @param $mixed boolean|callable
471479
*/
480+
#[\Override]
472481
public function setJsonDecoder($mixed)
473482
{
474483
if ($mixed === false) {
@@ -483,6 +492,7 @@ public function setJsonDecoder($mixed)
483492
*
484493
* @param $mixed boolean|callable
485494
*/
495+
#[\Override]
486496
public function setXmlDecoder($mixed)
487497
{
488498
if ($mixed === false) {
@@ -512,6 +522,7 @@ public function setProxies($proxies)
512522
* @param $option
513523
* @param $value
514524
*/
525+
#[\Override]
515526
public function setOpt($option, $value)
516527
{
517528
$this->options[$option] = $value;
@@ -536,6 +547,7 @@ public function setOpt($option, $value)
536547
*
537548
* @param $options
538549
*/
550+
#[\Override]
539551
public function setOpts($options)
540552
{
541553
foreach ($options as $option => $value) {
@@ -608,6 +620,7 @@ public function setRateLimit($rate_limit)
608620
*
609621
* @param $mixed
610622
*/
623+
#[\Override]
611624
public function setRetry($mixed)
612625
{
613626
$this->retry = $mixed;
@@ -619,6 +632,7 @@ public function setRetry($mixed)
619632
* @param $url
620633
* @param $mixed_data
621634
*/
635+
#[\Override]
622636
public function setUrl($url, $mixed_data = '')
623637
{
624638
$built_url = Url::buildUrl($url, $mixed_data);
@@ -748,6 +762,7 @@ public function start()
748762
/**
749763
* Stop
750764
*/
765+
#[\Override]
751766
public function stop()
752767
{
753768
// Remove any queued curl requests.
@@ -775,6 +790,7 @@ public function stop()
775790
*
776791
* @param $key
777792
*/
793+
#[\Override]
778794
public function unsetHeader($key)
779795
{
780796
unset($this->headers[$key]);

tests/psalm.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0"?>
22
<!-- TODO: Use errorLevel="1" -->
33
<psalm
4-
ensureOverrideAttribute="false"
54
errorLevel="4"
65
resolveFromConfigFile="true"
76
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

0 commit comments

Comments
 (0)