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

"Undefined variable" even though passed by reference #2026

Closed
iluuu1994 opened this issue Mar 25, 2019 · 4 comments
Closed

"Undefined variable" even though passed by reference #2026

iluuu1994 opened this issue Mar 25, 2019 · 4 comments

Comments

@iluuu1994
Copy link
Contributor

This piece of code:

https://phpstan.org/r/2afd6c3d-870c-4d24-a53b-33abfcddef53

$nonce = random_bytes(16);
openssl_encrypt('data', 'aes-128-gcm', 'key', 0, $nonce, $tag);

Produces an error:

Undefined variable: $tag

I thought the functionMap was wrong but it's correct:

'openssl_encrypt' => ['string|false', 'data'=>'string', 'method'=>'string', 'key'=>'string', 'options='=>'int', 'iv='=>'string', '&rw_tag='=>'string', 'aad='=>'string', 'tag_length='=>'int'],

rw_tag is defined as a reference.

Any clue why this is happening?

@iluuu1994 iluuu1994 changed the title "Undefined variable" eventhough passed by reference "Undefined variable" even though passed by reference Mar 25, 2019
@ondrejmirtes
Copy link
Member

If it can create a new variable, it should be just &w_tag.

@iluuu1994
Copy link
Contributor Author

Why? A reference can be optional or non-optional:

https://3v4l.org/3acu7

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Mar 25, 2019 via email

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Mar 25, 2019 via email

iluuu1994 added a commit to iluuu1994/phpstan that referenced this issue Mar 25, 2019
iluuu1994 added a commit to iluuu1994/phpstan that referenced this issue Mar 25, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants