Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the curl microsecond timing fields for HTTP requests #2844

Open
wants to merge 1 commit into
base: 1.10.x
Choose a base branch
from

Conversation

josephscott
Copy link

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 );

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.
@ondrejmirtes
Copy link
Member

  1. Please fix the test
  2. Please provide a test that fails without the changes in src/. Something that's incorrectly flagged is a great starting point.

@josephscott
Copy link
Author

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.

@staabm
Copy link
Contributor

staabm commented Dec 31, 2023

Cannot apply patch 0 (patches/Node.patch)!

thats a global macos problem with patch.

you will find the solution here cweagans/composer-patches#423 (comment)
namely run brew install gpatch and you can afterwards try building phpstan again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants