Skip to content

Commit

Permalink
Add missing void return types (#997)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgsowa authored May 31, 2024
1 parent d327cf2 commit d57da64
Show file tree
Hide file tree
Showing 56 changed files with 283 additions and 283 deletions.
12 changes: 6 additions & 6 deletions test/PhpParser/Builder/ClassConstTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function createClassConstBuilder($name, $value) {
return new ClassConst($name, $value);
}

public function testModifiers() {
public function testModifiers(): void {
$node = $this->createClassConstBuilder("TEST", 1)
->makePrivate()
->getNode()
Expand Down Expand Up @@ -82,7 +82,7 @@ public function testModifiers() {
);
}

public function testDocComment() {
public function testDocComment(): void {
$node = $this->createClassConstBuilder('TEST', 1)
->setDocComment('/** Test */')
->makePublic()
Expand All @@ -102,7 +102,7 @@ public function testDocComment() {
);
}

public function testAddConst() {
public function testAddConst(): void {
$node = $this->createClassConstBuilder('FIRST_TEST', 1)
->addConst("SECOND_TEST", 2)
->getNode();
Expand All @@ -118,7 +118,7 @@ public function testAddConst() {
);
}

public function testAddAttribute() {
public function testAddAttribute(): void {
$attribute = new Attribute(
new Name('Attr'),
[new Arg(new Int_(1), false, false, [], new Identifier('name'))]
Expand All @@ -142,7 +142,7 @@ public function testAddAttribute() {
);
}

public function testType() {
public function testType(): void {
$node = $this->createClassConstBuilder('TYPE', 1)
->setType('int')
->getNode();
Expand All @@ -157,7 +157,7 @@ public function testType() {
/**
* @dataProvider provideTestDefaultValues
*/
public function testValues($value, $expectedValueNode) {
public function testValues($value, $expectedValueNode): void {
$node = $this->createClassConstBuilder('TEST', $value)
->getNode()
;
Expand Down
22 changes: 11 additions & 11 deletions test/PhpParser/Builder/ClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function createClassBuilder($class) {
return new Class_($class);
}

public function testExtendsImplements() {
public function testExtendsImplements(): void {
$node = $this->createClassBuilder('SomeLogger')
->extend('BaseLogger')
->implement('Namespaced\Logger', new Name('SomeInterface'))
Expand All @@ -40,7 +40,7 @@ public function testExtendsImplements() {
);
}

public function testAbstract() {
public function testAbstract(): void {
$node = $this->createClassBuilder('Test')
->makeAbstract()
->getNode()
Expand All @@ -54,7 +54,7 @@ public function testAbstract() {
);
}

public function testFinal() {
public function testFinal(): void {
$node = $this->createClassBuilder('Test')
->makeFinal()
->getNode()
Expand All @@ -68,7 +68,7 @@ public function testFinal() {
);
}

public function testReadonly() {
public function testReadonly(): void {
$node = $this->createClassBuilder('Test')
->makeReadonly()
->getNode()
Expand All @@ -82,7 +82,7 @@ public function testReadonly() {
);
}

public function testStatementOrder() {
public function testStatementOrder(): void {
$method = new Stmt\ClassMethod('testMethod');
$property = new Stmt\Property(
Modifiers::PUBLIC,
Expand All @@ -108,7 +108,7 @@ public function testStatementOrder() {
);
}

public function testDocComment() {
public function testDocComment(): void {
$docComment = <<<'DOC'
/**
* Test
Expand Down Expand Up @@ -141,7 +141,7 @@ public function testDocComment() {
);
}

public function testAddAttribute() {
public function testAddAttribute(): void {
$attribute = new Attribute(
new Name('Attr'),
[new Arg(new Int_(1), false, false, [], new Identifier('name'))]
Expand All @@ -162,29 +162,29 @@ public function testAddAttribute() {
);
}

public function testInvalidStmtError() {
public function testInvalidStmtError(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Unexpected node of type "Stmt_Echo"');
$this->createClassBuilder('Test')
->addStmt(new Stmt\Echo_([]))
;
}

public function testInvalidDocComment() {
public function testInvalidDocComment(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Doc comment must be a string or an instance of PhpParser\Comment\Doc');
$this->createClassBuilder('Test')
->setDocComment(new Comment('Test'));
}

public function testEmptyName() {
public function testEmptyName(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Name cannot be empty');
$this->createClassBuilder('Test')
->extend('');
}

public function testInvalidName() {
public function testInvalidName(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Name must be a string or an instance of Node\Name');
$this->createClassBuilder('Test')
Expand Down
6 changes: 3 additions & 3 deletions test/PhpParser/Builder/EnumCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function createEnumCaseBuilder($name) {
return new EnumCase($name);
}

public function testDocComment() {
public function testDocComment(): void {
$node = $this->createEnumCaseBuilder('TEST')
->setDocComment('/** Test */')
->getNode();
Expand All @@ -35,7 +35,7 @@ public function testDocComment() {
);
}

public function testAddAttribute() {
public function testAddAttribute(): void {
$attribute = new Attribute(
new Name('Attr'),
[new Arg(new Int_(1), false, false, [], new Identifier('name'))]
Expand All @@ -59,7 +59,7 @@ public function testAddAttribute() {
/**
* @dataProvider provideTestDefaultValues
*/
public function testValues($value, $expectedValueNode) {
public function testValues($value, $expectedValueNode): void {
$node = $this->createEnumCaseBuilder('TEST')
->setValue($value)
->getNode()
Expand Down
18 changes: 9 additions & 9 deletions test/PhpParser/Builder/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected function createEnumBuilder($class) {
return new Enum_($class);
}

public function testImplements() {
public function testImplements(): void {
$node = $this->createEnumBuilder('SomeEnum')
->implement('Namespaced\SomeInterface', new Name('OtherInterface'))
->getNode()
Expand All @@ -34,7 +34,7 @@ public function testImplements() {
);
}

public function testSetScalarType() {
public function testSetScalarType(): void {
$node = $this->createEnumBuilder('Test')
->setScalarType('int')
->getNode()
Expand All @@ -48,7 +48,7 @@ public function testSetScalarType() {
);
}

public function testStatementOrder() {
public function testStatementOrder(): void {
$method = new Stmt\ClassMethod('testMethod');
$enumCase = new Stmt\EnumCase(
'TEST_ENUM_CASE'
Expand All @@ -73,7 +73,7 @@ public function testStatementOrder() {
);
}

public function testDocComment() {
public function testDocComment(): void {
$docComment = <<<'DOC'
/**
* Test
Expand Down Expand Up @@ -106,7 +106,7 @@ public function testDocComment() {
);
}

public function testAddAttribute() {
public function testAddAttribute(): void {
$attribute = new Attribute(
new Name('Attr'),
[new Arg(new Int_(1), false, false, [], new Identifier('name'))]
Expand All @@ -127,29 +127,29 @@ public function testAddAttribute() {
);
}

public function testInvalidStmtError() {
public function testInvalidStmtError(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Unexpected node of type "PropertyItem"');
$this->createEnumBuilder('Test')
->addStmt(new Node\PropertyItem('property'))
;
}

public function testInvalidDocComment() {
public function testInvalidDocComment(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Doc comment must be a string or an instance of PhpParser\Comment\Doc');
$this->createEnumBuilder('Test')
->setDocComment(new Comment('Test'));
}

public function testEmptyName() {
public function testEmptyName(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Name cannot be empty');
$this->createEnumBuilder('Test')
->implement('');
}

public function testInvalidName() {
public function testInvalidName(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Name must be a string or an instance of Node\Name');
$this->createEnumBuilder('Test')
Expand Down
18 changes: 9 additions & 9 deletions test/PhpParser/Builder/FunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function createFunctionBuilder($name) {
return new Function_($name);
}

public function testReturnByRef() {
public function testReturnByRef(): void {
$node = $this->createFunctionBuilder('test')
->makeReturnByRef()
->getNode()
Expand All @@ -34,7 +34,7 @@ public function testReturnByRef() {
);
}

public function testParams() {
public function testParams(): void {
$param1 = new Node\Param(new Variable('test1'));
$param2 = new Node\Param(new Variable('test2'));
$param3 = new Node\Param(new Variable('test3'));
Expand All @@ -53,7 +53,7 @@ public function testParams() {
);
}

public function testStmts() {
public function testStmts(): void {
$stmt1 = new Print_(new String_('test1'));
$stmt2 = new Print_(new String_('test2'));
$stmt3 = new Print_(new String_('test3'));
Expand All @@ -76,7 +76,7 @@ public function testStmts() {
);
}

public function testDocComment() {
public function testDocComment(): void {
$node = $this->createFunctionBuilder('test')
->setDocComment('/** Test */')
->getNode();
Expand All @@ -86,7 +86,7 @@ public function testDocComment() {
]), $node);
}

public function testAddAttribute() {
public function testAddAttribute(): void {
$attribute = new Attribute(
new Name('Attr'),
[new Arg(new Int_(1), false, false, [], new Identifier('name'))]
Expand All @@ -102,7 +102,7 @@ public function testAddAttribute() {
], []), $node);
}

public function testReturnType() {
public function testReturnType(): void {
$node = $this->createFunctionBuilder('test')
->setReturnType('void')
->getNode();
Expand All @@ -112,21 +112,21 @@ public function testReturnType() {
], []), $node);
}

public function testInvalidNullableVoidType() {
public function testInvalidNullableVoidType(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('void type cannot be nullable');
$this->createFunctionBuilder('test')->setReturnType('?void');
}

public function testInvalidParamError() {
public function testInvalidParamError(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Expected parameter node, got "Name"');
$this->createFunctionBuilder('test')
->addParam(new Node\Name('foo'))
;
}

public function testAddNonStmt() {
public function testAddNonStmt(): void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Expected statement or expression node');
$this->createFunctionBuilder('test')
Expand Down
Loading

0 comments on commit d57da64

Please sign in to comment.