-
Notifications
You must be signed in to change notification settings - Fork 651
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
Support no-seal-properties/no-seal-methods on classes to avoid emitting UndefinedMagicMethod #2588
Comments
Hey @TysonAndre, can you reproduce the issue on https://psalm.dev ? |
This just came up for us using Faker Faker allows for a plugin-based approach by: Note: The library has @method annotations to define the behaviour of the "built-in" plugins Due to df33405 this third party library is becoming sealed, which means psalm complains about the methods defined in any plugins. We cannot unseal the library without editing the source. If I remove the @method annotations psalm no longer complains |
I have the same problem with queue-interop, or specifically amqp-interop. In the base Context, createMessage returns a Message, but AmqpContext narrows the return type to AmqpMessage using a Are those kinds of overrides by design not meant to work with Psalm? PHPStorm on the other hand honors the use Interop\Amqp\AmqpContext;
use Interop\Amqp\AmqpMessage;
function sendMessage(AmqpContext $context, string $body, string $routingKey) {
/** @var AmqpMessage $amqpMessage */
$amqpMessage = $this->context->createMessage($body);
$amqpMessage->setRoutingKey($routingKey);
// ...
} |
I would also need a |
This can be closed now. |
Fixed in #9681 |
Some use cases, such as test frameworks, may rely on supporting unknown magic methods, while still having a few of their own magic methods.
It'd be useful if those classes could indicate psalm shouldn't emit UndefinedMagicMethod for any of their use cases.
@psalm-no-seal-methods
would be one way to do this. (or@no-seal-methods
https://github.com/ifwe/phockito/blob/bd1849468daf9539e052a3af9d11d981008397a8/Phockito.php#L617-L626 is one example of this - it supports both of the following syntaxes for the returned value of Phockito::when(...) (return() has a known type, someMethod() doesn't).
The text was updated successfully, but these errors were encountered: