Count all elements in an array, or something in an object

@link http://php.net/manual/en/function.count.php
@link http://phpjs.org/functions/count/

@param variable
@param isRecursive bool
@returns {number}
340691
function (variable, isRecursive) {

            var property, result = 0;

            isRecursive = (typeof isRecursive !== "undefined" && isRecursive) ? true : false;

            if (variable === false ||
                variable === null ||
                typeof variable === "undefined"
            ) {
                return 0;

            } else if (variable.constructor !== Array && variable.constructor !== Object) {
                return 1;
            }

            for (property in variable) {

                if (variable.hasOwnProperty(property) && !$this.isFunc(variable[property])) {
                    result++;

                    if (isRecursive && variable[property] &&
                        (
                            variable[property].constructor === Array ||
                            variable[property].constructor === Object
                        )
                    ) {
                        result += this.count(variable[property], true);
                    }
                }
            }

            return result;
        }
1058903
protected function varInUse(array $tokens, $closeTagIndex, $variable) {
		if ($variable === '$this') {
			return false;
		}

		$i = $closeTagIndex + 1;
		while (isset($tokens[$i])) {
			if ($tokens[$i]['code'] === T_VARIABLE && $tokens[$i]['content'] === $variable) {
				return true;
			}
			$i++;
		}

		return false;
	}
1212002
public function match($var)
    {
        $ret = false;

        foreach ($this->_types as $type) {
            if (array_search($type, array("*", "mixed")) !== false) {
                $ret = true;
            } elseif (array_search($type, array("number", "numeric")) !== false) {
                $ret = is_numeric($var);
            } elseif (array_search($type, array("bool", "boolean")) !== false) {
                $ret = is_bool($var);
            } elseif ($type == "string") {
                $ret = is_string($var);
            } elseif ($type == "array") {
                $ret = is_array($var);
            } elseif ($type == "object") {
                $ret = is_object($var);
            } elseif ($type == "resource") {
                $ret = is_resource($var);
            } elseif ($type == "function") {
                $ret = is_callable($var);
            } elseif ($type == "scalar") {
                $ret = is_scalar($var);
            } else {
                $ret = is_a($var, $type);
            }

            if ($ret) {
                break;
            }
        }

        return $ret;
    }
504336
function isAlphaNumericArray( value ) {
	var len;
	if ( !isArray( value ) ) {
		return false;
	}
	len = value.length;
	if ( !len ) {
		return false;
	}
	for ( var i = 0; i < len; i++ ) {
		if ( !isAlphaNumeric( value[i] ) ) {
			return false;
		}
	}
	return true;
}
272301
public function __isset($var)
    {
        // Look for access of the form {ns:var}. We don't use
        // _children() here because we can break out of the loop
        // immediately once we find something.
        if (strpos($var, ':') !== false) {
            list($ns, $elt) = explode(':', $var, 2);
            foreach ($this->_element->childNodes as $child) {
                if ($child->localName == $elt && $child->prefix == $ns) {
                    return true;
                }
            }
        } else {
            foreach ($this->_element->childNodes as $child) {
                if ($child->localName == $var) {
                    return true;
                }
            }
        }
    }
673895
public static int count(float[] array, float val) {
        int count = 0;
        for (int i=0; i<array.length; i++) {
            if (array[i] == val) {
                count++;
            }
        }
        return count;
    }
1122563
static public function formatVariableToPci(ResponseVariable $var) {
        $value = $var->getValue();
        switch($var->getCardinality()){
            case 'single':
                if(strlen($value) === 0){
                    $formatted = ['base' => null];
                }else{
                    try {
                        $formatted = ['base' => [$var->getBaseType() => self::formatStringValue($var->getBaseType(), $value)]];
                    } catch (\common_exception_NotImplemented $e) {
                        // simply ignore unsupported data/type
                        $formatted = ['base' => null];
                    }
                }
                break;
            case 'ordered':
            case 'multiple':
                if(strlen($value) === 0){
                    $formatted = ['list' => [$var->getBaseType() => []]];
                }else{
                    preg_match_all('/([^\[\];<>]+)/', $value, $matches);
                    $list = [];
                    foreach($matches[1] as $valueString){
                        if(empty(trim($valueString))){
                            continue;
                        }

                        try {
                            $list[] = self::formatStringValue($var->getBaseType(), $valueString);
                        } catch (\common_exception_NotImplemented $e) {
                            // simply ignore unsupported data/type
                        }
                    }
                    $formatted = ['list' => [$var->getBaseType() => $list]];
                }
                break;
            default:
                throw new \common_Exception('unknown response cardinality');
        }
        return $formatted;
    }
732047
private static int countElementOccurrence(Object element, Object[] array) {

        int count = 0;
        for ( int i= 0; i < array.length; ++i ) {
            Object arrayElement = array[i];
            if (arrayElement != null && element != null) {
                if (arrayElement.equals(element)) {
                    count ++;
                }
            }
        }    
        return count;

    }
12309
public static function getVariableValues(Variable $variable) {

        $returnValue = array();

        $baseType = $variable->getBaseType();
        $cardinalityType = $variable->getCardinality();
        $value = $variable->getValue();
        
        // This only works if the variable has a value ;)
        if ($value !== null) {
            
            if ($baseType === BaseType::IDENTIFIER) {
            
                if ($cardinalityType === Cardinality::SINGLE) {
            
                    $returnValue[] = $value->getValue();
                }
                else if($cardinalityType === Cardinality::MULTIPLE) {
            
                    foreach($variable->getValue() as $value) {
            
                        $returnValue[] = $value->getValue();
                    }
                }
            }
        }

        return $returnValue;
    }
707966
function checkVariable(variable) {
			getModifyingReferences(variable.references).forEach(function(reference) {
				context.report(
					reference.identifier,
					ProblemMessages.noConstantAssign,
					{
						name: reference.identifier.name
					});
			});
		}
1256475
private int getVariableSize(int variable) {
    for (int i = 0; i < neighborIndices.length; i++) {
      if (neighborIndices[i] == variable) return getDimensions()[i];
    }
    return 0;
  }
148696
function varIsArray($var)
		{
			$var_ser = serialize($var);
			array_push($this->arrHistory, $var_ser);

			$this->makeTableHeader("array","array");
			if(Arrays::isArray($var)) {
				foreach($var as $key => $value) {
					$this->makeTDHeader("array", $key);

					//check for recursion
					if(Arrays::isArray($value)) {
						$var_ser = serialize($value);
						if(Arrays::inArray($var_ser, $this->arrHistory, TRUE))
							$value = "*RECURSION*";
					}

					if(Arrays::inArray(gettype($value), $this->arrType)) {
						$this->checkType($value);
					} else {
						$value = (trim($value)=="") ? "[empty string]" : $value;
						echo $value;
					}
					echo $this->closeTDRow();
				}
			} else {
				echo "<tr><td>" . $this->error("array") . $this->closeTDRow();
			}
			array_pop($this->arrHistory);
			echo "</table><hr class=thinDebugHr />";
		}
686354
function (mixedVar) {

            var emptyValues = [undefined, null, false, 0, "", "0"],
                i, length;

            for (i = 0, length = emptyValues.length; i < length; i++) {
                if (mixedVar === emptyValues[i]) {
                    return true;
                }
            }

            if (typeof mixedVar === "object") {
                if ($this.count(mixedVar) === 0) {
                    return true;
                }
            }

            return false;
        }
174977
public static int count(int[] array, int value) {
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if (array[i] == value) {
                count++;
            }
        }
        return count;
    }
92235
public function diffRecursive(array $array = [], $helperVariableForRecursion = null): self
    {
        // init
        $result = [];

        if (
            $helperVariableForRecursion !== null
            &&
            \is_array($helperVariableForRecursion)
        ) {
            $arrayForTheLoop = $helperVariableForRecursion;
        } else {
            $arrayForTheLoop = $this->getGenerator();
        }

        foreach ($arrayForTheLoop as $key => $value) {
            if ($value instanceof self) {
                $value = $value->getArray();
            }

            if (\array_key_exists($key, $array)) {
                if ($value !== $array[$key]) {
                    $result[$key] = $value;
                }
            } else {
                $result[$key] = $value;
            }
        }

        return static::create(
            $result,
            $this->iteratorClass,
            false
        );
    }
47297
function (variable) {
            return typeof variable === "object" &&
                /^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(variable)) &&
                variable.length !== undefined &&
                (variable.length === 0 || (typeof variable[0] === "object" && variable[0].nodeType > 0));
        }
380768
public static function assertIsNumeric($variable, Throwable $exception): bool
    {
        static::makeAssertion(\is_numeric($variable), $exception);
        return true;
    }