Assert\Assertion::notIsInstanceOf PHP Method

notIsInstanceOf() public static method

Assert that value is not instance of given class-name.
public static notIsInstanceOf ( mixed $value, string $className, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$className string
$message string | null
$propertyPath string | null
return boolean
    public static function notIsInstanceOf($value, $className, $message = null, $propertyPath = null)
    {
        if ($value instanceof $className) {
            $message = sprintf($message ?: 'Class "%s" was not expected to be instanceof of "%s".', static::stringify($value), $className);
            throw static::createException($value, $message, static::INVALID_NOT_INSTANCE_OF, $propertyPath, array('class' => $className));
        }
        return true;
    }

Usage Example

Exemplo n.º 1
0
 public function testValidNotIsInstanceOf()
 {
     Assertion::notIsInstanceOf(new \stdClass(), 'PDO');
 }