mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
use return type hints instead of php doc "@return void"
This commit is contained in:
parent
2fbad1bbeb
commit
fdaed941ad
@ -119,9 +119,6 @@ class ClassAnalyzer extends ClassLikeAnalyzer
|
||||
. '_' . $class->getLine() . '_' . (int)$class->getAttribute('startFilePos');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function analyze(
|
||||
?Context $class_context = null,
|
||||
?Context $global_context = null
|
||||
|
@ -5,8 +5,5 @@ use Psalm\Plugin\EventHandler\Event\AfterClassLikeVisitEvent;
|
||||
|
||||
interface AfterClassLikeVisitInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event);
|
||||
public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event): void;
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ interface AfterCodebasePopulatedInterface
|
||||
{
|
||||
/**
|
||||
* Called after codebase has been populated
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event);
|
||||
public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event): void;
|
||||
}
|
||||
|
@ -34,8 +34,6 @@ class AfterClassLikeVisitEvent
|
||||
|
||||
/**
|
||||
* @param FileManipulation[] $file_replacements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
ClassLike $stmt,
|
||||
|
@ -12,8 +12,6 @@ interface AfterClassLikeVisitInterface
|
||||
{
|
||||
/**
|
||||
* @param FileManipulation[] $file_replacements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function afterClassLikeVisit(
|
||||
ClassLike $stmt,
|
||||
@ -21,5 +19,5 @@ interface AfterClassLikeVisitInterface
|
||||
FileSource $statements_source,
|
||||
Codebase $codebase,
|
||||
array &$file_replacements = []
|
||||
);
|
||||
): void;
|
||||
}
|
||||
|
@ -8,8 +8,6 @@ interface AfterCodebasePopulatedInterface
|
||||
{
|
||||
/**
|
||||
* Called after codebase has been populated
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function afterCodebasePopulated(Codebase $codebase);
|
||||
public static function afterCodebasePopulated(Codebase $codebase): void;
|
||||
}
|
||||
|
@ -10,10 +10,7 @@ class BinaryOperationTest extends TestCase
|
||||
use Traits\InvalidCodeAnalysisTestTrait;
|
||||
use Traits\ValidCodeAnalysisTestTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testGMPOperations()
|
||||
public function testGMPOperations(): void
|
||||
{
|
||||
if (class_exists('GMP') === false) {
|
||||
$this->markTestSkipped('Cannot run test, base class "GMP" does not exist!');
|
||||
|
@ -8,10 +8,7 @@ class ClassTest extends TestCase
|
||||
use Traits\InvalidCodeAnalysisTestTrait;
|
||||
use Traits\ValidCodeAnalysisTestTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testExtendsMysqli()
|
||||
public function testExtendsMysqli(): void
|
||||
{
|
||||
if (class_exists('mysqli') === false) {
|
||||
$this->markTestSkipped('Cannot run test, base class "mysqli" does not exist!');
|
||||
|
@ -143,10 +143,7 @@ class CodebaseTest extends TestCase
|
||||
'
|
||||
);
|
||||
$hook = new class implements AfterClassLikeVisitInterface {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event)
|
||||
public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event): void
|
||||
{
|
||||
$stmt = $event->getStmt();
|
||||
$storage = $event->getStorage();
|
||||
|
@ -140,10 +140,7 @@ class ConfigTest extends \Psalm\Tests\TestCase
|
||||
$this->assertFalse($config->isInProjectDirs(realpath('examples/StringAnalyzer.php')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testIgnoreSymlinkedProjectDirectory()
|
||||
public function testIgnoreSymlinkedProjectDirectory(): void
|
||||
{
|
||||
@unlink(dirname(__DIR__, 1) . '/fixtures/symlinktest/ignored/b');
|
||||
|
||||
@ -1378,8 +1375,7 @@ class ConfigTest extends \Psalm\Tests\TestCase
|
||||
$this->assertFalse($this->project_analyzer->getConfig()->use_phpstorm_meta_path);
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
public function testSetsUniversalObjectCrates()
|
||||
public function testSetsUniversalObjectCrates(): void
|
||||
{
|
||||
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
|
||||
TestConfig::loadFromXML(
|
||||
|
@ -540,8 +540,7 @@ class PluginTest extends \Psalm\Tests\TestCase
|
||||
);
|
||||
|
||||
$hook = new class implements AfterCodebasePopulatedInterface {
|
||||
/** @return void */
|
||||
public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event)
|
||||
public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event): void
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -24,10 +24,7 @@ class ErrorBaselineTest extends TestCase
|
||||
$this->fileProvider = $this->prophesize(FileProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testLoadShouldParseXmlBaselineToPhpArray()
|
||||
public function testLoadShouldParseXmlBaselineToPhpArray(): void
|
||||
{
|
||||
$baselineFilePath = 'baseline.xml';
|
||||
|
||||
@ -95,10 +92,7 @@ class ErrorBaselineTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testLoadShouldThrowExceptionWhenFilesAreNotDefinedInBaselineFile()
|
||||
public function testLoadShouldThrowExceptionWhenFilesAreNotDefinedInBaselineFile(): void
|
||||
{
|
||||
$this->expectException(ConfigException::class);
|
||||
|
||||
@ -115,10 +109,7 @@ class ErrorBaselineTest extends TestCase
|
||||
ErrorBaseline::read($this->fileProvider->reveal(), $baselineFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testLoadShouldThrowExceptionWhenBaselineFileDoesNotExist()
|
||||
public function testLoadShouldThrowExceptionWhenBaselineFileDoesNotExist(): void
|
||||
{
|
||||
$this->expectException(ConfigException::class);
|
||||
|
||||
@ -129,10 +120,7 @@ class ErrorBaselineTest extends TestCase
|
||||
ErrorBaseline::read($this->fileProvider->reveal(), $baselineFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testCountTotalIssuesShouldReturnCorrectNumber()
|
||||
public function testCountTotalIssuesShouldReturnCorrectNumber(): void
|
||||
{
|
||||
$existingIssues = [
|
||||
'sample/sample-file.php' => [
|
||||
@ -149,10 +137,7 @@ class ErrorBaselineTest extends TestCase
|
||||
$this->assertSame($totalIssues, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testCreateShouldAggregateIssuesPerFile()
|
||||
public function testCreateShouldAggregateIssuesPerFile(): void
|
||||
{
|
||||
$baselineFile = 'baseline.xml';
|
||||
|
||||
@ -342,10 +327,7 @@ class ErrorBaselineTest extends TestCase
|
||||
$this->assertSame('1', $file2Issues[1]->getAttribute('occurrences'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes()
|
||||
public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes(): void
|
||||
{
|
||||
$baselineFile = 'baseline.xml';
|
||||
|
||||
@ -481,10 +463,7 @@ class ErrorBaselineTest extends TestCase
|
||||
], $remainingBaseline);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testAddingACommentInBaselineDoesntTriggerNotice()
|
||||
public function testAddingACommentInBaselineDoesntTriggerNotice(): void
|
||||
{
|
||||
$baselineFilePath = 'baseline.xml';
|
||||
|
||||
|
@ -10,10 +10,7 @@ class MethodCallTest extends TestCase
|
||||
use Traits\InvalidCodeAnalysisTestTrait;
|
||||
use Traits\ValidCodeAnalysisTestTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testExtendDocblockParamType()
|
||||
public function testExtendDocblockParamType(): void
|
||||
{
|
||||
if (class_exists('SoapClient') === false) {
|
||||
$this->markTestSkipped('Cannot run test, base class "SoapClient" does not exist!');
|
||||
|
@ -12,10 +12,7 @@ class MethodSignatureTest extends TestCase
|
||||
use Traits\ValidCodeAnalysisTestTrait;
|
||||
use Traits\InvalidCodeAnalysisTestTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testExtendSoapClientWithDocblockTypes()
|
||||
public function testExtendSoapClientWithDocblockTypes(): void
|
||||
{
|
||||
if (class_exists('SoapClient') === false) {
|
||||
$this->markTestSkipped('Cannot run test, base class "SoapClient" does not exist!');
|
||||
@ -49,10 +46,7 @@ class MethodSignatureTest extends TestCase
|
||||
$this->analyzeFile('somefile.php', new Context());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testExtendSoapClientWithNoDocblockTypes()
|
||||
public function testExtendSoapClientWithNoDocblockTypes(): void
|
||||
{
|
||||
if (class_exists('SoapClient') === false) {
|
||||
$this->markTestSkipped('Cannot run test, base class "SoapClient" does not exist!');
|
||||
@ -78,10 +72,7 @@ class MethodSignatureTest extends TestCase
|
||||
$this->analyzeFile('somefile.php', new Context());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testExtendSoapClientWithParamType()
|
||||
public function testExtendSoapClientWithParamType(): void
|
||||
{
|
||||
if (class_exists('SoapClient') === false) {
|
||||
$this->markTestSkipped('Cannot run test, base class "SoapClient" does not exist!');
|
||||
@ -250,10 +241,7 @@ class MethodSignatureTest extends TestCase
|
||||
$this->analyzeFile('somefile.php', new Context());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testExtendDocblockParamTypeWithWrongDocblockParam()
|
||||
public function testExtendDocblockParamTypeWithWrongDocblockParam(): void
|
||||
{
|
||||
$this->expectExceptionMessage('ImplementedParamTypeMismatch');
|
||||
$this->expectException(\Psalm\Exception\CodeException::class);
|
||||
|
@ -108,8 +108,7 @@ class ProjectCheckerTest extends TestCase
|
||||
/** @var bool */
|
||||
public static $called = false;
|
||||
|
||||
/** @return void */
|
||||
public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event)
|
||||
public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event): void
|
||||
{
|
||||
self::$called = true;
|
||||
}
|
||||
|
@ -26,8 +26,6 @@ trait InvalidCodeAnalysisTestTrait
|
||||
* @param string $error_message
|
||||
* @param array<int|string, string> $error_levels
|
||||
* @param bool $strict_mode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidCode(
|
||||
$code,
|
||||
@ -35,7 +33,7 @@ trait InvalidCodeAnalysisTestTrait
|
||||
$error_levels = [],
|
||||
$strict_mode = false,
|
||||
string $php_version = '7.3'
|
||||
) {
|
||||
): void {
|
||||
$test_name = $this->getTestName();
|
||||
if (strpos($test_name, 'PHP71-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
|
||||
|
@ -27,15 +27,13 @@ trait ValidCodeAnalysisTestTrait
|
||||
* @param array<string|int, string> $error_levels
|
||||
*
|
||||
* @small
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testValidCode(
|
||||
$code,
|
||||
$assertions = [],
|
||||
$error_levels = [],
|
||||
string $php_version = '7.3'
|
||||
) {
|
||||
): void {
|
||||
$test_name = $this->getTestName();
|
||||
if (strpos($test_name, 'PHP73-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user