Skip to content

Commit

Permalink
Merge pull request #7003 from rarila/no-phpdoc-return-void
Browse files Browse the repository at this point in the history
Use return type hints instead of php doc "@return void"
  • Loading branch information
orklah committed Nov 26, 2021
2 parents a27e729 + 7279f00 commit 72de3b6
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 73 deletions.
3 changes: 0 additions & 3 deletions src/Psalm/Internal/Analyzer/ClassAnalyzer.php
Expand Up @@ -119,9 +119,6 @@ public static function getAnonymousClassName(PhpParser\Node\Stmt\Class_ $class,
. '_' . $class->getLine() . '_' . (int)$class->getAttribute('startFilePos');
}

/**
* @return void
*/
public function analyze(
?Context $class_context = null,
?Context $global_context = null
Expand Down
Expand Up @@ -34,8 +34,6 @@ class AfterClassLikeVisitEvent

/**
* @param FileManipulation[] $file_replacements
*
* @return void
*/
public function __construct(
ClassLike $stmt,
Expand Down
5 changes: 1 addition & 4 deletions tests/BinaryOperationTest.php
Expand Up @@ -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!');
Expand Down
5 changes: 1 addition & 4 deletions tests/ClassTest.php
Expand Up @@ -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!');
Expand Down
8 changes: 2 additions & 6 deletions tests/Config/ConfigTest.php
Expand Up @@ -140,10 +140,7 @@ public function testIgnoreMissingProjectDirectory(): void
$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');

Expand Down Expand Up @@ -1378,8 +1375,7 @@ public function testSetsUsePhpStormMetaPath(): void
$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(
Expand Down
35 changes: 7 additions & 28 deletions tests/ErrorBaselineTest.php
Expand Up @@ -24,10 +24,7 @@ public function setUp() : void
$this->fileProvider = $this->prophesize(FileProvider::class);
}

/**
* @return void
*/
public function testLoadShouldParseXmlBaselineToPhpArray()
public function testLoadShouldParseXmlBaselineToPhpArray(): void
{
$baselineFilePath = 'baseline.xml';

Expand Down Expand Up @@ -95,10 +92,7 @@ public function testLoadShouldIgnoreLineEndingsInIssueSnippet(): void
);
}

/**
* @return void
*/
public function testLoadShouldThrowExceptionWhenFilesAreNotDefinedInBaselineFile()
public function testLoadShouldThrowExceptionWhenFilesAreNotDefinedInBaselineFile(): void
{
$this->expectException(ConfigException::class);

Expand All @@ -115,10 +109,7 @@ public function testLoadShouldThrowExceptionWhenFilesAreNotDefinedInBaselineFile
ErrorBaseline::read($this->fileProvider->reveal(), $baselineFile);
}

/**
* @return void
*/
public function testLoadShouldThrowExceptionWhenBaselineFileDoesNotExist()
public function testLoadShouldThrowExceptionWhenBaselineFileDoesNotExist(): void
{
$this->expectException(ConfigException::class);

Expand All @@ -129,10 +120,7 @@ public function testLoadShouldThrowExceptionWhenBaselineFileDoesNotExist()
ErrorBaseline::read($this->fileProvider->reveal(), $baselineFile);
}

/**
* @return void
*/
public function testCountTotalIssuesShouldReturnCorrectNumber()
public function testCountTotalIssuesShouldReturnCorrectNumber(): void
{
$existingIssues = [
'sample/sample-file.php' => [
Expand All @@ -149,10 +137,7 @@ public function testCountTotalIssuesShouldReturnCorrectNumber()
$this->assertSame($totalIssues, 5);
}

/**
* @return void
*/
public function testCreateShouldAggregateIssuesPerFile()
public function testCreateShouldAggregateIssuesPerFile(): void
{
$baselineFile = 'baseline.xml';

Expand Down Expand Up @@ -342,10 +327,7 @@ public function testCreateShouldAggregateIssuesPerFile()
$this->assertSame('1', $file2Issues[1]->getAttribute('occurrences'));
}

/**
* @return void
*/
public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes()
public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes(): void
{
$baselineFile = 'baseline.xml';

Expand Down Expand Up @@ -481,10 +463,7 @@ public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes()
], $remainingBaseline);
}

/**
* @return void
*/
public function testAddingACommentInBaselineDoesntTriggerNotice()
public function testAddingACommentInBaselineDoesntTriggerNotice(): void
{
$baselineFilePath = 'baseline.xml';

Expand Down
5 changes: 1 addition & 4 deletions tests/MethodCallTest.php
Expand Up @@ -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!');
Expand Down
20 changes: 4 additions & 16 deletions tests/MethodSignatureTest.php
Expand Up @@ -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!');
Expand Down Expand Up @@ -49,10 +46,7 @@ public function __soapCall(
$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!');
Expand All @@ -78,10 +72,7 @@ public function __soapCall(
$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!');
Expand Down Expand Up @@ -250,10 +241,7 @@ class D extends C {}'
$this->analyzeFile('somefile.php', new Context());
}

/**
* @return void
*/
public function testExtendDocblockParamTypeWithWrongDocblockParam()
public function testExtendDocblockParamTypeWithWrongDocblockParam(): void
{
$this->expectExceptionMessage('ImplementedParamTypeMismatch');
$this->expectException(\Psalm\Exception\CodeException::class);
Expand Down
4 changes: 1 addition & 3 deletions tests/Traits/InvalidCodeAnalysisTestTrait.php
Expand Up @@ -26,16 +26,14 @@ abstract public function providerInvalidCodeParse(): iterable;
* @param string $error_message
* @param array<int|string, string> $error_levels
* @param bool $strict_mode
*
* @return void
*/
public function testInvalidCode(
$code,
$error_message,
$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', '<')) {
Expand Down
4 changes: 1 addition & 3 deletions tests/Traits/ValidCodeAnalysisTestTrait.php
Expand Up @@ -27,15 +27,13 @@ abstract public function providerValidCodeParse(): iterable;
* @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', '<')) {
Expand Down

0 comments on commit 72de3b6

Please sign in to comment.