Add the curl microsecond timing fields for HTTP requests
These are the *_TIME_T fields that are included in the results from curl_getinfo(), when no option is provided.
See https://www.php.net/manual/en/function.curl-getinfo.php for more info on each field.
You can see that phpstan will incorrectly flag problems currently when using these fields:
<?php
declare( strict_types = 1 );
$url = "http://example.com/";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, false);
$response = curl_exec($ch);
if ( $response === false ) {
echo 'Curl error ( ' . curl_errno($ch) . ' ): ' . curl_error($ch);
exit;
}
$info = curl_getinfo($ch);
curl_close($ch);
echo "DNS: {$info['namelookup_time_us']}\n\n";
print_r( $info );
- Please fix the test
- Please provide a test that fails without the changes in
src/. Something that's incorrectly flagged is a great starting point.
This is the first time I've tried to build phpstan and have been running into issues. Unfortunately just getting it setup is not going well.
$ composer install
... ( many lines )
Gathering patches for dependencies. This might take a minute.
- Installing hoa/consistency (1.17.05.02): Extracting archive
- Installing hoa/protocol (1.17.01.14): Extracting archive
- Installing hoa/iterator (2.17.01.10): Extracting archive
- Installing hoa/compiler (3.17.08.08): Extracting archive
- Installing hoa/stream (1.17.02.21): Extracting archive
- Installing jetbrains/phpstorm-stubs (dev-master 92dda01): Extracting archive
- Applying patches for hoa/consistency
patches/Consistency.patch (0)
- Applying patches for hoa/protocol
patches/Node.patch (0)
Could not apply patch! Skipping. The error was: The process "patch '-p1' --no-backup-if-mismatch -d '/Users/josephscott/repo/phpstan-src/vendor/hoa/protocol' < '/Users/josephscott/repo/phpstan-src/patches/Node.patch'" exceeded the timeout of 300 seconds.
In Patches.php line 331:
Cannot apply patch 0 (patches/Node.patch)!
install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]
This is on the 1.10.x branch with PHP 8.2. So I am still trying to get to the point where I can run tests.
Cannot apply patch 0 (patches/Node.patch)!
thats a global macos problem with patch.
you will find the solution here https://github.com/cweagans/composer-patches/issues/423#issuecomment-1301026697
namely run brew install gpatch and you can afterwards try building phpstan again
This was resolved by https://github.com/phpstan/phpstan-src/pull/4279 which added all the listed value and more. So this can be closed @josephscott @ondrejmirtes