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

Wrong stubs for imap_delete and imap_undelete #8533

Closed
ppdeblieck opened this issue Oct 5, 2022 · 5 comments
Closed

Wrong stubs for imap_delete and imap_undelete #8533

ppdeblieck opened this issue Oct 5, 2022 · 5 comments
Labels
bug easy problems Issues that can be fixed without background knowledge of Psalm Help wanted internal stubs/callmap

Comments

@ppdeblieck
Copy link
Contributor

Wrong stubs for imap_delete and imap_undelete

https://www.php.net/imap_delete and https://www.php.net/imap_undelete shows the following function signatures:

imap_delete(IMAP\Connection $imap, string $message_nums, int $flags = 0): bool
imap_undelete(IMAP\Connection $imap, string $message_nums, int $flags = 0): bool

It seems that the definititions in Callmap.php are incorrect.

Now:

'imap_delete' => ['bool', 'imap'=>'IMAP\Connection', 'message_num'=>'int', 'flags='=>'int'],
'imap_undelete' => ['bool', 'imap'=>'IMAP\Connection', 'message_num'=>'int', 'flags='=>'int'],

Should be:

'imap_delete' => ['bool', 'imap'=>'IMAP\Connection', 'message_nums'=>'string', 'flags='=>'int'],
'imap_undelete' => ['bool', 'imap'=>'IMAP\Connection', 'message_nums'=>'string', 'flags='=>'int'],
@psalm-github-bot
Copy link

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

@ppdeblieck
Copy link
Contributor Author

Sure. See https://psalm.dev/r/8afa9e030c

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/8afa9e030c
<?php

declare(strict_types=1);

function psalmTest(IMAP\Connection $imapConnection): void 
{
    /**
     * According to https://www.php.net/imap_delete the second parameter should be a string
     */
    if(imap_delete($imapConnection, 'abcd', FT_UID)) {
        //success
    }
    
    /**
     * According to https://www.php.net/imap_undelete the second parameter should be a string
     */
    if(imap_undelete($imapConnection, 'abcd', FT_UID)) {
        //success
    }
    
    /**
     * According to https://www.php.net/imap_delete providing an int for $message_nums should be incorrect
     */
    if(imap_delete($imapConnection, 123, FT_UID)) {
        //success
    }
    
    /**
     * According to https://www.php.net/imap_undelete providing an int for $message_nums should be incorrect
     */
    if(imap_undelete($imapConnection, 123, FT_UID)) {
        //success
    }
}
Psalm output (using commit 028ac7f):

ERROR: InvalidArgument - 10:37 - Argument 2 of imap_delete expects int, 'abcd' provided

ERROR: InvalidArgument - 17:39 - Argument 2 of imap_undelete expects int, 'abcd' provided

@orklah
Copy link
Collaborator

orklah commented Oct 5, 2022

Thanks for the report!

Care to create the PR? 🙂

@ppdeblieck
Copy link
Contributor Author

Done; see #8537

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug easy problems Issues that can be fixed without background knowledge of Psalm Help wanted internal stubs/callmap
Projects
None yet
Development

No branches or pull requests

3 participants