143 Commits

Author SHA1 Message Date
Zach Borboa 056de7d13d Use default for Psalm ensureOverrideAttribute (#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)
2025-02-18 21:49:22 -05:00
Zach Borboa fd902b4b7c Fix CI (PHPUnit) (#918)
* Add shims for PHPUnit

* Fix PHPUnit error: undefined method returnValue()

1) CurlTest\PHPCurlClassTest::testMock
Error: Call to undefined method CurlTest\PHPCurlClassTest::returnValue()

* Fix PHPUnit risky test by restoring error handler before exception thrown

There was 1 risky test:

1) CurlTest\PHPCurlClassTest::testRequiredOptionCurlOptReturnTransferEmitsWarningPHPUnit10Plus
Test code or tested code did not remove its own error handlers

* Fix psalm errors

* Add attributes for version constraint

* Temporarily pin psalm to fix ci
2025-02-17 18:24:42 -05:00
Zach Borboa 634ee48552 Increase PHPStan strictness (#908)
* Enable color

* Increase PHPStan strictness

* Fix static analysis error

------ --------------------------------------------------
Line   src/Curl/MultiCurl.php
------ --------------------------------------------------
593    Variable $interval_seconds might not be defined.
        🪪  variable.undefined
------ --------------------------------------------------

* Increase PHPStan strictness

* Fix static analysis errors

------ -----------------------------------------------------------------
Line   scripts/bump_major_version.php
------ -----------------------------------------------------------------
8      Binary operation "+=" between string and 1 results in an error.
        🪪  assignOp.invalid
------ -----------------------------------------------------------------

------ -----------------------------------------------------------------
Line   scripts/bump_minor_version.php
------ -----------------------------------------------------------------
8      Binary operation "+=" between string and 1 results in an error.
        🪪  assignOp.invalid
------ -----------------------------------------------------------------

------ -----------------------------------------------------------------
Line   scripts/bump_patch_version.php
------ -----------------------------------------------------------------
8      Binary operation "+=" between string and 1 results in an error.
        🪪  assignOp.invalid
------ -----------------------------------------------------------------

* Fix static analysis errors

------ --------------------------------------------------------------------------------------------------------------------
Line   src/Curl/CaseInsensitiveArray.php
------ --------------------------------------------------------------------------------------------------------------------
132    PHPDoc tag @param has invalid value (void): Unexpected token "\n     * ", expected variable at offset 42 on line 4
        🪪  phpDoc.parseError
145    PHPDoc tag @param has invalid value (void): Unexpected token "\n     * ", expected variable at offset 44 on line 4
        🪪  phpDoc.parseError
158    PHPDoc tag @param has invalid value (void): Unexpected token "\n     * ", expected variable at offset 41 on line 4
        🪪  phpDoc.parseError
171    PHPDoc tag @param has invalid value (void): Unexpected token "\n     * ", expected variable at offset 40 on line 4
        🪪  phpDoc.parseError
197    PHPDoc tag @param has invalid value (void): Unexpected token "\n     * ", expected variable at offset 43 on line 4
        🪪  phpDoc.parseError
------ --------------------------------------------------------------------------------------------------------------------

* Fix static analysis errors

------ -----------------------------------------------------------------------------------
Line   src/Curl/MultiCurl.php
------ -----------------------------------------------------------------------------------
937    Comparison operation "<" between float and (array|float|int) results in an error.
        🪪  smaller.invalid
941    Comparison operation "<" between float and (array|float|int) results in an error.
        🪪  smaller.invalid
------ -----------------------------------------------------------------------------------

* Increase PHPStan strictness

* Fix static analysis errors

------ -------------------------------------------
Line   src/Curl/Decoder.php
------ -------------------------------------------
22     Offset '0' does not exist on list<mixed>.
        🪪  offsetAccess.notFound
41     Offset '0' does not exist on list<mixed>.
        🪪  offsetAccess.notFound
------ -------------------------------------------
2025-01-11 21:51:30 -05:00
teandr 1d05ac3511 Add public method getActiveCurls (#871) 2024-08-17 02:55:10 +00:00
Zach Borboa b722b1516a Fix afterSend not being called (#848) 2024-02-24 08:32:22 -05:00
Zach Borboa 93c5a18302 Fix PHP CS Fixer validation
Error occurred with a newer version of PHP CS Fixer being installed
(3.42.0 → 3.43.1).
2023-12-29 21:50:09 -05:00
Zach Borboa 4624486d56 Fix use of mb_strpos() causing error when polyfill is used
Error message:
    Uncaught ErrorException: iconv_strpos(): Detected an illegal character in input string in
    /var/www/site/vendor/symfony/polyfill-mbstring/Mbstring.php:536
2023-09-09 11:52:42 -07:00
Zach Borboa 11bd600918 Rename ::setError() to ::afterSend() 2023-08-25 06:39:12 -07:00
Zach Borboa 5e5d284a9b Implement Curl::setError() and MultiCurl::setError() 2023-08-22 20:20:47 -07:00
Zach Borboa cd924d10c3 Update PHP_CodeSniffer ruleset: PSR2 → PSR12 2023-06-30 01:23:37 -07:00
Zach Borboa 9bd4776b73 Apply additional coding standards 2023-06-30 00:37:30 -07:00
Zach Borboa 128a0c1ea2 Add PHP-CS-Fixer to check for unused imports 2023-06-24 19:33:48 -07:00
Zach Borboa 5427717469 Fix existing header overwritten after using MultiCurl::addCurl() 2023-06-08 19:18:32 -07:00
Zach Borboa 16380527e1 Fix #750: Implement abstract class BaseCurl for Curl and MultiCurl 2023-01-12 07:51:07 -08:00
Zach Borboa cb6a0e83e6 Pass MultiCurl options to new Curl instances earlier
Fix setting of options by passing of MultiCurl options to new Curl
instances earlier. Set options during the Curl initialization instead of
waiting until the request instance is configured in
MultiCurl::initHandle().
2022-11-05 13:48:30 -07:00
Zach Borboa a33b7bde4e Fix #707: Call MultiCurl::beforeSend() before each request is made 2022-07-01 11:21:57 -04:00
Zach Borboa 3c9e0c7dc9 Fix #718: Remove active curl handle when stopping requests early
Error message:
    Warning: curl_multi_info_read(): supplied resource is not a valid
    cURL handle resource in
    ./vendor/php-curl-class/php-curl-class/src/Curl/MultiCurl.php on
    line 999
2022-06-30 13:40:27 -04:00
Zach Borboa 8fdb39bbaf Fix #718: Ensure cURL handle is passed to curl_multi_info_read()
Error message:
    curl_multi_info_read(): supplied resource is not a valid cURL handle resource
2022-06-23 15:24:53 -04:00
Zach Borboa 523386ec01 Fix #714: Attempt to stop active requests when MultiCurl::stop() is called 2022-06-23 08:26:20 -04:00
Zach Borboa 12b5757c22 Implement MultiCurl::stop() 2022-03-10 18:29:48 -08:00
Zach Borboa dc4d0db091 Rename variable 2022-03-10 18:29:40 -08:00
Theodoros-Franz Gerakitis e999cb4e25 Fix #686: Build url without using data parameter
Also for PATCH, PUT & SEARCH requests
2021-11-23 23:23:08 -05:00
Zach Borboa 92a8f3bbe2 Fix #686: Build url without using data parameter 2021-11-20 23:43:44 -05:00
Zach Borboa 3d9acedb66 Correct the post/redirect/get logic when using MultiCurl::addPost() 2021-11-20 22:17:32 -05:00
Zach Borboa cd825550b2 Fix Curl::downloadFileName not being correctly set 2021-07-26 20:17:14 -04:00
Zach Borboa 7af4a8d383 Fix some errors caused by using strict types 2021-07-26 10:08:44 -04:00
Zach Borboa bb1a190071 Use strict types 2021-07-26 00:48:18 -04:00
Zach Borboa 73dfde67e2 Modernize type casting 2021-07-25 23:53:32 -04:00
Zach Borboa 250421927f Add additional Curl::set* and MultiCurl::set* helper methods 2021-06-17 11:14:29 -04:00
Zach Borboa fe829855cb Fix #670: Add additional checks before attempting to close curl handles 2021-06-09 20:58:33 -04:00
Zach Borboa b1f05c117a Clean up 2021-03-24 01:23:05 -04:00
Zach Borboa 0194365f71 Fix MultiCurl base url being overwritten by the most recently set url
Previously, when using MultiCurl and updating the url after instances
have already been initialized, the most recently specified base url
would be used for the requests. This change fixes using relative urls
with MultiCurl::add* methods and allows instance-specific base urls to
be used.
2021-03-23 23:56:29 -04:00
Zach Borboa e1ff6e870d Add import 2021-03-23 11:21:39 -04:00
Zach Borboa 06ca377f64 Add support for using relative urls with MultiCurl::add*() methods
This change allows setting a base url with MultiCurl and adding requests
using relative paths.

Fixes #628.
2021-03-23 11:03:39 -04:00
harry 0671a73de9 Fix base_url on MultiCurl 2021-03-22 23:12:08 -04:00
Zach Borboa 161f9aea63 Use short array syntax 2021-03-18 01:15:52 -04:00
Zach Borboa 7bf3868c6d Update docblock for params that expect callables or nulls
Would use callable type declarations, but the functions accept both a
callables and nulls which would require union types (available in 8.x).
2021-03-17 22:40:46 -04:00
Zach Borboa b94ce189b3 Add properties MultiCurl::startTime and MultiCurl::stopTime 2021-03-17 00:06:15 -04:00
Zach Borboa 1ef5fce3df Decrease curl_multi_select() timeout so pending requests may have more accurate start times 2021-03-16 21:02:58 -04:00
Zach Borboa af08135139 Fix flaky rate limit tests caused by inconsistent sleep times 2021-03-14 00:07:54 -05:00
Philipp Keck 933e0bb76b Fix close() under PHP8
Fixes #662

At least on some platforms, maybe always with PHP8, is_resource(curl_init())===false because it returns the new \CurlHandle type instead.
2021-03-13 18:23:09 -05:00
Zach Borboa eac149a259 Clean up 2021-03-13 17:37:47 -05:00
Zach Borboa 3d8e4c38c2 Allow passing an indexed array to MultiCurl::setHeaders() 2020-10-31 14:59:35 -07:00
Zach Borboa cea618a6c1 Update docblock with possible exceptions thrown 2020-10-30 21:32:43 -07:00
Zach Borboa cec296410a Clean up 2020-05-17 18:53:13 -07:00
Zach Borboa 976008d094 Implement rate limiting requests via MultiCurl::setRateLimit() 2020-05-16 22:01:15 -07:00
Zach Borboa ab407d6b25 Implement disableTimeout()
Implement Curl::disableTimeout() and MultiCurl::disableTimeout()
2020-05-09 09:19:35 -07:00
Zach Borboa 85c9a1a5e9 Clean up 2020-04-10 19:31:28 -07:00
harry 09006e0e26 Implement setInterface()
Implement Curl::setInterface() and MultiCurl::setInterface()
2020-04-10 12:02:41 +05:30
Zach Borboa cf9ab59780 Use setFile() 2020-01-14 21:01:04 -08:00