How to check if not instance of some class in symfony2

In Symfony2, you can check if an object is not an instance of a certain class using the "instanceof" keyword in combination with the "!" (not) operator. For example:

<?php

if (!$object instanceof SomeClass) {
    // Do something
}

Watch a course Learn object oriented PHP

This will check if the variable $object is not an instance of the class SomeClass, and if it is not, the code inside the if block will be executed.