1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00
psalm/tests/Php40Test.php

67 lines
1.5 KiB
PHP
Raw Normal View History

2016-11-21 20:36:06 +01:00
<?php
namespace Psalm\Tests;
use PhpParser\ParserFactory;
use PHPUnit_Framework_TestCase;
use Psalm\Checker\FileChecker;
use Psalm\Config;
use Psalm\Context;
class Php40Test extends PHPUnit_Framework_TestCase
{
/** @var \PhpParser\Parser */
2016-11-21 20:36:06 +01:00
protected static $parser;
/** @var TestConfig */
protected static $config;
/** @var \Psalm\Checker\ProjectChecker */
protected $project_checker;
2017-01-13 20:07:23 +01:00
/**
* @return void
*/
2016-11-21 20:36:06 +01:00
public static function setUpBeforeClass()
{
self::$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
self::$config = new TestConfig();
2016-11-21 20:36:06 +01:00
}
2017-01-13 20:07:23 +01:00
/**
* @return void
*/
2016-11-21 20:36:06 +01:00
public function setUp()
{
FileChecker::clearCache();
$this->project_checker = new \Psalm\Checker\ProjectChecker();
$this->project_checker->setConfig(self::$config);
2016-11-21 20:36:06 +01:00
}
2017-01-13 20:07:23 +01:00
/**
* @return void
*/
2016-11-21 20:36:06 +01:00
public function testExtendOldStyleConstructor()
{
$stmts = self::$parser->parse('<?php
class A {
2016-12-07 20:13:39 +01:00
/**
* @return string
*/
2016-11-21 20:36:06 +01:00
public function A() {
2016-12-07 20:13:39 +01:00
return "hello";
2016-11-21 20:36:06 +01:00
}
}
class B extends A {
public function __construct() {
parent::__construct();
}
}
');
$file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts);
$context = new Context();
$file_checker->visitAndAnalyzeMethods($context);
2016-11-21 20:36:06 +01:00
}
}