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

55 lines
1.3 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 \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();
$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();
}
}
');
$file_checker = new FileChecker('somefile.php', $this->project_checker, $stmts);
2016-11-21 20:36:06 +01:00
$context = new Context('somefile.php');
$file_checker->visitAndAnalyzeMethods($context);
2016-11-21 20:36:06 +01:00
}
}