Checks if the object is of this type or has this type as one of its parents

@param string $type  class name of type being required
@param mixed  $value Some PHP value to be tested

@return boolean True if $object has type of $type
961298
protected function isObjectOfSameType($type, $value)
    {
        if (false === is_object($value)) {
            return false;
        }

        return is_a($value, $type);
    }
1182870
public function checkType($value)
    {
        if (isset($this->name) && null !== $this->name) {
            $fn = 'is_'.$this->name;

            return $fn($value);
        }

        throw new \Exception('Invalid name or name not defined for primitive type.');
    }
488009
protected function checkType($value)
    {
        if (RuntimeUtils::isQtiScalarDatatypeCompliant($value)) {
            return;
        } else {
            $value = (gettype($value) === 'object') ? get_class($value) : $value;
            $msg = "The OperandsCollection only accepts QTI Runtime compliant values, '" . $value . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
2359
public static function isTruthy($value)
    {
        if (!$value) {
            return $value === 0 || $value === '0';
        } elseif ($value instanceof \stdClass) {
            return (bool) get_object_vars($value);
        } else {
            return true;
        }
    }
115260
protected function _getType($value)
    {
        if (is_object($value)) {
            try {
                return self::getShortClassname($value);
            } catch (\InvalidArgumentException $e) {
                return null;
            }
        }

        if (is_array($value)) {
            return 'array';
        }

        return 'scalar';
    }
1219509
protected static function isValidValue(TypeInterface $type, $value)
    {
        if ($type instanceof NonNullModifier) {
            if (NULL === $value) {
                return FALSE;
            }

            return self::isValidValue($type->getWrappedType(), $value);
        }

        if ($value === NULL) {
            return TRUE;
        }

        if ($type instanceof ListModifier) {
            $itemType = $type->getWrappedType();
            if (is_array($value)) {
                foreach ($value as $item) {
                    if (!self::isValidValue($itemType, $item)) {
                        return FALSE;
                    }
                }

                return TRUE;
            } else {
                return self::isValidValue($itemType, $value);
            }
        }

        if ($type instanceof InputObjectType) {
            $fields = $type->getFields();
            foreach ($fields as $fieldName => $field) {
                if (!self::isValidValue($field->getType(), isset($value[$fieldName]) ? $value[$fieldName] : NULL)) {
                    return FALSE;
                }
            }

            return TRUE;
        }

        if ($type instanceof ScalarType || $type instanceof EnumType) {
            return NULL !== $type->coerce($value);
        }

        return FALSE;
    }
1143296
protected function verifyCorrectType($type, $value)
    {
        // Switch various types
        switch ($type) {
            case 'string':
                if (!is_string($value)) {
                    throw new SetterGetterException('String type expected', 3);
                }
                break;

            case 'number':
                if (!is_numeric($value)) {
                    throw new SetterGetterException('Number type expected', 4);
                }
                break;

            case 'array':
                if (!is_array($value)) {
                    throw new SetterGetterException('Array type expected', 5);
                }
                break;

            case 'object':
                if (!is_object($value)) {
                    throw new SetterGetterException('Object type expected.', 6);
                }
                break;

            default:
                // If a @var type is given in annotation and we haven't received
                // proper type.
                if (!is_null($type) && !$value instanceof $type) {
                    throw new SetterGetterException('Instance of ' . $type . ' expected.', 7);
                }
                break;
        }
    }
445009
public static function isTypeOf($value, $type) {
        switch ($type) {
            case self::ARGUMENT_ARRAY:
                ArrayHelper::isArray($value);
                break;
            case self::ARGUMENT_BOOLEAN:
                BooleanHelper::isBoolean($value);
                break;
            case self::ARGUMENT_DATE:
                DateTimeHelper::isDate($value);
                break;
            case self::ARGUMENT_DOUBLE:
                DoubleHelper::isDouble($value);
                break;
            case self::ARGUMENT_FLOAT:
                FloatHelper::isFloat($value);
                break;
            case self::ARGUMENT_INTEGER:
                IntegerHelper::isInteger($value);
                break;
            case self::ARGUMENT_NUMBER:
                NumberHelper::isNumber($value);
                break;
            case self::ARGUMENT_OBJECT:
                ObjectHelper::isObject($value);
                break;
            case self::ARGUMENT_RESOURCE:
                ResourceHelper::isResource($value);
                break;
            case self::ARGUMENT_STRING:
                StringHelper::isString($value);
                break;
            case self::ARGUMENT_TIMESTAMP:
                TimestampHelper::isTimestamp($value);
                break;
            default:
                throw new IllegalArgumentException("The type \"" . $type . "\" is not implemented");
        }
        return true;
    }
723219
public function skip(int $type, $value = null) : bool
    {
        if ($this->accept($type, $value)) {
            $this->advance();

            return true;
        }

        return false;
    }
1213362
public static function IsDerivedSubtype( $value )
	{
		if ( $value instanceof Integer )
	        return true;

	    switch ( Type::FromValue( $value )->getTypeCode() )
	    {
	        case TypeCode::SByte:
	        case TypeCode::Int16:
	        case TypeCode::Int32:
	        case TypeCode::Int64:
	        case TypeCode::Byte:
	        case TypeCode::UInt16:
	        case TypeCode::UInt32:
	        case TypeCode::UInt64:
	            return true;

	        default:
	            return false;
	    }
	}
985067
private function validateType($type, $value): bool
    {
        if (substr($type, 0, 1) === '[' && substr($type, -1) === ']') { // Array of a specified type?
            if ($this->validateType('array', $value) === false) {
                return false;
            }
            $itemType = substr($type, 1, -1);
            foreach ($value as $i => $item) {
                if ($this->validateType($itemType, $item) === false) {
                    return false;
                }
            }
            return true;
        }

        if (is_subclass_of($type, AbstractAnnotation::class)) {
            $type = 'object';
        }

        return $this->validateDefaultTypes($type, $value);
    }
917290
public function containsValue($value): bool {
        TypeHelper::validateValue($value, $this);
        foreach ($this as $v) {
            if ($value == $v) {
                return true;
            }
        }

        return false;
    }
132040
protected function isValueTypeValidForExactConditions($value)
    {
        if (is_string($value) || is_bool($value) || is_int($value) || is_float($value)) {
            return true;
        }

        return false;
    }
388474
public function check($typeName, $value)
    {
        switch ($typeName) {
            case static::COMPOUND_ARRAY:
                return is_array($value);
            case static::COMPOUND_OBJECT:
                return is_object($value);
            default:
                return false;
        }
    }
345178
public function matches($value): bool
    {
        if (!interface_exists($this->type) && !class_exists($this->type)) {
            throw new UndefinedTypeException($this->type);
        }

        return $value instanceof $this->type;
    }
359025
private function isBlock($type, $value = NULL)
    {
        return $this->_current == $type
        && (NULL === $value ? true : $this->_blocks[$this->_pos][3] == $value);
    }
688187
public static function resource($value, $type = null): bool
    {
        if ($type !== null) {
            return is_resource($value) && $type === get_resource_type($value);
        }

        return is_resource($value);
    }