Fix curl error messages missing error code constant

Fix PHPStan static analysis errors (#929) left two placeholder property declarations behind, which shadow __get() so the lazy getters never ran. Since 11.0.5, curl error messages have lacked their (CURLE_...) suffix.
This commit is contained in:
Zach Borboa
2026-11-03 21:16:15 -05:00
parent 4d61037818
commit 59976fe1a0
2 changed files with 13 additions and 3 deletions
+4 -3
View File
@@ -4,6 +4,10 @@ declare(strict_types=1);
namespace Curl;
/**
* @property-read string $curlErrorCodeConstant
* @property-read array<int, string> $curlErrorCodeConstants
*/
class Curl extends BaseCurl
{
public const VERSION = '13.0.2';
@@ -92,9 +96,6 @@ class Curl extends BaseCurl
's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
];
public $curlErrorCodeConstant;
public $curlErrorCodeConstants;
private static $deferredProperties = [
'curlErrorCodeConstant',
'curlErrorCodeConstants',
+9
View File
@@ -1403,6 +1403,15 @@ class PHPCurlClassTest extends \PHPUnit\Framework\TestCase
$this->assertEquals('HTTP/1.1 401 Unauthorized', $test->curl->errorMessage);
}
public function testCurlErrorMessageIncludesErrorCodeConstant()
{
$curl = new Curl();
$curl->get('unsupported://127.0.0.1/');
$this->assertEquals(CURLE_UNSUPPORTED_PROTOCOL, $curl->curlErrorCode);
$this->assertEquals('CURLE_UNSUPPORTED_PROTOCOL', $curl->curlErrorCodeConstant);
$this->assertStringContainsString('(CURLE_UNSUPPORTED_PROTOCOL)', $curl->curlErrorMessage);
}
public function testRequestHeaderCaseSensitivity()
{
$content_type = 'application/json';