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

False positive on stream_get_meta_data #10887

Closed
pincher2012 opened this issue Apr 16, 2024 · 5 comments
Closed

False positive on stream_get_meta_data #10887

pincher2012 opened this issue Apr 16, 2024 · 5 comments
Labels
Milestone

Comments

@pincher2012
Copy link

pincher2012 commented Apr 16, 2024

Bug report

Metadata of stream_socket_client does not contains uri item, but phpstan report as error.

Code snippet that reproduces the problem

https://phpstan.org/r/67303fbb-4df5-49f9-b451-58a88d118aa7

Expected output

Phpstan does not alert about error

Did PHPStan help you today? Did it make you happy in any way?

PHPStan is awesome!

@ondrejmirtes
Copy link
Member

When is the uri index missing?

@pincher2012
Copy link
Author

  1. Create resource with stream_socket_client
  2. Get stream metadata with stream_get_meta_data
  3. var_dump metadata
array(8) {
  ["crypto"]=>
  array(4) {
    ["protocol"]=>
    string(7) "TLSv1.2"
    ["cipher_name"]=>
    string(27) "ECDHE-RSA-AES128-GCM-SHA256"
    ["cipher_bits"]=>
    int(128)
    ["cipher_version"]=>
    string(11) "TLSv1/SSLv3"
  }
  ["timed_out"]=>
  bool(false)
  ["blocked"]=>
  bool(true)
  ["eof"]=>
  bool(false)
  ["stream_type"]=>
  string(14) "tcp_socket/ssl"
  ["mode"]=>
  string(2) "r+"
  ["unread_bytes"]=>
  int(0)
  ["seekable"]=>
  bool(false)
}

As you see, the composition of the fields is different from another case when you use fopen and url as parameter.

https://www.php.net/manual/en/function.stream-get-meta-data.php

@ondrejmirtes
Copy link
Member

Yeah, so we just need to make the url key optional.

@ondrejmirtes
Copy link
Member

Fixed phpstan/phpstan-src#3024

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants