<commit_before><?php
/**
 * PHP Token Reflection
 *
 * Version 1.0 beta 2
 *
 * 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;

use TokenReflection\Exception;

/**
 * Tokenized function/method parameter reflection.
 */
class ReflectionParameter extends ReflectionBase implements IReflectionParameter
{
	/**
	 * The parameter requires an array as its value.
	 *
	 * @var string
	 */
	CONST ARRAY_CONSTRAINT = 'array';

	/**
	 * Defines if the default value definitions should be parsed (eval-ed).
	 *
	 * @var boolean
	 */
	private static $parseValueDefinitions = false;

	/**
	 * Defines a constraint (class name or array) of parameter values.
	 *
	 * @var string
	 */
	private $valueConstraint;

	/**
	 * Defines a constraint (class name or array) of parameter values as it was defined.
	 *
	 * @var string
	 */
	private $originalValueConstraint;

	/**
	 * Parameter default value definition (part of the source code).
	 *
	 * @var string
	 */
	private $defaultValueDefinition;

	/**
	 * Parameter default value.
	 *
	 * @var mixed
	 */
	private $defaultValue;

	/**
	 * Declaring class name.
	 *
	 * @var string
	 */
	private $declaringClassName;

	/**
	 * Declaring function name.
	 *
	 * @var string
	 */
	private $declaringFunctionName;

	/**
	 * Determines if the value is passed by reference.
	 *
	 * @var boolean
	 */
	private $passedByReference = false;

	/**
	 * Determines if the parameter is optional.
	 *
	 * @var boolean
	 */
	private $isOptional;

	/**
	 * Position of the parameter in the function/method.
	 *
	 * @var integer
	 */
	private $position;

	/**
	 * Returns if the the parameter allows NULL.
	 *
	 * @return boolean
	 */
	public function allowsNull()
	{
		if (($this->isArray() || null !== $this->getOriginalClassName()) && 'null' !== strtolower($this->defaultValueDefinition)) {
			return false;
		}

		return true;
	}

	/**
	 * Returns reflection of the required class of the value.
	 *
	 * @return \TokenReflection\ReflectionClass|\TokenReflection\ReflectionPhpClass|null
	 */
	public function getClass()
	{
		$name = $this->getClassName();
		if (null === $name) {
			return null;
		}

		return $this->getBroker()->getClass($name);
	}

	/**
	 * Returns the required class name of the value.
	 *
	 * @return string|null
	 * @throws \TokenReflection\Exception\Runtime If the constraint class FQN could not be determined<commit_msg>Documentation fix<commit_after><?php
/**
 * PHP Token Reflection
 *
 * Version 1.0 beta 2
 *
 * 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;

use TokenReflection\Exception;

/**
 * Tokenized function/method parameter reflection.
 */
class ReflectionParameter extends ReflectionBase implements IReflectionParameter
{
	/**
	 * The parameter requires an array as its value.
	 *
	 * @var string
	 */
	CONST ARRAY_CONSTRAINT = 'array';

	/**
	 * Defines if the default value definitions should be parsed (eval-ed).
	 *
	 * @var boolean
	 */
	private static $parseValueDefinitions = false;

	/**
	 * Defines a constraint (class name or array) of parameter values.
	 *
	 * @var string
	 */
	private $valueConstraint;

	/**
	 * Defines a constraint (class name or array) of parameter values as it was defined.
	 *
	 * @var string
	 */
	private $originalValueConstraint;

	/**
	 * Parameter default value definition (part of the source code).
	 *
	 * @var string
	 */
	private $defaultValueDefinition;

	/**
	 * Parameter default value.
	 *
	 * @var mixed
	 */
	private $defaultValue;

	/**
	 * Declaring class name.
	 *
	 * @var string
	 */
	private $declaringClassName;

	/**
	 * Declaring function name.
	 *
	 * @var string
	 */
	private $declaringFunctionName;

	/**
	 * Determines if the value is passed by reference.
	 *
	 * @var boolean
	 */
	private $passedByReference = false;

	/**
	 * Determines if the parameter is optional.
	 *
	 * @var boolean
	 */
	private $isOptional;

	/**
	 * Position of the parameter in the function/method.
	 *
	 * @var integer
	 */
	private $position;

	/**
	 * Returns if the the parameter allows NULL.
	 *
	 * @return boolean
	 */
	public function allowsNull()
	{
		if (($this->isArray() || null !== $this->getOriginalClassName()) && 'null' !== strtolower($this->defaultValueDefinition)) {
			return false;
		}

		return true;
	}

	/**
	 * Returns reflection of the required class of the value.
	 *
	 * @return \TokenReflection\IReflectionClass|null
	 */
	public function getClass()
	{
		$name = $this->getClassName();
		if (null === $name) {
			return null;
		}

		return $this->getBroker()->getClass($name);
	}

	/**
	 * Returns the required class name of the value.
	 *
	 * @return string|null
	 * @throws \TokenReflection\Exception\Runtime If the constraint class FQN could not be determined
{'fraction_non_alphanumeric': 0.12144702842377261, 'fraction_numerical': 0.0011926058437686344, 'mean_word_length': 3.138157894736842, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, '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': '6532901', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1424, 'n_words': 488}