<commit_before><?php

namespace tests\PHPCD;

use PHPCD\ObjectElementInfo\ReflectionPropertyInfo;
use PHPCD\PHPCD;
use PHPUnit\Framework\TestCase;
use Mockery;
use PHPCD\PHPFileInfo\PHPFileInfoFactory;
use PHPCD\PHPFileInfo\PHPFileInfo;
use PHPCD\ClassInfo\ClassInfoFactory;
use PHPCD\ConstantInfo\ConstantInfoRepository;
use PHPCD\ObjectElementInfo\MethodInfoRepository;
use PHPCD\ObjectElementInfo\PropertyInfoRepository;
use PHPCD\NamespaceInfo;
use PHPCD\View\View;
use Psr\Log\LoggerInterface as Logger;
use PHPCD\DocBlock\LegacyTypeLogic;
use PHPCD\DocBlock\DocBlock;

class ProptypeTest extends TestCase
{
    /**
     * @test
     * @dataProvider proptypeDataProvider
     */
    public function proptype($class, $property, $namespace, $imports, $expectedTypes)
    {
        $nsinfo = Mockery::mock(NamespaceInfo::class);
        $logger = Mockery::mock(Logger::class);
        $constantRepository = Mockery::mock(ConstantInfoRepository::class);
        $propertyInfoRepository = Mockery::mock(PropertyInfoRepository::class);
        $methodInfoRepository = Mockery::mock(MethodInfoRepository::class);
        $fileInfoFactory = Mockery::mock(PHPFileInfoFactory::class);
        $view = Mockery::mock(View::class);
        $fileInfo = Mockery::mock(PHPFileInfo::class);
        $legacyTypeLogic = new LegacyTypeLogic($logger, $fileInfoFactory);
        $docBlock = Mockery::mock(DocBlock::class);
        $propertyInfo = new ReflectionPropertyInfo(new \ReflectionProperty($class, $property), $docBlock);

        $fileInfo->shouldReceive('getImports')->andReturn($imports);
        $fileInfo->shouldReceive('getNamespace')->andReturn($namespace);
        $fileInfoFactory->shouldReceive('createFileInfo')->andReturn($fileInfo);
        $view->shouldReceive('renderPHPFileInfo')->andReturnNull();
        $propertyInfoRepository->shouldReceive('getByPath')->andReturn($propertyInfo);

        $phpcd = new PHPCD(
            $nsinfo,
            $logger,
            $constantRepository,
            $propertyInfoRepository,
            $methodInfoRepository,
            $fileInfoFactory,
            $view,
            $legacyTypeLogic
        );

        $types = $phpcd->proptype($class, $property, true);

        $this->assertEquals(count($expectedTypes), count($types));

        foreach ($expectedTypes as $expectedType) {
            $this->assertContains($expectedType, $types);<commit_msg>fixup! fixup! [squash] function repository<commit_after><?php

namespace tests\PHPCD;

use PHPCD\ObjectElementInfo\ReflectionPropertyInfo;
use PHPCD\PHPCD;
use PHPUnit\Framework\TestCase;
use Mockery;
use PHPCD\PHPFileInfo\PHPFileInfoFactory;
use PHPCD\PHPFileInfo\PHPFileInfo;
use PHPCD\ClassInfo\ClassInfoFactory;
use PHPCD\ConstantInfo\ConstantInfoRepository;
use PHPCD\ObjectElementInfo\MethodInfoRepository;
use PHPCD\ObjectElementInfo\PropertyInfoRepository;
use PHPCD\NamespaceInfo;
use PHPCD\View\View;
use Psr\Log\LoggerInterface as Logger;
use PHPCD\DocBlock\LegacyTypeLogic;
use PHPCD\DocBlock\DocBlock;

class ProptypeTest extends TestCase
{
    /**
     * @test
     * @dataProvider proptypeDataProvider
     */
    public function proptype($class, $property, $namespace, $imports, $expectedTypes)
    {
        $nsinfo = Mockery::mock(NamespaceInfo::class);
        $logger = Mockery::mock(Logger::class);
        $constantRepository = Mockery::mock(ConstantInfoRepository::class);
        $propertyInfoRepository = Mockery::mock(PropertyInfoRepository::class);
        $methodInfoRepository = Mockery::mock(MethodInfoRepository::class);
        $fileInfoFactory = Mockery::mock(PHPFileInfoFactory::class);
        $view = Mockery::mock(View::class);
        $fileInfo = Mockery::mock(PHPFileInfo::class);
        $legacyTypeLogic = new LegacyTypeLogic($logger, $fileInfoFactory);
        $docBlock = Mockery::mock(DocBlock::class);
        $propertyInfo = new ReflectionPropertyInfo(new \ReflectionProperty($class, $property), $docBlock);

        $fileInfo->shouldReceive('getImports')->andReturn($imports);
        $fileInfo->shouldReceive('getNamespace')->andReturn($namespace);
        $fileInfoFactory->shouldReceive('createFileInfo')->andReturn($fileInfo);
        $view->shouldReceive('renderPHPFileInfo')->andReturnNull();
        $propertyInfoRepository->shouldReceive('getByPath')->andReturn($propertyInfo);

        $phpcd = new PHPCD(
            $nsinfo,
            $logger,
            $constantRepository,
            $propertyInfoRepository,
            $methodInfoRepository,
            $fileInfoFactory,
            $view,
            $legacyTypeLogic
        );

        $types = $phpcd->getTypesOfProperty($class, $property);

        $this->assertEquals(count($expectedTypes), count($types));

        foreach ($expectedTypes as $expectedType) {
            $this->assertContains($expectedType, $types);
{'fraction_non_alphanumeric': 0.12229325634151371, 'fraction_numerical': 0.0, 'mean_word_length': 4.041580041580041, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3376484', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1334, 'n_words': 212}