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
|
|
|
|
{
|
2016-12-14 18:55:23 +01:00
|
|
|
/** @var \PhpParser\Parser */
|
2016-11-21 20:36:06 +01:00
|
|
|
protected static $parser;
|
|
|
|
|
2017-01-02 21:31:18 +01:00
|
|
|
/** @var \Psalm\Checker\ProjectChecker */
|
|
|
|
protected $project_checker;
|
|
|
|
|
2016-11-21 20:36:06 +01:00
|
|
|
public static function setUpBeforeClass()
|
|
|
|
{
|
|
|
|
self::$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
|
|
|
|
|
2016-12-14 18:28:38 +01:00
|
|
|
$config = new TestConfig();
|
2016-11-21 20:36:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
FileChecker::clearCache();
|
2017-01-02 21:31:18 +01:00
|
|
|
$this->project_checker = new \Psalm\Checker\ProjectChecker();
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
');
|
|
|
|
|
2017-01-02 21:31:18 +01:00
|
|
|
$file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts);
|
2016-11-21 20:36:06 +01:00
|
|
|
$context = new Context('somefile.php');
|
2017-01-02 21:31:18 +01:00
|
|
|
$file_checker->visitAndCheckMethods($context);
|
2016-11-21 20:36:06 +01:00
|
|
|
}
|
|
|
|
}
|