Calculates functions

@param string  $function
@param string  $str
@param integer $strlen
@param integer $i
425142
private function calculateFunction($function, &$str, &$strlen, $i)
    {
        $j = ($function == 'sqrt') ? $i+4 : $i+3;
        $arg = null;

        while (true) {
            if (isset($str[$j])) {
                if ((strstr('+-', $str[$j]) && $arg === null)
                || preg_match('/([\d\.eE\+\-])|([\d\.INF])/', $str[$j])) {
                    $arg .= $str[$j];
                } elseif (strstr(' ', $str[$j]) && !strpbrk($arg, '0123456789')) {
                } else {
                    $arg = trim($arg);
                    break;
                }
                $j++;
            } else {
                break;
            }
        }

        $this->checkInf($arg);
        if (!is_numeric($arg)) {
            $this->correct = 0;
        } else {
            if ($function == 'exp') {
                $result = pow(M_E, $arg);
            } else {
                $result = $function($arg);
            }
        }

        if (is_numeric($result) && $this->correct) {
            $str1 = substr($str, 0, $i);
            $str2 = substr($str, $j);
            $str = $str1.' '.$result.$str2;
            $strlen = strlen($str);
        }
    }
1183687
static function strdiff($str1, $str2)
    {
        if(strlen($str1) < strlen($str2)) {
            $strtmp = $str1;
            $str1 = $str2;
            $str2 = $strtmp;
        }

        $start = stripos($str1, $str2);

        $result_str = substr($str1, $start + strlen($str2));

        return $result_str ? $result_str : '';
    }
668983
public void setFunctions(java.util.Collection<String> functions) {
        if (functions == null) {
            this.functions = null;
            return;
        }

        this.functions = new java.util.ArrayList<String>(functions);
    }
85017
private function typeCast(&$str)
  {
    if (is_numeric($str)) {
      $cast = intval($str);
      if ($str == (string) $cast) {
        $str = $cast;
      } else {
        $str = floatval($str);
      }
    }
  }
513080
protected function calculateFunctionNode(FunctionNode $functionNode)
    {
        $nodes = $functionNode->getChildNodes();

        $arguments = [];
        $argumentChildNodes = [];

        foreach ($nodes as $node) {
            if (is_a($node, SymbolNode::class)) {
                /** @var SymbolNode $node */

                if (is_a($node->getSymbol(), AbstractSeparator::class)) {
                    $containerNode = new ContainerNode($argumentChildNodes);
                    $arguments[] = $this->calculateContainerNode($containerNode);
                    $argumentChildNodes = [];
                } else {
                    $argumentChildNodes[] = $node;
                }
            } else {
                $argumentChildNodes[] = $node;
            }
        }

        if (sizeof($argumentChildNodes) > 0) {
            $containerNode = new ContainerNode($argumentChildNodes);
            $arguments[] = $this->calculateContainerNode($containerNode);
        }

        /** @var AbstractFunction $symbol */
        $symbol = $functionNode->getSymbolNode()->getSymbol();

        $result = $symbol->execute($arguments);

        return $result;
    }
370062
function strToUtf8($str)
	{
		$chars = unpack('C*', $str);
		$cnt = \count($chars);
		for($i=1;$i<=$cnt;$i++)
			$this->_charToUtf8($chars[$i]);
		return implode("",$chars);
	}
92932
protected function visitFunction(Node $function)
    {
        $this->metrics['functions']++;

        if (count($function->stmts) === 0) {
            // without implementation
            return;
        }

        $lines = $this->getLinesOfCode($function->stmts);

        foreach ($lines as $key => $count) {
            $this->metrics[$key] += $count;
        }

        $this->metrics['llocFunctions'] += $lines['lloc'];
    }
518158
function function_enabled($func) {
        // cache the list of disabled functions
        static $disabled = null;
        if ($disabled === null) $disabled = array_map('trim', array_map('strtolower', explode(',', ini_get('disable_functions'))));
        // cache the list of functions blacklisted by suhosin
        static $blacklist = null;
        if ($blacklist === null) $blacklist = extension_loaded('suhosin') ? array_map('trim', array_map('strtolower', explode(',', ini_get('  suhosin.executor.func.blacklist')))) : array();
        // checks if the function is really enabled
        return (function_exists($func) && !in_array($func, $disabled) && !in_array($func, $blacklist));
    }
427834
public static function compose(/* $function1, $function2, ... */)
    {
        $functions = func_get_args();

        if (count($functions) === 1) {
            static::validate($functions[0]);
            return $functions[0];
        }

        $firstFunction = array_shift($functions);

        static::validate($firstFunction);

        return function() use($firstFunction, $functions) {

            $partial = call_user_func_array(array('\Functionals\Functionals', 'compose'), $functions);

            return call_user_func($firstFunction, call_user_func_array($partial, func_get_args()));
        };
    }
1103672
function _i2osp($x, $xLen)
    {
        $x = $x->toBytes();
        if (strlen($x) > $xLen) {
            user_error('Integer too large');
            return false;
        }
        return str_pad($x, $xLen, chr(0), STR_PAD_LEFT);
    }
797171
function processFunction(funcNode) {
            const node = isEmbedded(funcNode) ? funcNode.parent : funcNode;

            if (!IIFEs && isIIFE(node)) {
                return;
            }
            let lineCount = 0;

            for (let i = node.loc.start.line - 1; i < node.loc.end.line; ++i) {
                const line = lines[i];

                if (skipComments) {
                    if (commentLineNumbers.has(i + 1) && isFullLineComment(line, i + 1, commentLineNumbers.get(i + 1))) {
                        continue;
                    }
                }

                if (skipBlankLines) {
                    if (line.match(/^\s*$/u)) {
                        continue;
                    }
                }

                lineCount++;
            }

            if (lineCount > maxLines) {
                const name = astUtils.getFunctionNameWithKind(funcNode);

                context.report({
                    node,
                    messageId: "exceed",
                    data: { name, lineCount, maxLines }
                });
            }
        }
1021009
public function writeString($str)
    {
        /**
         * This implementation supports only Basic Multilingual Plane
         * (BMP) characters (from 0x0000 to 0xFFFF) and doesn't support
         * "supplementary characters" (characters whose code points are
         * greater than 0xFFFF)
         * Java 2 represents these characters as a pair of char (16-bit)
         * values, the first from the high-surrogates range (0xD800-0xDBFF),
         * the second from the low-surrogates range (0xDC00-0xDFFF). Then
         * they are encoded as usual UTF-8 characters in six bytes.
         * Standard UTF-8 representation uses four bytes for supplementary
         * characters.
         */

        // convert input to a string before iterating string characters
        settype($str, 'string');

        $chars = $strlen = strlen($str);
        $containNullChars = false;

        for ($count = 0; $count < $strlen; $count++ ) {
            /**
             * String is already in Java 2 representation.
             * We should only calculate actual string length and replace
             * \x00 by \xC0\x80
             */
            if ((ord($str[$count]) & 0xC0) == 0xC0) {
                $addBytes = 1;
                if (ord($str[$count]) & 0x20 ) {
                    $addBytes++;

                    // Never used. Java2 doesn't encode strings in four bytes
                    // and we dont't support non-BMP characters
                    if (ord($str[$count]) & 0x10 ) {
                        $addBytes++;
                    }
                }
                $chars -= $addBytes;

                if (ord($str[$count]) == 0 ) {
                    $containNullChars = true;
                }
                $count += $addBytes;
            }
        }

        if ($chars < 0) {
            include_once 'Zend/Search/Lucene/Exception.php';
            throw new Zend_Search_Lucene_Exception('Invalid UTF-8 string');
        }

        $this->writeVInt($chars);
        if ($containNullChars) {
            $this->_fwrite(str_replace($str, "\x00", "\xC0\x80"));
        } else {
            $this->_fwrite($str);
        }
    }
1327699
public void updateAt(int i, int j, MatrixFunction function) {
        set(i, j, function.evaluate(i, j, get(i, j)));
    }
220955
public function length($str, $encoding = null)
	{
		$encoding or $encoding = $this->encoding;

		return function_exists('mb_strlen')
			? mb_strlen($str, $encoding)
			: strlen($str);
	}
61282
public final CALC function(Class<? extends Function> function, Object... values) {
        Function fn = CacheExtension.getFunction(function);
        FunctionData fd = new FunctionData(fn, values);
        this.infix.addFunction(fd);

        return getThis();
    }
307326
private double calcEntropy(String str) {

    HashMap<Character, Integer> freq = new HashMap<>();
    for (int i = 0; i < str.length(); i++) {
      char c = str.charAt(i);
      Integer count = freq.get(c);
      if (count == null) freq.put(c, 1);
      else freq.put(c, count + 1);
    }
    double sume = 0;
    int N = str.length();
    double n;
    for (char c : freq.keySet()) {
      n = freq.get(c);
      sume += -n / N * Math.log(n / N) / Math.log(2);
    }
    return sume;
  }
1333125
function entropy($str) {
		$len=strlen($str);
		return 4*min($len,1)+($len>1?(2*(min($len,8)-1)):0)+
			($len>8?(1.5*(min($len,20)-8)):0)+($len>20?($len-20):0)+
			6*(bool)(preg_match(
				'/[A-Z].*?[0-9[:punct:]]|[0-9[:punct:]].*?[A-Z]/',$str));
	}