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

namespace PHPStan\Analyser;

class AnalyserIntegrationTest extends \PHPStan\TestCase
{

	public function testUndefinedVariableFromAssignErrorHasLine()
	{
		$file = __DIR__ . '/data/undefined-variable-assign.php';
		$analyser = $this->getContainer()->getByType(Analyser::class);
		$errors = $analyser->analyse([$file]);
		$this->assertCount(1, $errors);
		$error = $errors[0];
		$this->assertSame('Undefined variable: $bar', $error->getMessage());
		$this->assertSame($file, $error->getFile());
		$this->assertSame(3, $error->getLine());
	}

	public function testMissingPropertyAndMethod()
	{
		$file = __DIR__ . '/../../notAutoloaded/Foo.php';
		$analyser = $this->getContainer()->getByType(Analyser::class);
		$errors = $analyser->analyse([$file]);
		$this->assertCount(1, $errors);
		$error = $errors[0];
		$this->assertSame('Property $fooProperty was not found in reflection of class PHPStan\Tests\Foo - probably the wrong version of class is autoloaded.', $error->getMessage());
		$this->assertSame($file, $error->getFile());
		$this->assertNull($error->getLine());
	}

	public function testErrorAboutMisconfiguredAutoloader()
	{
		$file = __DIR__ . '/../../notAutoloaded/Bar.php';
		$analyser = $this->getContainer()->getByType(Analyser::class);
		$errors = $analyser->analyse([$file]);
		$this->assertCount(1, $errors);
		$error = $errors[0];
		$this->assertSame('Class PHPStan\Tests\Bar was not found while trying to analyse it - autoloading is not probably configured properly.', $error->getMessage());
		$this->assertSame($file, $error->getFile());
		$this->assertNull($error->getLine());
	}

}<commit_msg>AnalyserIntegrationTest - DRYed running analyse()<commit_after><?php declare(strict_types = 1);

namespace PHPStan\Analyser;

class AnalyserIntegrationTest extends \PHPStan\TestCase
{

	public function testUndefinedVariableFromAssignErrorHasLine()
	{
		$errors = $this->runAnalyse(__DIR__ . '/data/undefined-variable-assign.php');
		$this->assertCount(1, $errors);
		$error = $errors[0];
		$this->assertSame('Undefined variable: $bar', $error->getMessage());
		$this->assertSame(3, $error->getLine());
	}

	public function testMissingPropertyAndMethod()
	{
		$errors = $this->runAnalyse(__DIR__ . '/../../notAutoloaded/Foo.php');
		$this->assertCount(1, $errors);
		$error = $errors[0];
		$this->assertSame('Property $fooProperty was not found in reflection of class PHPStan\Tests\Foo - probably the wrong version of class is autoloaded.', $error->getMessage());
		$this->assertNull($error->getLine());
	}

	public function testErrorAboutMisconfiguredAutoloader()
	{
		$errors = $this->runAnalyse(__DIR__ . '/../../notAutoloaded/Bar.php');
		$this->assertCount(1, $errors);
		$error = $errors[0];
		$this->assertSame('Class PHPStan\Tests\Bar was not found while trying to analyse it - autoloading is not probably configured properly.', $error->getMessage());
		$this->assertNull($error->getLine());
	}

	/**
	 * @param string $file
	 * @return \PHPStan\Analyser\Error[]
	 */
	private function runAnalyse(string $file): array
	{
		/** @var \PHPStan\Analyser\Analyser $analyser */
		$analyser = $this->getContainer()->getByType(Analyser::class);
		$errors = $analyser->analyse([$file]);
		foreach ($errors as $error) {
			$this->assertSame($file, $error->getFile());
		}

		return $errors;
	}

}
{'fraction_non_alphanumeric': 0.17962466487935658, 'fraction_numerical': 0.004766160262138814, 'mean_word_length': 5.184162062615101, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 56, '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': '5211254', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1102, 'n_words': 212}