src/Mouf/Reflection/TypeDescriptor.php
public function isCompatible($value) {
		// If null, we are compatible
		if ($value === null) {
			return true;
		}
		
		// If the value passed is an array
		if (is_array($value)) {
			// Let's check if this type is an array.
			if (!$this->isArray()) {
				return false;
			}
			if (!$this->isAssociativeArray()) {
				// Let's check if the array passed in parameter has string values as keys.
				foreach ($value as $key=>$val) {
					if (is_string($key)) {
						return false;
					}
				}
			}
			// Now, let's test each subkey for compatibility
			foreach ($value as $key=>$val) {
				if (!$this->subType->isCompatible($val)) {
					return false;
				}
			}
			return true;
		} elseif ($value instanceof MoufInstanceDescriptor) {
			// Let's check if the instance descriptor is compatible with our type.
			if ($this->isPrimitiveType()) {
				return false;
			}
			if ($this->type == "array") {
				return false;
			}
			$classDescriptor = $value->getClassDescriptor();
			if (ltrim($this->type,'\\') == ltrim($classDescriptor->getName(), '\\')) {
				return true;
			}
			//$type = new MoufReflectionClass($this->getType());
			$result =  $classDescriptor->isSubclassOf($this->getType());
			return $result;
		} else {
			// The value is a primitive type.
			if ($this->isPrimitiveType()) {
				return true;
			} else {
				return false;
			}
		}
	}
public function isCompatible($value) {
		// If null, we are compatible
		if ($value === null) {
			return true;
		}
		
		// If the value passed is an array
		if (is_array($value)) {
			// Let's check if this type is an array.
			if (!$this->isArray()) {
				return false;
			}
			if (!$this->isAssociativeArray()) {
				// Let's check if the array passed in parameter has string values as keys.
				foreach ($value as $key=>$val) {
					if (is_string($key)) {
						return false;
					}
				}
			}
			// Now, let's test each subkey for compatibility
			foreach ($value as $key=>$val) {
				if (!$this->subType->isCompatible($val)) {
					return false;
				}
			}
			return true;
		} elseif ($value instanceof MoufInstanceDescriptor) {
			// Let's check if the instance descriptor is compatible with our type.
			if ($this->isPrimitiveType()) {
				return false;
			}
			if ($this->type == "array") {
				return false;
			}
			$classDescriptor = $value->getClassDescriptor();
			if (ltrim($this->type,'\\') == ltrim($classDescriptor->getName(), '\\')) {
				return true;
			}
			//$type = new MoufReflectionClass($this->getType());
			$result =  $classDescriptor->isSubclassOf($this->getType());
			return $result;
		} else {
			// The value is a primitive type.
			if ($this->isPrimitiveType()) {
				return true;
			} else {
				return false;
			}
		}
	}
public function isCompatible ( $ value ) { // If null, we are compatible if ( $ value === null ) { return true ; } // If the value passed is an array if ( is_array ( $ value ) ) { // Let's check if this type is an array. if ( ! $ this -> isArray ( ) ) { return false ; } if ( ! $ this -> isAssociativeArray ( ) ) { // Let's check if the array passed in parameter has string values as keys. foreach ( $ value as $ key => $ val ) { if ( is_string ( $ key ) ) { return false ; } } } // Now, let's test each subkey for compatibility foreach ( $ value as $ key => $ val ) { if ( ! $ this -> subType -> isCompatible ( $ val ) ) { return false ; } } return true ; } elseif ( $ value instanceof MoufInstanceDescriptor ) { // Let's check if the instance descriptor is compatible with our type. if ( $ this -> isPrimitiveType ( ) ) { return false ; } if ( $ this -> type == "array" ) { return false ; } $ classDescriptor = $ value -> getClassDescriptor ( ) ; if ( ltrim ( $ this -> type , '\\' ) == ltrim ( $ classDescriptor -> getName ( ) , '\\' ) ) { return true ; } //$type = new MoufReflectionClass($this->getType()); $ result = $ classDescriptor -> isSubclassOf ( $ this -> getType ( ) ) ; return $ result ; } else { // The value is a primitive type. if ( $ this -> isPrimitiveType ( ) ) { return true ; } else { return false ; } } }
Returns true if this type is compatible with the propertyDescriptor's value
passed in parameter.

@param string|array|MoufInstanceDescriptor|MoufInstanceDescriptor[] $instanceDescriptor
@return bool
Returns true if this type is compatible with the propertyDescriptor s value passed in parameter .