<commit_before><?php
declare(strict_types=1);

namespace Roave\BetterReflection\Reflection;

use Roave\BetterReflection\NodeCompiler\CompileNodeToValue;
use Roave\BetterReflection\NodeCompiler\CompilerContext;
use Roave\BetterReflection\Reflector\Reflector;
use Roave\BetterReflection\TypesFinder\FindPropertyType;
use Roave\BetterReflection\Util\GetFirstDocComment;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Property as PropertyNode;
use phpDocumentor\Reflection\Type;

class ReflectionProperty implements \Reflector
{
    /**
     * @var ReflectionClass
     */
    private $declaringClass;

    /**
     * @var PropertyNode
     */
    private $node;

    /**
     * @var bool
     */
    private $declaredAtCompileTime = true;

    /**
     * @var Reflector
     */
    private $reflector;

    private function __construct()
    {
    }

    public static function export()
    {
        throw new \Exception('Unable to export statically');
    }

    /**
     * Create a reflection of a class's property by it's name
     *
     * @param string $className
     * @param string $propertyName
     * @return self
     */
    public static function createFromName(string $className, string $propertyName) : self
    {
        return ReflectionClass::createFromName($className)->getProperty($propertyName);
    }

    /**
     * Create a reflection of an instance's property by it's name
     *
     * @param object $instance
     * @param string $propertyName
     * @return self
     * @throws \InvalidArgumentException
     */
    public static function createFromInstance($instance, string $propertyName) : self
    {
        return ReflectionClass::createFromInstance($instance)->getProperty($propertyName);
    }

    /**
     * Return string representation of this little old property.
     *
     * @return string
     */
    public function __toString() : string
    {
        return sprintf(
            'Property [%s %s%s $%s ]',
            $this->isStatic() ? '' : ($this->isDefault() ? ' <default>' : ' <dynamic>'),
            $this->getVisibilityAsString(),
            $this->isStatic() ? ' static' : '',
            $this->getName()
        );
    }

    /**
     * @param Reflector $reflector
     * @param PropertyNode $node
     * @param ReflectionClass $declaringClass
     * @param bool $declaredAtCompileTime
     * @return ReflectionProperty
     */
    public static function createFromNode(
        Reflector $reflector,
        PropertyNode $node,
        ReflectionClass $declaringClass,
        bool $declaredAtCompileTime = true
    ) : self {
        $prop = new self();
        $prop->reflector = $reflector;
        $prop->node = $node;
        $prop->declaringClass = $declaringClass;
        $prop->declaredAtCompileTime = $declaredAtCompileTime;
        return $prop;
    }

    /**
     * @return string
     */<commit_msg>Removed confusing ternary expression<commit_after><?php
declare(strict_types=1);

namespace Roave\BetterReflection\Reflection;

use Roave\BetterReflection\NodeCompiler\CompileNodeToValue;
use Roave\BetterReflection\NodeCompiler\CompilerContext;
use Roave\BetterReflection\Reflector\Reflector;
use Roave\BetterReflection\TypesFinder\FindPropertyType;
use Roave\BetterReflection\Util\GetFirstDocComment;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Property as PropertyNode;
use phpDocumentor\Reflection\Type;

class ReflectionProperty implements \Reflector
{
    /**
     * @var ReflectionClass
     */
    private $declaringClass;

    /**
     * @var PropertyNode
     */
    private $node;

    /**
     * @var bool
     */
    private $declaredAtCompileTime = true;

    /**
     * @var Reflector
     */
    private $reflector;

    private function __construct()
    {
    }

    public static function export()
    {
        throw new \Exception('Unable to export statically');
    }

    /**
     * Create a reflection of a class's property by it's name
     *
     * @param string $className
     * @param string $propertyName
     * @return self
     */
    public static function createFromName(string $className, string $propertyName) : self
    {
        return ReflectionClass::createFromName($className)->getProperty($propertyName);
    }

    /**
     * Create a reflection of an instance's property by it's name
     *
     * @param object $instance
     * @param string $propertyName
     * @return self
     * @throws \InvalidArgumentException
     */
    public static function createFromInstance($instance, string $propertyName) : self
    {
        return ReflectionClass::createFromInstance($instance)->getProperty($propertyName);
    }

    /**
     * Return string representation of this little old property.
     *
     * @return string
     */
    public function __toString() : string
    {
        $stateModifier = '';

        if (! $this->isStatic()) {
            $stateModifier = $this->isDefault() ? ' <default>' : ' <dynamic>';
        }

        return sprintf(
            'Property [%s %s%s $%s ]',
            $stateModifier,
            $this->getVisibilityAsString(),
            $this->isStatic() ? ' static' : '',
            $this->getName()
        );
    }

    /**
     * @param Reflector $reflector
     * @param PropertyNode $node
     * @param ReflectionClass $declaringClass
     * @param bool $declaredAtCompileTime
     * @return ReflectionProperty
     */
    public static function createFromNode(
        Reflector $reflector,
        PropertyNode $node,
        ReflectionClass $declaringClass,
        bool $declaredAtCompileTime = true
    ) : self {
        $prop = new self();
        $prop->reflector = $reflector;
        $prop->node = $node;
        $prop->declaringClass = $declaringClass;
        $prop->declaredAtCompileTime = $declaredAtCompileTime;
        return $prop;
    }

    /**
     * @return string
     */
{'fraction_non_alphanumeric': 0.11003236245954692, 'fraction_numerical': 0.00034065746891500596, 'mean_word_length': 2.548036253776435, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, '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': '2961989', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1613, 'n_words': 375}