<commit_before><?php
/**
 * PHP Token Reflection
 *
 * Version 1.0beta1
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this library in the file license.txt.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */

namespace TokenReflection;

/**
 * Docblock parser.
 */
class ReflectionAnnotation
{
	/**
	 * Main description annotation identifier.
	 *
	 * White space at the beginning on purpose.
	 *
	 * @var string
	 */
	const SHORT_DESCRIPTION = ' short_description';

	/**
	 * Sub description annotation identifier.
	 *
	 * White space at the beginning on purpose.
	 *
	 * @var string
	 */
	const LONG_DESCRIPTION = ' long_description';

	/**
	 * Parses reflection object documentation.
	 *
	 * @param ReflectionBase $reflection Reflection object
	 * @return array
	 */
	public static function parse(ReflectionBase $reflection)
	{
		static $emptyResult = array();

		$docblock = $reflection->getInheritedDocComment();

		if (false === $docblock) {
			return $emptyResult;
		}

		// Parse docblock
		$result = $emptyResult;
		$name = self::SHORT_DESCRIPTION;
		$docblock = trim(preg_replace(array('~^/\\s*\\*\\*~', '~\\*/$~'), '', $docblock));
		foreach (explode("\n", $docblock) as $line) {
			$line = preg_replace('~^\\*\\s*~', '', trim($line));

			// End of short description
			if ('' === $line && self::SHORT_DESCRIPTION === $name) {
				$name = self::LONG_DESCRIPTION;
				continue;
			}

			// @annotation
			if (preg_match('~^@([\\S]+)\\s*(.*)~', $line, $matches)) {
				$name = $matches[1];
				$result[$name][] = $matches[2];
				continue;
			}

			// Continuation
			if (self::SHORT_DESCRIPTION === $name || self::LONG_DESCRIPTION === $name) {
				if (!isset($result[$name])) {
					$result[$name] = $line;
				} else {
					$result[$name] .= "\n" . $line;
				}
			} else {
				$result[$name][count($result[$name]) - 1] .= "\n" . $line;
			}
		}

		array_walk_recursive($result, function(&$value) {
			$value = trim($value);
		});

		return $result;
	}
}<commit_msg>{@*} support<commit_after><?php
/**
 * PHP Token Reflection
 *
 * Version 1.0beta1
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this library in the file license.txt.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */

namespace TokenReflection;

/**
 * Docblock parser.
 */
class ReflectionAnnotation
{
	/**
	 * Main description annotation identifier.
	 *
	 * White space at the beginning on purpose.
	 *
	 * @var string
	 */
	const SHORT_DESCRIPTION = ' short_description';

	/**
	 * Sub description annotation identifier.
	 *
	 * White space at the beginning on purpose.
	 *
	 * @var string
	 */
	const LONG_DESCRIPTION = ' long_description';

	/**
	 * Parses reflection object documentation.
	 *
	 * @param ReflectionBase $reflection Reflection object
	 * @return array
	 */
	public static function parse(ReflectionBase $reflection)
	{
		static $emptyResult = array();

		$docblock = $reflection->getInheritedDocComment();

		if (false === $docblock) {
			return $emptyResult;
		}

		// Parse docblock
		$result = $emptyResult;
		$name = self::SHORT_DESCRIPTION;
		$docblock = trim(preg_replace(array('~^/\\s*\\*\\*~', '~\\*/$~'), '', $docblock));
		foreach (explode("\n", $docblock) as $line) {
			$line = preg_replace('~^\\*\\s*~', '', trim($line));

			// End of short description
			if ('' === $line && self::SHORT_DESCRIPTION === $name) {
				$name = self::LONG_DESCRIPTION;
				continue;
			}

			// @annotation
			if (preg_match('~^@([\\S]+)\\s*(.*)~', $line, $matches)) {
				$name = $matches[1];
				$result[$name][] = $matches[2];
				continue;
			}

			// Continuation
			if (self::SHORT_DESCRIPTION === $name || self::LONG_DESCRIPTION === $name) {
				if (!isset($result[$name])) {
					$result[$name] = $line;
				} else {
					$result[$name] .= "\n" . $line;
				}
			} else {
				$result[$name][count($result[$name]) - 1] .= "\n" . $line;
			}
		}

		array_walk_recursive($result, function(&$value) {
			// {@*} is a placeholder for */ (phpDocumentor compatibility)
			$value = str_replace('{@*}', '*/', $value);
			$value = trim($value);
		});

		return $result;
	}
}
{'fraction_non_alphanumeric': 0.18876941457586618, 'fraction_numerical': 0.002867383512544803, 'mean_word_length': 3.19438877755511, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1880980', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1358, 'n_words': 330}