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

Inline declaration of global variable #3794

Closed
joehoyle opened this issue Jul 10, 2020 · 4 comments
Closed

Inline declaration of global variable #3794

joehoyle opened this issue Jul 10, 2020 · 4 comments

Comments

@joehoyle
Copy link
Contributor

In PhpStorm and other tools, it's typical to be able to hint globals similar to how you do variables, like:

function a() {
    /** @var string $token */
    global $token;
    echo $token;
}

In Psalm, this doesn't seem to be supported.

@psalm-github-bot
Copy link

Hey @joehoyle, can you reproduce the issue on https://psalm.dev ?

@joehoyle
Copy link
Contributor Author

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/33edceca2d
<?php

function a() {
    /** @var string $token */
	global $token;
    echo $token;
}
Psalm output (using commit d1ca68e):

INFO: MixedArgument - 6:10 - Argument 1 of echo cannot be mixed, expecting string

INFO: MissingReturnType - 3:10 - Method a does not have a return type, expecting void

@muglug
Copy link
Collaborator

muglug commented Jul 10, 2020

dupe of #1916

@muglug muglug closed this as completed Jul 10, 2020
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

No branches or pull requests

2 participants