<commit_before><?php
/**
 * Created by PhpStorm.
 * User: janhuang
 * Date: 16/2/21
 * Time: 上午12:04
 * Github: https://www.github.com/janhuang
 * Coding: https://www.coding.net/janhuang
 * SegmentFault: http://segmentfault.com/u/janhuang
 * Blog: http://segmentfault.com/blog/janhuang
 * Gmail: <EMAIL>
 * WebSite: http://www.janhuang.me
 */

namespace FastD\Generator\Parser;

use FastD\Generator\Factory\Object;

/**
 * Class ObjectParse
 *
 * @package FastD\Generator\Parser
 */
class ObjectParse extends Parser implements ParserInterface
{
    /**
     * @var \ReflectionClass
     */
    protected $reflector;

    /**
     * ObjectParse constructor.
     * @param mixed $class
     */
    public function __construct($class)
    {
        parent::__construct(new \ReflectionClass($class));

        $file = new \SplFileObject($this->reflector->getFileName());

        $usages = [];

        $i = 1;
        $end = $this->reflector->getStartLine();
        $file->seek($i);
        while ($i < $end) {
            $line = $file->current();
            if ('use' === substr($line, 0, 3)) {
                $usages[] = substr($line, 4, -2);
            }
            $file->next();
            $i++;
        }
        unset($file);

        $this->generator = new Object($this->reflector->getShortName(), $this->reflector->getNamespaceName());
        $this->generator->setUsages($usages);

        $properties = [];

        foreach ($this->reflector->getConstants() as $name => $value) {
            $properties[$name] = (new ConstantParser($name, $value))->getGenerator();
        }

        foreach ($this->reflector->getProperties() as $property) {
            $properties[$property->getName()] = (new PropertyParser($this->reflector, $property->getName()))->getGenerator();
        }

        $methods = [];
        foreach ($this->reflector->getMethods() as $method) {
            $methods[$method->getName()] = (new MethodParser($method))->getGenerator();
        }

        $this->generator->setProperties($properties);
        $this->generator->setMethods($methods);

        $interfaces = [];
        foreach ($this->reflector->getInterfaces() as $interface) {
            $interfaces[$interface->getShortName()] = new Object($interface->getShortName(), $interface->getNamespaceName(), Object::OBJECT_INTERFACE);
        }
        $this->generator->setImplements($interfaces);<commit_msg>fixed class methods and propertyies<commit_after><?php
/**
 * Created by PhpStorm.
 * User: janhuang
 * Date: 16/2/21
 * Time: 上午12:04
 * Github: https://www.github.com/janhuang
 * Coding: https://www.coding.net/janhuang
 * SegmentFault: http://segmentfault.com/u/janhuang
 * Blog: http://segmentfault.com/blog/janhuang
 * Gmail: <EMAIL>
 * WebSite: http://www.janhuang.me
 */

namespace FastD\Generator\Parser;

use FastD\Generator\Factory\Object;

/**
 * Class ObjectParse
 *
 * @package FastD\Generator\Parser
 */
class ObjectParse extends Parser implements ParserInterface
{
    /**
     * @var \ReflectionClass
     */
    protected $reflector;

    /**
     * ObjectParse constructor.
     * @param mixed $class
     */
    public function __construct($class)
    {
        parent::__construct(new \ReflectionClass($class));

        $file = new \SplFileObject($this->reflector->getFileName());

        $usages = [];

        $i = 1;
        $end = $this->reflector->getStartLine();
        $file->seek($i);
        while ($i < $end) {
            $line = $file->current();
            if ('use' === substr($line, 0, 3)) {
                $usages[] = substr($line, 4, -2);
            }
            $file->next();
            $i++;
        }
        unset($file);

        $this->generator = new Object($this->reflector->getShortName(), $this->reflector->getNamespaceName());
        $this->generator->setUsages($usages);

        $properties = [];

        foreach ($this->reflector->getConstants() as $name => $value) {
            $properties[$name] = (new ConstantParser($name, $value))->getGenerator();
        }

        foreach ($this->reflector->getProperties() as $property) {
            if ($property->getDeclaringClass()->getName() !== $this->reflector->getName()) {
                continue;
            }
            $properties[$property->getName()] = (new PropertyParser($this->reflector, $property->getName()))->getGenerator();
        }

        $methods = [];
        foreach ($this->reflector->getMethods() as $method) {
            if ($method->getDeclaringClass()->getName() !== $this->reflector->getName()) {
                continue;
            }
            $methods[$method->getName()] = (new MethodParser($method))->getGenerator();
        }

        $this->generator->setProperties($properties);
        $this->generator->setMethods($methods);

        $interfaces = [];
        foreach ($this->reflector->getInterfaces() as $interface) {
            $interfaces[$interface->getShortName()] = new Object($interface->getShortName(), $interface->getNamespaceName(), Object::OBJECT_INTERFACE);
        }
        $this->generator->setImplements($interfaces);
{'fraction_non_alphanumeric': 0.17471535139379663, 'fraction_numerical': 0.005496662740478995, 'mean_word_length': 2.565430370888733, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 91, 'https://': 4, 'lorem ipsum': 0, 'www.': 6, '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': '2355587', 'n_tokens_mistral': 1494, 'n_tokens_neox': 1453, 'n_words': 251}