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

@psalm-type loses return type when declaring callable #9496

Closed
ptomulik opened this issue Mar 12, 2023 · 2 comments
Closed

@psalm-type loses return type when declaring callable #9496

ptomulik opened this issue Mar 12, 2023 · 2 comments

Comments

@ptomulik
Copy link
Contributor

ptomulik commented Mar 12, 2023

https://psalm.dev/r/4a64c9c24d

This changed somewhere between 5.7.7 and 5.8.0. For 5.7.7, both, $callback1 and $callback2 are of type callable():int.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/4a64c9c24d
<?php

/**
 * @psalm-suppress UnusedClass
 * @psalm-type TCallback1 callable():int
 * @psalm-type TCallback2 (callable():int)
 */
final class Test {
    /** @psalm-var TCallback1 */
    private callable $callback1;
    /** @psalm-var TCallback2 */
    private callable $callback2;
    
    /**
     * @psalm-param TCallback1 $callback1
     * @psalm-param TCallback2 $callback2
     */
    public function __construct(callable $callback1, callable $callback2) {
        /** @psalm-trace $callback1 */;
        /** @psalm-trace $callback2 */;
        $this->callback1 = $callback1;
        $this->callback2 = $callback2;
    }
}
Psalm output (using commit 44ffd5f):

INFO: Trace - 19:39 - $callback1: callable()

INFO: Trace - 20:39 - $callback2: callable():int

@ptomulik
Copy link
Contributor Author

Traced down to c72edef.

ptomulik added a commit to ptomulik/psalm that referenced this issue Mar 12, 2023
ptomulik added a commit to ptomulik/psalm that referenced this issue Mar 12, 2023
ptomulik added a commit to ptomulik/psalm that referenced this issue Mar 12, 2023
ptomulik added a commit to ptomulik/psalm that referenced this issue Mar 13, 2023
ptomulik added a commit to ptomulik/psalm that referenced this issue Mar 13, 2023
@orklah orklah closed this as completed in 6bbcfb2 Mar 16, 2023
orklah added a commit that referenced this issue Mar 16, 2023
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

1 participant