Repository navigation
refactor: resolve CURL_HTTP_VERSION_3 through constant() - #10821
Conversation
neznaika0
left a comment
There was a problem hiding this comment.
Wouldn’t it be better to add a PHP version check? What’s the point of having a constant if you can’t use it? You can skip the test.
|
The constant is not purely guarded on the PHP version (8.4). It also depends if PHP is built with libcurl 7.66 or later:
|
|
Ok. We could add a check, but right now I can’t check whether the coverage percentage will change. And this depends on the phpunit configuration. if (PHP_VERSION_ID >= 80400) {
// @codeCoverageIgnoreStart
... |
|
Do you want something like: if (PHP_VERSION_ID >= 80400 && ! defined('CURL_HTTP_VERSION_3')) {
define('CURL_HTTP_VERSION_3', 30); // @codeCoverageIgnore
}? |
if (PHP_VERSION_ID >= 80400) {
// @codeCoverageIgnoreStart
// Use constant here
echo CURL_HTTP_VERSION_3;
// @codeCoverageIgnoreEnd
}I already answered above; that’s not how it works. The static analyzer won’t ignore the code at 8.3 and check it at 8.4. |
Description
Psalm 7 on PHP 8.3 reports
UndefinedConstantforCURL_HTTP_VERSION_3inCURLRequest::setCURLOptions()and inCURLRequestTest. The constant exists only from PHP 8.4, and the code defines it at runtime behind adefined()check, which Psalm doesn't follow. That fails the Psalm job on 4.8 since the HTTP/3 support landed. develop still runs Psalm 6, which doesn't flag it.CURLRequestnow defines the constant whenever it is missing, no longer only for version3.0, and reads it withconstant('CURL_HTTP_VERSION_3'). The test reads it the same way. The option values are unchanged.Checklist: