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

Weird behavior of iterator containing static class #8560

Closed
danog opened this issue Oct 10, 2022 · 1 comment
Closed

Weird behavior of iterator containing static class #8560

danog opened this issue Oct 10, 2022 · 1 comment
Labels

Comments

@danog
Copy link
Collaborator

danog commented Oct 10, 2022

https://psalm.dev/r/c4714e538a

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/c4714e538a
<?php

/**
 * @template TTKey
 * @template TTValue
 * 
 * @extends ArrayObject<TTKey, TTValue>
 */
class iter extends ArrayObject {
    /**
     * @return self<TTKey, TTValue>
     */
    public function stabilize(): self {
        return $this;
    }
}

class a {
    /**
     * @return iter<int, static>
     */
    public function ret(): iter {
        return new iter([$this]);
    }
}
class b extends a {}

$a = (new a)->ret();
$a = $a->stabilize();
/** @psalm-trace $a */;
Psalm output (using commit 028ac7f):

INFO: Trace - 30:23 - $a: iter<int, a&iter<int, a&static>>

INFO: UnusedVariable - 29:1 - $a is never referenced or the value is not used

@orklah orklah added the static label Oct 10, 2022
danog added a commit to nicelocal/psalm that referenced this issue Oct 14, 2022
danog added a commit to nicelocal/psalm that referenced this issue Oct 14, 2022
danog added a commit to nicelocal/psalm that referenced this issue Oct 17, 2022
orklah added a commit that referenced this issue Oct 19, 2022
@danog danog closed this as completed Oct 19, 2022
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