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

Cannot override variable type with phpdoc #2807

Closed
andrew-demb opened this issue Feb 13, 2020 · 6 comments
Closed

Cannot override variable type with phpdoc #2807

andrew-demb opened this issue Feb 13, 2020 · 6 comments

Comments

@andrew-demb
Copy link
Contributor

https://psalm.dev/r/0f31b34d81

Expected: no issues
Actual: UndefinedInterfaceMethod - 16:23 - Method BaseInterface::getsome does not exist

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/0f31b34d81
<?php

interface BaseInterface
{
    public function getBase(): string;
}

interface SomeInterface extends BaseInterface
{
    public function getSome(): ?string;
}

function send(BaseInterface $notification): bool
{
  /** @var SomeInterface $notification */
  echo $notification->getSome();
  
  return true;
}
Psalm output (using commit ae0b1a6):

ERROR: UndefinedInterfaceMethod - 16:23 - Method BaseInterface::getsome does not exist

@muglug
Copy link
Collaborator

muglug commented Feb 13, 2020

Sort-of dupe of #1916

@muglug muglug closed this as completed Feb 13, 2020
@andrew-demb
Copy link
Contributor Author

I don't think it's related.
echo added only for example.

https://psalm.dev/r/6d0482f6c1 with if, same problem

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/6d0482f6c1
<?php

interface BaseInterface
{
    public function getBase(): string;
}

interface SomeInterface extends BaseInterface
{
    public function getSome(): ?string;
}

function send(BaseInterface $notification): bool
{
  /** @var SomeInterface $notification */
  if (null !== $notification->getSome()) {
  	return false;
  }
  
  return true;
}
Psalm output (using commit 395cf58):

ERROR: UndefinedInterfaceMethod - 16:31 - Method BaseInterface::getsome does not exist

@muglug
Copy link
Collaborator

muglug commented Feb 13, 2020

Yes, more statements where @var docblocks currently have no effect

@andrew-demb
Copy link
Contributor Author

Now I get it. Thank you.

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