<commit_before><?php

namespace AppBundle\Command;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class ValidationCommand extends \Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('digideps:validation')
            ->setDescription('Check or print validation rules')
            ->addOption('print', null, InputOption::VALUE_NONE, 'print validation rules')
        ;
    }

    private function getClassValidationRules($entity)
    {
        $validator = $this->getContainer()->get('validator');
        $data = $validator->getMetadataFor($entity); /* @var $data \Symfony\Component\Validator\Mapping\ClassMetadata */
        
        $ret = [];
        foreach ($data->getConstrainedProperties() as $property) {
            $propMetaData = $data->getMemberMetadatas($property)[0]; /* @var $propMetaData \Symfony\Component\Validator\Mapping\PropertyMetadata */
            $ret[$property] = $propMetaData->getConstraints();
        }
        
        return $ret;
    }
    
    protected function execute(InputInterface $input, OutputInterface $output)
    {
//        try {
            $ret = [];
            foreach (glob($this->getContainer()->get('kernel')->getRootDir() . '/../src/AppBundle/Entity/*.php') as $entity) {
                if (preg_match('/([A-Z][a-z]+)\.php$/', $entity, $matches)) {
                    $className = '\\AppBundle\\Entity\\' . $matches[1];
                    $ret[$className] = $this->getClassValidationRules(new $className);
                }
            }
//        } catch (\Exception $e) {
//            echo $e->getMessage();
//            die(1);
//        }
        
        if ($input->getOption('print')) {
            $output->writeln(print_r($ret, true));
        }<commit_msg>fix class validate checks<commit_after><?php

namespace AppBundle\Command;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class ValidationCommand extends \Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('digideps:validation')
            ->setDescription('Check or print validation rules')
            ->addOption('print', null, InputOption::VALUE_NONE, 'print validation rules')
        ;
    }

    private function getClassValidationRules($entity)
    {
        $validator = $this->getContainer()->get('validator');
        $data = $validator->getMetadataFor($entity); /* @var $data \Symfony\Component\Validator\Mapping\ClassMetadata */
        
        $ret = [];
        foreach ($data->getConstrainedProperties() as $property) {
            $propMetaData = $data->getMemberMetadatas($property)[0]; /* @var $propMetaData \Symfony\Component\Validator\Mapping\PropertyMetadata */
            $ret[$property] = $propMetaData->getConstraints();
        }
        
        return $ret;
    }
    
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $ret = [];
        foreach (glob($this->getContainer()->get('kernel')->getRootDir() . '/../src/AppBundle/Entity/*.php') as $entity) {
            if (preg_match('/([A-Z][a-z]+)\.php$/', $entity, $matches)) {
                $className = '\\AppBundle\\Entity\\' . $matches[1];
                if (class_exists($className)) {
                    $ret[$className] = $this->getClassValidationRules(new $className);
                }
            }
        }

        if ($input->getOption('print')) {
            $output->writeln(print_r($ret, true));
        }
{'fraction_non_alphanumeric': 0.14967741935483872, 'fraction_numerical': 0.0012903225806451613, 'mean_word_length': 2.514052583862194, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, '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': '2483576', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1041, 'n_words': 174}