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

Allow multiple values for instanceof #80

Closed
theofidry opened this issue Sep 16, 2018 · 3 comments
Closed

Allow multiple values for instanceof #80

theofidry opened this issue Sep 16, 2018 · 3 comments

Comments

@theofidry
Copy link

As of now we have:

public static function isInstanceOf($value, $class, $message = '')

It would however be convenient to be able to do:

Assert::isInstanceOf($object, [Foo::class, Bar::class]);

instead of:

Assert::true($object instanceof Foo || $object instanceof Bar);

or another alternative

@DavidGarciaCat
Copy link
Contributor

I didn't check the commits history to confirm if the issue is older or newer, but I can see that this method is already implemented as part of the Assert class:

public static function isInstanceOfAny($value, array $classes, $message = '')

Please check it here:
https://github.com/webmozart/assert/blob/master/src/Assert.php#L393-L406

So I guess that this is requesting something that already exists, and the issue can be closed?

@theofidry
Copy link
Author

Oh indeed, thanks!

@DavidGarciaCat
Copy link
Contributor

Good to know this is what you need 😄

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