603 Commits

Author SHA1 Message Date
Zach Borboa d05e75aa14 Check for composer installation failure (#924) 2025-02-17 20:34:41 -05:00
Zach Borboa 86eb0d1059 Merge branch 'master' into create-pull-request/patch 2025-02-17 18:53:56 -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
github-actions[bot] f9494a3e62 Update pre-commit dependencies 2025-02-17 18:04:47 +00:00
github-actions[bot] 736c692faa Update pre-commit dependencies 2025-01-29 18:04:54 +00:00
github-actions[bot] 2e56602b04 Update pre-commit dependencies 2025-01-28 18:04:48 +00:00
Zach Borboa 8259795c46 Fix CI tests (psalm) (#913)
* Display psalm version being run

* Update exclusions

* Use separate configuration for PHP 7.4

* Remove temporary workaround
2025-01-26 19:22:36 -05:00
Zach Borboa 8cbaf60cf0 Move pre-commit configuration out of root directory (#911) 2025-01-12 15:59:05 -05:00
Zach Borboa 29cca2e48b Move some configs out of the root directory (#910)
* Move flake8 configuration out of root directory

* Move PHPStan configuration out of root directory
2025-01-12 12:39:31 -05:00
Zach Borboa bd793d1287 Increase Psalm strictness (#909)
* Increase Psalm strictness

* Fix static analysis errors

ERROR: RedundantCast - ../src/Curl/CaseInsensitiveArray.php:91:16 - Redundant cast to bool (see https://psalm.dev/262)
        return (bool) array_key_exists(strtolower($offset), $this->data);

ERROR: RedundantCast - ../src/Curl/CaseInsensitiveArray.php:138:16 - Redundant cast to int<0, max> (see https://psalm.dev/262)
        return (int) count($this->data);

ERROR: RedundantCast - ../src/Curl/CaseInsensitiveArray.php:187:16 - Redundant cast to bool (see https://psalm.dev/262)
        return (bool) (key($this->data) !== null);

ERROR: ForbiddenCode - ../src/Curl/Curl.php:1765:13 - Unsafe var_dump (see https://psalm.dev/002)
            var_dump($value);

ERROR: ForbiddenCode - ../src/Curl/Curl.php:1770:13 - Unsafe var_dump (see https://psalm.dev/002)
            var_dump($value);

ERROR: InvalidOperand - ../src/Curl/Curl.php:1816:35 - Cannot concatenate with a value-of<TArray> (see https://psalm.dev/058)
                return $k . '=' . $v;
2025-01-11 23:11:26 -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
Zach Borboa 87fc9b3796 Use separate scripts to ci tests (#907)
* Run ci static analysis checks using scripts

* Clean up

* Move phpunit run to dedicated script

* Use run.sh and remove ci.sh

* Rename test scripts to be prefixed with "run_"

* Move static analysis runs to test script

* Clean up
2025-01-10 21:44:05 -05:00
Zach Borboa a11ecf6d7b Clean up (#904) 2025-01-09 22:30:06 -05:00
Zach Borboa a041ac97db Add PHP 8.4 as supported (#900)
* Add PHP 8.4 as supported

* Add temporary workaround that manually install psalm on currently supported versions
2024-12-04 09:39:33 -05:00
Zach Borboa c40be1084e Fix phpcs warning (#897)
FILE: ...e/runner/work/php-curl-class/php-curl-class/tests/PHPCurlClass/UrlTest.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 14 | WARNING | The $escape parameter must be passed when calling fgetcsv() as
    |         | its default value will change in a future PHP version.
    |         | (PHPCompatibility.ParameterValues.RemovedProprietaryCSVEscaping.DeprecatedParamNotPassed)
 15 | WARNING | The $escape parameter must be passed when calling fgetcsv() as
    |         | its default value will change in a future PHP version.
    |         | (PHPCompatibility.ParameterValues.RemovedProprietaryCSVEscaping.DeprecatedParamNotPassed)
--------------------------------------------------------------------------------
2024-10-07 21:49:42 -04:00
Zach Borboa c808484e5b Drop support for PHP 7.3 (#889) 2024-08-21 22:56:50 -04:00
Zach Borboa 10ea095b5d Drop support for PHP 7.2 (#888) 2024-08-21 22:27:45 -04:00
Zach Borboa d6ffbcfb44 Drop support for PHP 7.1 (#887) 2024-08-21 21:40:39 -04:00
Zach Borboa 63bddcd230 Drop support for PHP 7.0 (#880) 2024-08-17 09:15:46 -04:00
Zach Borboa b722b1516a Fix afterSend not being called (#848) 2024-02-24 08:32:22 -05:00
Zach Borboa d6ede93924 Fix static type checker error
Error message:
    error: Import "urlparse" could not be resolved
    (reportMissingImports)
2023-10-21 19:19:57 -07:00
Zach Borboa a6e6110051 Update checks for decoding gzip-encoded responses 2023-08-29 07:01:18 -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 c745e59532 Merge branch 'master' into master 2023-07-06 20:46:55 -07:00
Robin van der Vliet 94d8cf948f Replace isset with null coalescing operator (#800) 2023-07-06 20:41:38 -07:00
Zach Borboa 0d7ff95736 Add coding standards rule to use the null coalescing operator ?? where possible 2023-07-05 20:41:54 -07:00
Zach Borboa efe4f69683 Normalize strings 2023-07-01 09:57:03 -07:00
Zach Borboa 6c49609b9f Format python files 2023-07-01 09:57:03 -07:00
Zach Borboa 314f373a17 Move long lines check to PHP_CodeSniffer 2023-07-01 06:43:51 -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 b921ac3c52 Merge branch 'master' into master 2023-06-26 04:10:29 -07:00
Zach Borboa 2f532ab2b8 Merge branch 'master' into use-short-array-syntax 2023-06-26 02:57:15 -07:00
Zach Borboa 50320065ce Add coding standards rule to error on long array syntax 2023-06-25 16:02:46 -07:00
Zach Borboa 128a0c1ea2 Add PHP-CS-Fixer to check for unused imports 2023-06-24 19:33:48 -07:00
Robin van der Vliet c45f8e22de Use short array syntax 2023-06-23 19:50:18 +02:00
Zach Borboa 76e74fdc44 Improve and add tests for Curl::fastDownload() 2023-06-13 02:52:59 -07:00
Zach Borboa 2bb2f32087 Make method to display curl option value public 2023-06-12 20:27:16 -07:00
Zach Borboa bbf1e1417b Add test server support for specifying which requests fail and succeed 2023-06-12 19:31:49 -07:00
Zach Borboa 5427717469 Fix existing header overwritten after using MultiCurl::addCurl() 2023-06-08 19:18:32 -07:00
Zach Borboa 1b2e2d446f Return JSON from the retry test server endpoint 2023-06-03 04:50:41 -07:00
Zach Borboa c37bb58a48 Make function public 2023-05-23 20:35:36 -07:00
Zach Borboa 1c270272c8 Update Curl::diagnose() to detect bit flags with negative values 2023-05-20 13:32:44 -07:00
Zach Borboa 2a73070caf Run PHPCompatibility on PHP 7.2 and higher
Error message:

++ phpcs_to_use=vendor/bin/phpcs
++ vendor/bin/phpcs --version
PHP_CodeSniffer version 3.7.2 (stable) by Squiz (http://www.squiz.net)
++ vendor/bin/phpcs --extensions=php '--ignore=*/vendor/*' --standard=tests/ruleset.xml -p -s .
W...........................................................  60 / 116 (52%)
........................................................     116 / 116 (100%)

FILE: ...me/runner/work/php-curl-class/php-curl-class/examples/custom.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 1 | WARNING | IMPORTANT: Please be advised that for the most
   |         | reliable PHPCompatibility results, PHP 7.2 or higher
   |         | should be used. Support for lower versions will be
   |         | dropped in the foreseeable future. You are currently
   |         | using PHP 7.0.33-65+ubuntu22.04.1+deb.sury.org+1.
   |         | Please upgrade your PHP installation to version 7.2 or
   |         | higher.
   |         |
   |         | To disable this notice, add
   |         | --exclude=PHPCompatibility.Upgrade.LowPHP to your
   |         | command or add <exclude
   |         | name="PHPCompatibility.Upgrade.LowPHP.BelowRecommended_7_2"/>
   |         | to your custom ruleset.
   |         |
   |         | Thank you for using PHPCompatibility!
   |         | (PHPCompatibility.Upgrade.LowPHP.BelowRecommended_7_2)
----------------------------------------------------------------------
2023-05-20 10:41:23 -07:00
Zach Borboa a304084a61 Display bit flags in use when calling Curl::diagnose()
This change attempts to determine which underlying constants were
bitmasked together to reach the resulting value passed to curl_setopt()
using Curl::setOpt().
2023-05-18 16:11:07 -07:00
Zach Borboa f7b216a3d9 Fix #777: Handle missing content-type response header in Curl::diagnose() 2023-05-15 19:33:59 -07:00
Zach Borboa 5b39126488 Update article in Curl::diagnose() Allow header warning 2023-05-07 02:50:08 -07:00
Zach Borboa dfdd2f5fb0 Remove use of array_merge() inside loop 2023-03-11 05:01:00 -08:00
Zach Borboa 3971c2f081 Fix sed portability 2023-03-10 04:31:11 -08:00