Convert profiler mark to string
@param array $mark
@return string
18728
protected static function _profilerFormatMark(array $mark)
    {
        return sprintf("%0.3f sec (+%.3f); %0.3f MB (%s%0.3f) - %s",
            (float)$mark['time'],
            (float)$mark['timeDiff'],
            ($mark['memory'] / 1024 / 1024),
            ($mark['memoryDiff'] / 1024 / 1024 >= 0) ? '+' : '',
            ($mark['memoryDiff'] / 1024 / 1024),
            $mark['label']
        );
    }
1035866
public function getPanel()
    {
        if (!$this->_profilers) {
            return '';
        }

        $html = '<h4>Database queries</h4>';
        
        foreach ($this->_profilers as $name => $profiler) {
            $html .= '<h4>Connection: '.$name.'</h4>';
            
            if (count($profiler) > 0 ) {
                $html .= '<ol>';  
                  
                foreach ($profiler as $event) {
                    if (in_array($event->getCode(), $this->getQueryEventCodes())) {
                        $query = htmlspecialchars($event->getQuery());
                        $time = round($event->getElapsedSecs() * 1000, 2);
                        $html .= '<li>' . $query . '<p><strong>Time: </strong>' . $time . ' ms</p></li>';
                    }
                }
                
                $html .= '</ol>';
            }
        }

        return $html;
    }
863758
public static function traceToString($trace)
    {
        if (!is_array($trace)) {
            return '';
        }

        $result = array();
        foreach ($trace as $index => $line) {
            if (isset($line['args']) && is_array($line['args'])) {
                $params = static::paramsToString($line['args']);
            } else {
                $params = '';
            }

            if (isset($line['file'])) {
                $result[] = sprintf(
                    "#%d %s:%d - %s(%s)", $index, $line['file'], $line['line'], $line['function'], $params
                );
            } else {
                $result[] = sprintf("#%d - %s(%s)", $index, $line['function'], $params);
            }
        }

        return implode(PHP_EOL, $result);
    }
45338
public function deleteMark(Mark $mark)
    {
        $this->om->remove($mark);
        $this->om->flush();
        // First of all update older mark events so as result would be 0
        $this->updateNewMarkEventResult($mark->getUser(), $mark->getId(), 0);
        // Then delete mark
        $deleteMarkEvent = new LogResultsDeleteMarkEvent($mark);
        $this->dispatcher->dispatch('log', $deleteMarkEvent);
    }
130481
public function toString($indent = null)
    {
        $indent = ($indent !== null)
                ? $this->getWhitespace($indent)
                : $this->getIndent();

        $return    = $this->prefix;
        $keys      = array_keys($this->container);
        $lastIndex = end($keys);
        foreach ($this->container as $index => $item) {
            $item = array_merge($this->defaultParams, (array) $item);
            $return .= vsprintf($this->wrapper, $item);
            if ($index !== $lastIndex) {
                $return .= $this->separator;
            }
        }
        $return .= $this->postfix;

        return preg_replace("/(\r\n?|\n)[ ]*/", '$1' . $indent, $return);
    }
480426
function getSignatureString() {
		$parts = array();

		foreach($this->fieldsInOrder as $f) {
			$val = $this->$f;
			if ($val === null) {
				$val = "";
			}
			elseif (is_bool($val)) {
				if ($val) {
					$val = "true";
				} else {
					$val = "false";
				}
			} elseif (is_array($val)) {
				// There are never more than 2 levels, we don't need recursive walk
				$valParts = array();
				foreach($val as $v) {
					if (is_scalar($v)) {
						$valParts[] = $v;
					} else {
						$valParts[] = implode("|", $v);
					}
				}
				$val = implode("|", $valParts);
			}
			$parts[] = $val;
		}

		foreach ($this->auxFieldsInOrder as $f) {
			$val = $this->$f;
			if ($val !== null) {
				$parts[] = $val;
			}
		}

		return implode("|", $parts);
	}
737910
public function convert($string, $profile = null)
	{
        $this->_chunks = array();
        $this->_nodes = array();
        $this->_parsed = '';
        $this->_stripped = '';
        $this->_string = $this->escape($string);

        // Change profile.
        if ($this->_profile !== $profile) {
        	$this->setProfile($profile);
        }
       
		return $this->parse();
	}
639502
public function mark($label)
    {
        $prefix = XTAINJoomlaBundle::STOPWATCH_PREFIX;
        $stopName = null;
        if (preg_match('/^(before|after)/', $label)) {
            $stopName = lcfirst(preg_replace('/^(before|after)/', '', $label));
        }
        if (self::$stopwatch !== null) {
            if ($stopName !== null) {
                if (self::$stopwatch->isStarted($prefix . $stopName)) {
                    self::$stopwatch->stop($prefix . $stopName);
                } else {
                    self::$stopwatch->start($prefix . $stopName, XTAINJoomlaBundle::STOPWATCH_CATEGORY_NAME);
                    if (preg_match('/^(after)/', $label)) {
                        self::$stopwatch->stop($prefix . $stopName, XTAINJoomlaBundle::STOPWATCH_CATEGORY_NAME);
                    }
                }
            } else {
                self::$stopwatch->start($prefix . $label, XTAINJoomlaBundle::STOPWATCH_CATEGORY_NAME);
            }
        }

        return parent::mark($label);
    }
1059730
public static function serializeTags(array $tags)
    {
        if (empty($tags))
            return '';

        self::validateTags($tags);
        $tagstrs = array();
        foreach ($tags as $tag)
            $tagstrs[] = $tag->toString(true);

        return implode(';', $tagstrs);
    }
133994
private function tokensToString(array $tokens): string
    {
        $lineCount = 0;
        $headerLines = [];
        $headerLines[] = $this->name.': ';
        $currentLine = &$headerLines[$lineCount++];

        // Build all tokens back into compliant header
        foreach ($tokens as $i => $token) {
            // Line longer than specified maximum or token was just a new line
            if (("\r\n" === $token) ||
                ($i > 0 && \strlen($currentLine.$token) > $this->lineLength)
                && 0 < \strlen($currentLine)) {
                $headerLines[] = '';
                $currentLine = &$headerLines[$lineCount++];
            }

            // Append token to the line
            if ("\r\n" !== $token) {
                $currentLine .= $token;
            }
        }

        // Implode with FWS (RFC 2822, 2.2.3)
        return implode("\r\n", $headerLines);
    }
215764
public static function attributes(array $attributes): string
    {
        ksort($attributes);

        $html = '';
        foreach ($attributes as $attribute => $value) {
            $value = !is_scalar($value) ? json_encode($value) : (string)$value;

            $html .= sprintf('%s="%s" ', self::escape($attribute), self::escape($value));
        }

        return rtrim($html);
    }
1159402
protected function writeFlags(array $entry)
    {
        $result = '';

        if (count($entry['flags']) > 0) {
            $result .= "#, " . implode(', ', $entry['flags']) . "\n";
        }

        if (isset($entry['@'])) {
            $result .= "#@ " . $entry['@'] . "\n";
        }

        return $result;
    }
239105
private function getStringName(array $name) : string
    {
        $names = array_reduce(array_keys($name), function (array $carry, $key) use ($name) : array {
            $carry[] .= $key . '=' . $name[(string) $key];

            return $carry;
        }, []);

        return implode(',', $names);
    }
1110217
private function sign(array $payload): string
    {
        $jsonConverter = new StandardConverter();
        $payload = array_merge(
            $payload,
            $this->getAdditionalPayload()
        );
        $headers = $this->getSignatureHeader();
        $signatureKey = $this->signatureKeyset->get($this->signatureKeyIndex);
        if ($signatureKey->has('kid')) {
            $headers['kid'] = $signatureKey->get('kid');
        }

        $jws = $this->jwsBuilder
            ->create()
            ->withPayload($jsonConverter->encode($payload))
            ->addSignature($signatureKey, $headers)
            ->build();

        $serializer = new JWSCompactSerializer($jsonConverter);

        return $serializer->serialize($jws, 0);
    }
1313345
public function when($mark, $value=null)
     {
        $markFilter = $this->matchingListener->markToArray($mark, $value, $this->knownMarks);
        $newMarkFilter = array_merge($this->markFilters, $markFilter);
        return new static($this->root, $this->marks, $newMarkFilter);
     }
366146
public static function normalizeBacktrace(array $trace)
    {
        $trace = new Data($trace);

        $args = [];

        foreach ($trace['args'] as $arg) {
            if (is_array($arg)) {
                $arg = 'Array';
            } elseif (is_object($arg)) {
                $arg = ReflectionHelper::getShortName($arg);
            } elseif (is_string($arg)) {
                if (Mbstring::strlen($arg) > 20) {
                    $arg = Utf8String::substr($arg, 0, 20) . '...';
                }

                $arg = Str::wrap($arg);
            } elseif ($arg === null) {
                $arg = 'NULL';
            } elseif (is_bool($arg)) {
                $arg = $arg ? 'TRUE' : 'FALSE';
            }

            $args[] = $arg;
        }

        return [
            'file' => !empty($trace['file']) ? static::replaceRoot($trace['file']) . ' (' . $trace['line'] . ')' : null,
            'function' => ($trace['class'] ? $trace['class'] . $trace['type'] : null) . $trace['function'] .
                sprintf('(%s)', implode(', ', $args)),
            'pathname' => $trace['file'],
            'line' => $trace['line']
        ];
    }
231710
private function generateDocumentProperties(array $metadata)
    {
        $lines = [];

        foreach ($metadata['properties'] as $property) {
            $lines[] = $this->generatePropertyDocBlock($property);
            $lines[] = $this->spaces . $property['visibility'] . ' $' . $property['field_name'] . ";\n";
        }

        return implode("\n", $lines);
    }