Skip to content

Add isNotInstanceOfAny assertion#352

Open
aymericcucherousset wants to merge 2 commits intowebmozarts:masterfrom
aymericcucherousset:feature/not-instance-of-any
Open

Add isNotInstanceOfAny assertion#352
aymericcucherousset wants to merge 2 commits intowebmozarts:masterfrom
aymericcucherousset:feature/not-instance-of-any

Conversation

@aymericcucherousset
Copy link
Copy Markdown

Fix #270

src/Assert.php Outdated
Comment on lines +556 to +562
* @template T of object
*
* @psalm-assert T $value
*
* @param T $value
*
* @return T
Copy link
Copy Markdown
Collaborator

@shadowhand shadowhand Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is correct, because there is no reason that $value has to be an object at all. For instance:

Assert::isNotInstanceOfAny(null, ['stdClass']); // true
Assert::isNotInstanceOfAny([42], ['stdClass']); // true
Assert::isNotInstanceOfAny(false, ['stdClass']); // true

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were right, there was no guarantee that values were objects.
I removed the of object constraint to reflect the actual behavior.

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

Successfully merging this pull request may close these issues.

Missing notInstanceOfAny

2 participants