2017-02-10 21:27:12 -05:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
2018-01-21 10:22:04 -05:00
|
|
|
use Psalm\Context;
|
2017-02-10 21:27:12 -05:00
|
|
|
|
2017-04-24 23:45:02 -04:00
|
|
|
class BadFormatTest extends TestCase
|
2017-02-10 21:27:12 -05:00
|
|
|
{
|
|
|
|
/**
|
2019-03-23 14:27:54 -04:00
|
|
|
* @expectedException \Psalm\Exception\CodeException
|
2018-09-29 00:15:39 -04:00
|
|
|
* @expectedExceptionMessage ParseError - somefile.php:9
|
2019-03-23 14:27:54 -04:00
|
|
|
*
|
2017-02-10 21:27:12 -05:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testMissingSemicolon()
|
|
|
|
{
|
2017-07-25 16:11:02 -04:00
|
|
|
$this->addFile(
|
2017-04-24 23:45:02 -04:00
|
|
|
'somefile.php',
|
2017-02-10 21:27:12 -05:00
|
|
|
'<?php
|
2017-07-25 16:11:02 -04:00
|
|
|
class A {
|
|
|
|
/** @var int|null */
|
|
|
|
protected $hello;
|
2017-02-10 21:27:12 -05:00
|
|
|
|
2017-07-25 16:11:02 -04:00
|
|
|
/** @return void */
|
|
|
|
function foo() {
|
|
|
|
$this->hello = 5
|
|
|
|
}
|
|
|
|
}'
|
2017-02-10 21:27:12 -05:00
|
|
|
);
|
|
|
|
|
2018-01-21 10:22:04 -05:00
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
2017-02-10 21:27:12 -05:00
|
|
|
}
|
2018-10-26 00:59:14 -04:00
|
|
|
|
2019-01-19 12:19:51 -05:00
|
|
|
/**
|
2019-03-23 14:27:54 -04:00
|
|
|
* @expectedException \Psalm\Exception\CodeException
|
2019-01-19 12:19:51 -05:00
|
|
|
* @expectedExceptionMessage ParseError - somefile.php:3
|
2019-03-23 14:27:54 -04:00
|
|
|
*
|
2019-01-19 12:19:51 -05:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testClassMethodWithNoStmts()
|
|
|
|
{
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
class A {
|
|
|
|
public function foo() : void;
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
}
|
|
|
|
|
2018-10-26 00:59:14 -04:00
|
|
|
/**
|
2019-03-23 14:27:54 -04:00
|
|
|
* @expectedException \Psalm\Exception\CodeException
|
2018-10-26 00:59:14 -04:00
|
|
|
* @expectedExceptionMessage ParseError - somefile.php:5
|
2019-03-23 14:27:54 -04:00
|
|
|
*
|
2018-10-26 00:59:14 -04:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testTypingReturnType()
|
|
|
|
{
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
class A {
|
|
|
|
/** @return void */
|
|
|
|
protected function _getCollaborators(User $user, User $cur_user = null) :
|
|
|
|
{
|
|
|
|
return $a;
|
|
|
|
}
|
|
|
|
}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
}
|
2019-01-20 11:10:12 -05:00
|
|
|
|
|
|
|
/**
|
2019-03-23 14:27:54 -04:00
|
|
|
* @expectedException \Psalm\Exception\CodeException
|
2019-01-20 11:10:12 -05:00
|
|
|
* @expectedExceptionMessage ParseError - somefile.php:6
|
2019-03-23 14:27:54 -04:00
|
|
|
*
|
2019-01-20 11:10:12 -05:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function testOverriddenUse()
|
|
|
|
{
|
|
|
|
$this->addFile(
|
|
|
|
'somefile.php',
|
|
|
|
'<?php
|
|
|
|
namespace Demo;
|
|
|
|
|
|
|
|
use A\B;
|
|
|
|
|
|
|
|
interface B {}'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->analyzeFile('somefile.php', new Context());
|
|
|
|
}
|
2017-02-10 21:27:12 -05:00
|
|
|
}
|