Check if a class is instance or extends from the expected instance.

@param mixed  $value
@param string $classFQN

@return bool
976122
private function isInstanceOf($value, $classFQN)
    {
        return is_object($value)
        && (strtolower(get_class($value)) === strtolower($classFQN) || \is_subclass_of($value, $classFQN, 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';
    }
1321219
public static function isValid($value)
    {
        if($value === null){
            return false;
        }

        $reflection = new \ReflectionClass(get_called_class());
        return in_array($value, $reflection->getConstants());
    }
629668
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;
			}
		}
	}
593388
protected function castToClass($value)
    {
        if (!class_exists($this->class)) {
            return $this->dontCast($value, "Class doesn't exist");
        }

        if (is_object($value) && is_a($value, $this->class)) {
            return $value;
        }

        $value = $this->createWithSetState($value);

        if (!is_a($value, $this->class)) {
            $class = $this->class;
            $value = new $class($value);
        }

        return $value;
    }
1114225
public function isSameTypeAs($value): bool
    {
        if (!is_array($value) && !$value instanceof Traversable) {
            return false;
        }

        foreach ($value as $key => $val) {
            if (!($this->key->isSameTypeAs($key) && $this->value->isSameTypeAs($val))) {
                return false;
            }
        }

        return true;
    }
287299
private function hasMap($value)
    {
        $class = $this->getClassName($value);

        return isset($this->loadedClasses[$class]) || $this->loader->hasMetadata($class);
    }
86902
public function isInstanceOf($className)
    {
        $this->doCheck(function ($value) use ($className) {
            $this->throwExceptionIfFalse(
                $value instanceof $className,
                'Failed assertion that %s is an instance of %s', $value, $className
            );
        });

        return $this;
    }
39276
private function isValidObjectClass($className)
    {
        //====================================================================//
        // Safety Check => Object Type is String
        if (!is_string($className)) {
            return "Object Type is Not a String";
        }
        //====================================================================//
        // Safety Check => Class Exists
        if (!class_exists($className)) {
            return "Object Class Not Found";
        }
        //====================================================================//
        // Safety Check => Class Extends
        if (!is_subclass_of($className, AbstractObject::class)) {
            return "Object Class MUST extends ".AbstractObject::class;
        }

        return true;
    }
987487
private final static function loadClass($fqcn)
    {
        $reflectionClass = new ReflectionClass($fqcn);
        $constants       = $reflectionClass->getConstants();

        foreach ($constants as $name => $value) {
            $instance = new $fqcn($fqcn, $name, $value);

            /* @var $instance Enum */
            if (is_callable([$instance, '__initEnum'])) {
                $instance->__initEnum();
            }

            $instanceConstructorName = '__' . $name;
            if (is_callable([$instance, $instanceConstructorName])) {
                $instance->$instanceConstructorName();
            }

            if (!isset(self::$instances[$fqcn])) {
                self::$instances[$fqcn] = [];
            }

            self::$instances[$fqcn][$name] = $instance;
        }
    }
753371
public static function isClassInstance($object, $class_name)
    {
        if (class_exists($class_name) && is_object($object)) {
            return (bool) ($object instanceof $class_name);
        }
        return false;
    }
1051702
protected function isValidPropertyValue($value)
    {
        return (is_scalar($value) ||
               (is_object($value) &&
                ((($value instanceof NodeInterface) && ($value->getGraph() === $this->graph)) ||
                 ($value instanceof Value))));
    }
667200
public static function isInternalType($value)
    {
        if (!is_object($value)) {
            return false;
        }

        if (class_exists('\MongoDB\BSON\Type')) {
            // mongodb extension for PHP 7
            return $value instanceof \MongoDB\BSON\Type;
        } else {
            // legacy mongo extension for PHP 5
            $mongoTypes = array(
                'MongoId',
                'MongoCode',
                'MongoDate',
                'MongoRegex',
                'MongoBinData',
                'MongoInt32',
                'MongoInt64',
                'MongoDBRef',
                'MongoMinKey',
                'MongoMaxKey',
                'MongoTimestamp'
            );

            return in_array(
                get_class($value),
                $mongoTypes
            );
        }
    }
772147
public function validate($value)
    {
        return ($value instanceof \stdClass && count((array) $value) <= $this->size)
            || parent::validate($value);
    }
450408
public function validateReflectionClassForAccessorVisibility($classFQN, $accessor)
    {
        $reflectionClass = $this->getReflectionClass($classFQN);
        if ($reflectionClass instanceof CoverFishMessageError) {
            return $reflectionClass;
        }

        $accessorResult = null;

        switch ($accessor) {
            case 'public':
                $accessorResult = $this->validateReflectionClassForAccessorPublic($reflectionClass);
                break;

            case 'protected':
                $accessorResult = $this->validateReflectionClassForAccessorProtected($reflectionClass);
                break;

            case 'private':
                $accessorResult = $this->validateReflectionClassForAccessorPrivate($reflectionClass);
                break;

            case '!public':
                $accessorResult = $this->validateReflectionClassForAccessorNotPublic($reflectionClass);
                break;

            case '!protected':
                $accessorResult = $this->validateReflectionClassForAccessorNotProtected($reflectionClass);
                break;

            case '!private':
                $accessorResult = $this->validateReflectionClassForAccessorNotPrivate($reflectionClass);
                break;

            default:
                return false;
        }

        if ($accessorResult instanceof CoverFishMessageError) {
            return $accessorResult;
        }

        return true;
    }
905830
@Override
    public boolean hasInstance(Scriptable value) {
        Scriptable proto = value.getPrototype();
        while (proto != null) {
            if (proto.equals(this))
                return true;
            proto = proto.getPrototype();
        }

        return false;
    }
9207
final public function instanceof(string $fqcn): InstanceofConfigurator
    {
        $this->instanceof[$fqcn] = $definition = new ChildDefinition('');

        return new InstanceofConfigurator($this, $definition, $fqcn, $this->path);
    }