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

$http_response_header reported undefined even after http file_get_contents call #2608

Open
L1Q opened this issue Mar 17, 2024 · 1 comment
Open
Labels

Comments

@L1Q
Copy link

L1Q commented Mar 17, 2024

In PHP 4+, $http_response_header is populated in local scope with response headers of outgoing HTTP requests when using HTTP wrapper such as file_get_contents with a url as filename.

example from php.net:

function get_contents() {
  file_get_contents("http://example.com");
  var_dump($http_response_header); // variable is populated in the local scope
}
get_contents();
var_dump($http_response_header); // a call to get_contents() does not populate the variable outside the function scope

current behavior

phpactor still reports $http_response_header as "Undefined variable"

running neovim v0.9.5 with phpactor 2024.03.09.0, installed through nvim-lspconfig

@dantleech
Copy link
Collaborator

this is an edge case (i didn't even know this "feature" existed).

if somebody wants to implement this they can add a new "stub" like

class InArrayStub implements FunctionStub
with a test like this: https://github.com/phpactor/phpactor/blob/master/lib/WorseReflection/Tests/Inference/function/in_array.test

it should be fairly trivail to:

  • check to see the the file has a HTTP scheme
  • add the appropriate variarbles to the $frame if it doesn.

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

No branches or pull requests

2 participants