diff --git a/test/PhpParser/Builder/ClassConstTest.php b/test/PhpParser/Builder/ClassConstTest.php index 4a71e0fdd5..f0cccfd2c8 100644 --- a/test/PhpParser/Builder/ClassConstTest.php +++ b/test/PhpParser/Builder/ClassConstTest.php @@ -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() @@ -82,7 +82,7 @@ public function testModifiers() { ); } - public function testDocComment() { + public function testDocComment(): void { $node = $this->createClassConstBuilder('TEST', 1) ->setDocComment('/** Test */') ->makePublic() @@ -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(); @@ -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'))] @@ -142,7 +142,7 @@ public function testAddAttribute() { ); } - public function testType() { + public function testType(): void { $node = $this->createClassConstBuilder('TYPE', 1) ->setType('int') ->getNode(); @@ -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() ; diff --git a/test/PhpParser/Builder/ClassTest.php b/test/PhpParser/Builder/ClassTest.php index 334a85382c..69866b7b79 100644 --- a/test/PhpParser/Builder/ClassTest.php +++ b/test/PhpParser/Builder/ClassTest.php @@ -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')) @@ -40,7 +40,7 @@ public function testExtendsImplements() { ); } - public function testAbstract() { + public function testAbstract(): void { $node = $this->createClassBuilder('Test') ->makeAbstract() ->getNode() @@ -54,7 +54,7 @@ public function testAbstract() { ); } - public function testFinal() { + public function testFinal(): void { $node = $this->createClassBuilder('Test') ->makeFinal() ->getNode() @@ -68,7 +68,7 @@ public function testFinal() { ); } - public function testReadonly() { + public function testReadonly(): void { $node = $this->createClassBuilder('Test') ->makeReadonly() ->getNode() @@ -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, @@ -108,7 +108,7 @@ public function testStatementOrder() { ); } - public function testDocComment() { + public function testDocComment(): void { $docComment = <<<'DOC' /** * Test @@ -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'))] @@ -162,7 +162,7 @@ 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') @@ -170,21 +170,21 @@ public function testInvalidStmtError() { ; } - 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') diff --git a/test/PhpParser/Builder/EnumCaseTest.php b/test/PhpParser/Builder/EnumCaseTest.php index 66eb10c3dd..fb0ddfafab 100644 --- a/test/PhpParser/Builder/EnumCaseTest.php +++ b/test/PhpParser/Builder/EnumCaseTest.php @@ -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(); @@ -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'))] @@ -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() diff --git a/test/PhpParser/Builder/EnumTest.php b/test/PhpParser/Builder/EnumTest.php index c88a8d6069..f62392a26c 100644 --- a/test/PhpParser/Builder/EnumTest.php +++ b/test/PhpParser/Builder/EnumTest.php @@ -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() @@ -34,7 +34,7 @@ public function testImplements() { ); } - public function testSetScalarType() { + public function testSetScalarType(): void { $node = $this->createEnumBuilder('Test') ->setScalarType('int') ->getNode() @@ -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' @@ -73,7 +73,7 @@ public function testStatementOrder() { ); } - public function testDocComment() { + public function testDocComment(): void { $docComment = <<<'DOC' /** * Test @@ -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'))] @@ -127,7 +127,7 @@ public function testAddAttribute() { ); } - public function testInvalidStmtError() { + public function testInvalidStmtError(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Unexpected node of type "PropertyItem"'); $this->createEnumBuilder('Test') @@ -135,21 +135,21 @@ public function testInvalidStmtError() { ; } - 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') diff --git a/test/PhpParser/Builder/FunctionTest.php b/test/PhpParser/Builder/FunctionTest.php index 2fdecf7f6f..1b60112731 100644 --- a/test/PhpParser/Builder/FunctionTest.php +++ b/test/PhpParser/Builder/FunctionTest.php @@ -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() @@ -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')); @@ -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')); @@ -76,7 +76,7 @@ public function testStmts() { ); } - public function testDocComment() { + public function testDocComment(): void { $node = $this->createFunctionBuilder('test') ->setDocComment('/** Test */') ->getNode(); @@ -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'))] @@ -102,7 +102,7 @@ public function testAddAttribute() { ], []), $node); } - public function testReturnType() { + public function testReturnType(): void { $node = $this->createFunctionBuilder('test') ->setReturnType('void') ->getNode(); @@ -112,13 +112,13 @@ 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') @@ -126,7 +126,7 @@ public function testInvalidParamError() { ; } - public function testAddNonStmt() { + public function testAddNonStmt(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Expected statement or expression node'); $this->createFunctionBuilder('test') diff --git a/test/PhpParser/Builder/InterfaceTest.php b/test/PhpParser/Builder/InterfaceTest.php index 71652f72c1..75f2ed7d27 100644 --- a/test/PhpParser/Builder/InterfaceTest.php +++ b/test/PhpParser/Builder/InterfaceTest.php @@ -23,13 +23,13 @@ private function dump($node) { return $pp->prettyPrint([$node]); } - public function testEmpty() { + public function testEmpty(): void { $contract = $this->createInterfaceBuilder()->getNode(); $this->assertInstanceOf(Stmt\Interface_::class, $contract); $this->assertEquals(new Node\Identifier('Contract'), $contract->name); } - public function testExtending() { + public function testExtending(): void { $contract = $this->createInterfaceBuilder() ->extend('Space\Root1', 'Root2')->getNode(); $this->assertEquals( @@ -42,13 +42,13 @@ public function testExtending() { ); } - public function testAddMethod() { + public function testAddMethod(): void { $method = new Stmt\ClassMethod('doSomething'); $contract = $this->createInterfaceBuilder()->addStmt($method)->getNode(); $this->assertSame([$method], $contract->stmts); } - public function testAddConst() { + public function testAddConst(): void { $const = new Stmt\ClassConst([ new Node\Const_('SPEED_OF_LIGHT', new Float_(299792458.0)) ]); @@ -56,7 +56,7 @@ public function testAddConst() { $this->assertSame(299792458.0, $contract->stmts[0]->consts[0]->value->value); } - public function testOrder() { + public function testOrder(): void { $const = new Stmt\ClassConst([ new Node\Const_('SPEED_OF_LIGHT', new Float_(299792458)) ]); @@ -71,7 +71,7 @@ public function testOrder() { $this->assertInstanceOf(Stmt\ClassMethod::class, $contract->stmts[1]); } - public function testDocComment() { + public function testDocComment(): void { $node = $this->createInterfaceBuilder() ->setDocComment('/** Test */') ->getNode(); @@ -81,7 +81,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'))] @@ -97,13 +97,13 @@ public function testAddAttribute() { ], []), $node); } - public function testInvalidStmtError() { + public function testInvalidStmtError(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Unexpected node of type "PropertyItem"'); $this->createInterfaceBuilder()->addStmt(new Node\PropertyItem('invalid')); } - public function testFullFunctional() { + public function testFullFunctional(): void { $const = new Stmt\ClassConst([ new Node\Const_('SPEED_OF_LIGHT', new Float_(299792458)) ]); diff --git a/test/PhpParser/Builder/MethodTest.php b/test/PhpParser/Builder/MethodTest.php index 807072d735..a5ff8f7c80 100644 --- a/test/PhpParser/Builder/MethodTest.php +++ b/test/PhpParser/Builder/MethodTest.php @@ -21,7 +21,7 @@ public function createMethodBuilder($name) { return new Method($name); } - public function testModifiers() { + public function testModifiers(): void { $node = $this->createMethodBuilder('test') ->makePublic() ->makeAbstract() @@ -63,7 +63,7 @@ public function testModifiers() { ); } - public function testReturnByRef() { + public function testReturnByRef(): void { $node = $this->createMethodBuilder('test') ->makeReturnByRef() ->getNode() @@ -77,7 +77,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')); @@ -96,7 +96,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')); @@ -118,7 +118,7 @@ public function testStmts() { $node ); } - public function testDocComment() { + public function testDocComment(): void { $node = $this->createMethodBuilder('test') ->setDocComment('/** Test */') ->getNode(); @@ -128,7 +128,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'))] @@ -144,7 +144,7 @@ public function testAddAttribute() { ], []), $node); } - public function testReturnType() { + public function testReturnType(): void { $node = $this->createMethodBuilder('test') ->setReturnType('bool') ->getNode(); @@ -153,7 +153,7 @@ public function testReturnType() { ], []), $node); } - public function testAddStmtToAbstractMethodError() { + public function testAddStmtToAbstractMethodError(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot add statements to an abstract method'); $this->createMethodBuilder('test') @@ -162,7 +162,7 @@ public function testAddStmtToAbstractMethodError() { ; } - public function testMakeMethodWithStmtsAbstractError() { + public function testMakeMethodWithStmtsAbstractError(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot make method with statements abstract'); $this->createMethodBuilder('test') @@ -171,7 +171,7 @@ public function testMakeMethodWithStmtsAbstractError() { ; } - public function testInvalidParamError() { + public function testInvalidParamError(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Expected parameter node, got "Name"'); $this->createMethodBuilder('test') diff --git a/test/PhpParser/Builder/NamespaceTest.php b/test/PhpParser/Builder/NamespaceTest.php index 10a3870a83..2cce107f47 100644 --- a/test/PhpParser/Builder/NamespaceTest.php +++ b/test/PhpParser/Builder/NamespaceTest.php @@ -11,7 +11,7 @@ protected function createNamespaceBuilder($fqn) { return new Namespace_($fqn); } - public function testCreation() { + public function testCreation(): void { $stmt1 = new Stmt\Class_('SomeClass'); $stmt2 = new Stmt\Interface_('SomeInterface'); $stmt3 = new Stmt\Function_('someFunction'); diff --git a/test/PhpParser/Builder/ParamTest.php b/test/PhpParser/Builder/ParamTest.php index 58a6c04287..f1ac65bb8a 100644 --- a/test/PhpParser/Builder/ParamTest.php +++ b/test/PhpParser/Builder/ParamTest.php @@ -21,7 +21,7 @@ public function createParamBuilder($name) { /** * @dataProvider provideTestDefaultValues */ - public function testDefaultValues($value, $expectedValueNode) { + public function testDefaultValues($value, $expectedValueNode): void { $node = $this->createParamBuilder('test') ->setDefault($value) ->getNode() @@ -89,7 +89,7 @@ public function provideTestDefaultValues() { * @dataProvider provideTestNullableTypes * @dataProvider provideTestUnionTypes */ - public function testTypes($typeHint, $expectedType) { + public function testTypes($typeHint, $expectedType): void { $node = $this->createParamBuilder('test') ->setType($typeHint) ->getNode() @@ -169,19 +169,19 @@ public function provideTestUnionTypes() { ]; } - public function testVoidTypeError() { + public function testVoidTypeError(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Parameter type cannot be void'); $this->createParamBuilder('test')->setType('void'); } - public function testInvalidTypeError() { + public function testInvalidTypeError(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Type must be a string, or an instance of Name, Identifier or ComplexType'); $this->createParamBuilder('test')->setType(new \stdClass()); } - public function testByRef() { + public function testByRef(): void { $node = $this->createParamBuilder('test') ->makeByRef() ->getNode() @@ -193,7 +193,7 @@ public function testByRef() { ); } - public function testVariadic() { + public function testVariadic(): void { $node = $this->createParamBuilder('test') ->makeVariadic() ->getNode() @@ -205,7 +205,7 @@ public function testVariadic() { ); } - public function testMakePublic() { + public function testMakePublic(): void { $node = $this->createParamBuilder('test') ->makePublic() ->getNode() @@ -217,7 +217,7 @@ public function testMakePublic() { ); } - public function testMakeProtected() { + public function testMakeProtected(): void { $node = $this->createParamBuilder('test') ->makeProtected() ->getNode() @@ -229,7 +229,7 @@ public function testMakeProtected() { ); } - public function testMakePrivate() { + public function testMakePrivate(): void { $node = $this->createParamBuilder('test') ->makePrivate() ->getNode() @@ -241,7 +241,7 @@ public function testMakePrivate() { ); } - public function testMakeReadonly() { + public function testMakeReadonly(): void { $node = $this->createParamBuilder('test') ->makeReadonly() ->getNode() @@ -253,7 +253,7 @@ public function testMakeReadonly() { ); } - public function testAddAttribute() { + public function testAddAttribute(): void { $attribute = new Attribute( new Name('Attr'), [new Arg(new Int_(1), false, false, [], new Identifier('name'))] diff --git a/test/PhpParser/Builder/PropertyTest.php b/test/PhpParser/Builder/PropertyTest.php index 50fff0a8ac..b2983141cf 100644 --- a/test/PhpParser/Builder/PropertyTest.php +++ b/test/PhpParser/Builder/PropertyTest.php @@ -19,7 +19,7 @@ public function createPropertyBuilder($name) { return new Property($name); } - public function testModifiers() { + public function testModifiers(): void { $node = $this->createPropertyBuilder('test') ->makePrivate() ->makeStatic() @@ -82,7 +82,7 @@ public function testModifiers() { ); } - public function testDocComment() { + public function testDocComment(): void { $node = $this->createPropertyBuilder('test') ->setDocComment('/** Test */') ->getNode(); @@ -101,7 +101,7 @@ public function testDocComment() { /** * @dataProvider provideTestDefaultValues */ - public function testDefaultValues($value, $expectedValueNode) { + public function testDefaultValues($value, $expectedValueNode): void { $node = $this->createPropertyBuilder('test') ->setDefault($value) ->getNode() @@ -110,7 +110,7 @@ public function testDefaultValues($value, $expectedValueNode) { $this->assertEquals($expectedValueNode, $node->props[0]->default); } - public function testAddAttribute() { + public function testAddAttribute(): void { $attribute = new Attribute( new Name('Attr'), [new Arg(new Int_(1), false, false, [], new Identifier('name'))] diff --git a/test/PhpParser/Builder/TraitTest.php b/test/PhpParser/Builder/TraitTest.php index 850f198bbe..ddb9f9d631 100644 --- a/test/PhpParser/Builder/TraitTest.php +++ b/test/PhpParser/Builder/TraitTest.php @@ -23,7 +23,7 @@ protected function createTraitBuilder($class) { return new Trait_($class); } - public function testStmtAddition() { + public function testStmtAddition(): void { $method1 = new Stmt\ClassMethod('test1'); $method2 = new Stmt\ClassMethod('test2'); $method3 = new Stmt\ClassMethod('test3'); @@ -49,7 +49,7 @@ public function testStmtAddition() { ]), $trait); } - public function testInvalidStmtError() { + public function testInvalidStmtError(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Unexpected node of type "Stmt_Echo"'); $this->createTraitBuilder('Test') @@ -57,7 +57,7 @@ public function testInvalidStmtError() { ; } - public function testGetMethods() { + public function testGetMethods(): void { $methods = [ new ClassMethod('foo'), new ClassMethod('bar'), @@ -77,7 +77,7 @@ public function testGetMethods() { $this->assertSame($methods, $trait->getMethods()); } - public function testGetProperties() { + public function testGetProperties(): void { $properties = [ new Property(Modifiers::PUBLIC, [new PropertyItem('foo')]), new Property(Modifiers::PUBLIC, [new PropertyItem('bar')]), @@ -95,7 +95,7 @@ public function testGetProperties() { $this->assertSame($properties, $trait->getProperties()); } - public function testAddAttribute() { + public function testAddAttribute(): void { $attribute = new Attribute( new Name('Attr'), [new Arg(new Int_(1), false, false, [], new Identifier('name'))] diff --git a/test/PhpParser/Builder/TraitUseAdaptationTest.php b/test/PhpParser/Builder/TraitUseAdaptationTest.php index d08850bd1f..56ab75f185 100644 --- a/test/PhpParser/Builder/TraitUseAdaptationTest.php +++ b/test/PhpParser/Builder/TraitUseAdaptationTest.php @@ -12,7 +12,7 @@ protected function createTraitUseAdaptationBuilder($trait, $method) { return new TraitUseAdaptation($trait, $method); } - public function testAsMake() { + public function testAsMake(): void { $builder = $this->createTraitUseAdaptationBuilder(null, 'foo'); $this->assertEquals( @@ -36,7 +36,7 @@ public function testAsMake() { ); } - public function testInsteadof() { + public function testInsteadof(): void { $node = $this->createTraitUseAdaptationBuilder('SomeTrait', 'foo') ->insteadof('AnotherTrait') ->getNode() @@ -52,7 +52,7 @@ public function testInsteadof() { ); } - public function testAsOnNotAlias() { + public function testAsOnNotAlias(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot set alias for not alias adaptation buider'); $this->createTraitUseAdaptationBuilder('Test', 'foo') @@ -61,7 +61,7 @@ public function testAsOnNotAlias() { ; } - public function testInsteadofOnNotPrecedence() { + public function testInsteadofOnNotPrecedence(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot add overwritten traits for not precedence adaptation buider'); $this->createTraitUseAdaptationBuilder('Test', 'foo') @@ -70,7 +70,7 @@ public function testInsteadofOnNotPrecedence() { ; } - public function testInsteadofWithoutTrait() { + public function testInsteadofWithoutTrait(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Precedence adaptation must have trait'); $this->createTraitUseAdaptationBuilder(null, 'foo') @@ -78,7 +78,7 @@ public function testInsteadofWithoutTrait() { ; } - public function testMakeOnNotAlias() { + public function testMakeOnNotAlias(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot set access modifier for not alias adaptation buider'); $this->createTraitUseAdaptationBuilder('Test', 'foo') @@ -87,7 +87,7 @@ public function testMakeOnNotAlias() { ; } - public function testMultipleMake() { + public function testMultipleMake(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Multiple access type modifiers are not allowed'); $this->createTraitUseAdaptationBuilder(null, 'foo') @@ -96,7 +96,7 @@ public function testMultipleMake() { ; } - public function testUndefinedType() { + public function testUndefinedType(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Type of adaptation is not defined'); $this->createTraitUseAdaptationBuilder(null, 'foo') diff --git a/test/PhpParser/Builder/TraitUseTest.php b/test/PhpParser/Builder/TraitUseTest.php index b7bb527302..8101b777cb 100644 --- a/test/PhpParser/Builder/TraitUseTest.php +++ b/test/PhpParser/Builder/TraitUseTest.php @@ -10,7 +10,7 @@ protected function createTraitUseBuilder(...$traits) { return new TraitUse(...$traits); } - public function testAnd() { + public function testAnd(): void { $node = $this->createTraitUseBuilder('SomeTrait') ->and('AnotherTrait') ->getNode() @@ -25,7 +25,7 @@ public function testAnd() { ); } - public function testWith() { + public function testWith(): void { $node = $this->createTraitUseBuilder('SomeTrait') ->with(new Stmt\TraitUseAdaptation\Alias(null, 'foo', null, 'bar')) ->with((new TraitUseAdaptation(null, 'test'))->as('baz')) @@ -41,7 +41,7 @@ public function testWith() { ); } - public function testInvalidAdaptationNode() { + public function testInvalidAdaptationNode(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Adaptation must have type TraitUseAdaptation'); $this->createTraitUseBuilder('Test') diff --git a/test/PhpParser/Builder/UseTest.php b/test/PhpParser/Builder/UseTest.php index 2952d44099..5e5601589b 100644 --- a/test/PhpParser/Builder/UseTest.php +++ b/test/PhpParser/Builder/UseTest.php @@ -11,7 +11,7 @@ protected function createUseBuilder($name, $type = Stmt\Use_::TYPE_NORMAL) { return new Builder\Use_($name, $type); } - public function testCreation() { + public function testCreation(): void { $node = $this->createUseBuilder('Foo\Bar')->getNode(); $this->assertEquals(new Stmt\Use_([ new \PhpParser\Node\UseItem(new Name('Foo\Bar'), null) diff --git a/test/PhpParser/BuilderFactoryTest.php b/test/PhpParser/BuilderFactoryTest.php index a86e17e14f..8c08cc205e 100644 --- a/test/PhpParser/BuilderFactoryTest.php +++ b/test/PhpParser/BuilderFactoryTest.php @@ -15,7 +15,7 @@ class BuilderFactoryTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider provideTestFactory */ - public function testFactory($methodName, $className) { + public function testFactory($methodName, $className): void { $factory = new BuilderFactory(); $this->assertInstanceOf($className, $factory->$methodName('test')); } @@ -38,12 +38,12 @@ public function provideTestFactory() { ]; } - public function testFactoryClassConst() { + public function testFactoryClassConst(): void { $factory = new BuilderFactory(); $this->assertInstanceOf(Builder\ClassConst::class, $factory->classConst('TEST', 1)); } - public function testAttribute() { + public function testAttribute(): void { $factory = new BuilderFactory(); $this->assertEquals( new Attribute(new Name('AttributeName'), [new Arg( @@ -53,7 +53,7 @@ public function testAttribute() { ); } - public function testVal() { + public function testVal(): void { // This method is a wrapper around BuilderHelpers::normalizeValue(), // which is already tested elsewhere $factory = new BuilderFactory(); @@ -63,7 +63,7 @@ public function testVal() { ); } - public function testConcat() { + public function testConcat(): void { $factory = new BuilderFactory(); $varA = new Expr\Variable('a'); $varB = new Expr\Variable('b'); @@ -83,19 +83,19 @@ public function testConcat() { ); } - public function testConcatOneError() { + public function testConcatOneError(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Expected at least two expressions'); (new BuilderFactory())->concat("a"); } - public function testConcatInvalidExpr() { + public function testConcatInvalidExpr(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Expected string or Expr'); (new BuilderFactory())->concat("a", 42); } - public function testArgs() { + public function testArgs(): void { $factory = new BuilderFactory(); $unpack = new Arg(new Expr\Variable('c'), false, true); $this->assertEquals( @@ -108,7 +108,7 @@ public function testArgs() { ); } - public function testNamedArgs() { + public function testNamedArgs(): void { $factory = new BuilderFactory(); $this->assertEquals( [ @@ -119,7 +119,7 @@ public function testNamedArgs() { ); } - public function testCalls() { + public function testCalls(): void { $factory = new BuilderFactory(); // Simple function call @@ -195,7 +195,7 @@ public function testCalls() { ); } - public function testConstFetches() { + public function testConstFetches(): void { $factory = new BuilderFactory(); $this->assertEquals( new Expr\ConstFetch(new Name('FOO')), @@ -215,7 +215,7 @@ public function testConstFetches() { ); } - public function testVar() { + public function testVar(): void { $factory = new BuilderFactory(); $this->assertEquals( new Expr\Variable("foo"), @@ -227,7 +227,7 @@ public function testVar() { ); } - public function testPropertyFetch() { + public function testPropertyFetch(): void { $f = new BuilderFactory(); $this->assertEquals( new Expr\PropertyFetch(new Expr\Variable('foo'), 'bar'), @@ -243,31 +243,31 @@ public function testPropertyFetch() { ); } - public function testInvalidIdentifier() { + public function testInvalidIdentifier(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Expected string or instance of Node\Identifier'); (new BuilderFactory())->classConstFetch('Foo', new Name('foo')); } - public function testInvalidIdentifierOrExpr() { + public function testInvalidIdentifierOrExpr(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Expected string or instance of Node\Identifier or Node\Expr'); (new BuilderFactory())->staticCall('Foo', new Name('bar')); } - public function testInvalidNameOrExpr() { + public function testInvalidNameOrExpr(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Name must be a string or an instance of Node\Name or Node\Expr'); (new BuilderFactory())->funcCall(new Node\Stmt\Return_()); } - public function testInvalidVar() { + public function testInvalidVar(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Variable name must be string or Expr'); (new BuilderFactory())->var(new Node\Stmt\Return_()); } - public function testIntegration() { + public function testIntegration(): void { $factory = new BuilderFactory(); $node = $factory->namespace('Name\Space') ->addStmt($factory->use('Foo\Bar\SomeOtherClass')) diff --git a/test/PhpParser/BuilderHelpersTest.php b/test/PhpParser/BuilderHelpersTest.php index d70be9d8ce..0e89e47fbb 100644 --- a/test/PhpParser/BuilderHelpersTest.php +++ b/test/PhpParser/BuilderHelpersTest.php @@ -9,7 +9,7 @@ use PhpParser\Node\Expr; class BuilderHelpersTest extends \PHPUnit\Framework\TestCase { - public function testNormalizeNode() { + public function testNormalizeNode(): void { $builder = new Class_('SomeClass'); $this->assertEquals($builder->getNode(), BuilderHelpers::normalizeNode($builder)); @@ -21,7 +21,7 @@ public function testNormalizeNode() { BuilderHelpers::normalizeNode('test'); } - public function testNormalizeStmt() { + public function testNormalizeStmt(): void { $stmt = new Node\Stmt\Class_('Class'); $this->assertSame($stmt, BuilderHelpers::normalizeStmt($stmt)); @@ -35,13 +35,13 @@ public function testNormalizeStmt() { BuilderHelpers::normalizeStmt(new Node\Attribute(new Node\Name('Test'))); } - public function testNormalizeStmtInvalidType() { + public function testNormalizeStmtInvalidType(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Expected node or builder object'); BuilderHelpers::normalizeStmt('test'); } - public function testNormalizeIdentifier() { + public function testNormalizeIdentifier(): void { $identifier = new Node\Identifier('fn'); $this->assertSame($identifier, BuilderHelpers::normalizeIdentifier($identifier)); $this->assertEquals($identifier, BuilderHelpers::normalizeIdentifier('fn')); @@ -51,7 +51,7 @@ public function testNormalizeIdentifier() { BuilderHelpers::normalizeIdentifier(1); } - public function testNormalizeIdentifierOrExpr() { + public function testNormalizeIdentifierOrExpr(): void { $identifier = new Node\Identifier('fn'); $this->assertSame($identifier, BuilderHelpers::normalizeIdentifierOrExpr($identifier)); @@ -64,7 +64,7 @@ public function testNormalizeIdentifierOrExpr() { BuilderHelpers::normalizeIdentifierOrExpr(1); } - public function testNormalizeName() { + public function testNormalizeName(): void { $name = new Node\Name('test'); $this->assertSame($name, BuilderHelpers::normalizeName($name)); $this->assertEquals( @@ -82,13 +82,13 @@ public function testNormalizeName() { BuilderHelpers::normalizeName(''); } - public function testNormalizeNameInvalidType() { + public function testNormalizeNameInvalidType(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Name must be a string or an instance of Node\Name'); BuilderHelpers::normalizeName(1); } - public function testNormalizeNameOrExpr() { + public function testNormalizeNameOrExpr(): void { $expr = new Expr\Variable('fn'); $this->assertSame($expr, BuilderHelpers::normalizeNameOrExpr($expr)); @@ -109,13 +109,13 @@ public function testNormalizeNameOrExpr() { BuilderHelpers::normalizeNameOrExpr(''); } - public function testNormalizeNameOrExpInvalidType() { + public function testNormalizeNameOrExpInvalidType(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Name must be a string or an instance of Node\Name or Node\Expr'); BuilderHelpers::normalizeNameOrExpr(1); } - public function testNormalizeType() { + public function testNormalizeType(): void { $this->assertEquals(new Node\Identifier('array'), BuilderHelpers::normalizeType('array')); $this->assertEquals(new Node\Identifier('callable'), BuilderHelpers::normalizeType('callable')); $this->assertEquals(new Node\Identifier('string'), BuilderHelpers::normalizeType('string')); @@ -156,25 +156,25 @@ public function testNormalizeType() { BuilderHelpers::normalizeType(1); } - public function testNormalizeTypeNullableVoid() { + public function testNormalizeTypeNullableVoid(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('void type cannot be nullable'); BuilderHelpers::normalizeType('?void'); } - public function testNormalizeTypeNullableMixed() { + public function testNormalizeTypeNullableMixed(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('mixed type cannot be nullable'); BuilderHelpers::normalizeType('?mixed'); } - public function testNormalizeTypeNullableNever() { + public function testNormalizeTypeNullableNever(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('never type cannot be nullable'); BuilderHelpers::normalizeType('?never'); } - public function testNormalizeValue() { + public function testNormalizeValue(): void { $expression = new Scalar\Int_(1); $this->assertSame($expression, BuilderHelpers::normalizeValue($expression)); @@ -200,7 +200,7 @@ public function testNormalizeValue() { BuilderHelpers::normalizeValue(new \stdClass()); } - public function testNormalizeDocComment() { + public function testNormalizeDocComment(): void { $docComment = new Comment\Doc('Some doc comment'); $this->assertSame($docComment, BuilderHelpers::normalizeDocComment($docComment)); @@ -211,7 +211,7 @@ public function testNormalizeDocComment() { BuilderHelpers::normalizeDocComment(1); } - public function testNormalizeAttribute() { + public function testNormalizeAttribute(): void { $attribute = new Node\Attribute(new Node\Name('Test')); $attributeGroup = new Node\AttributeGroup([$attribute]); diff --git a/test/PhpParser/CodeParsingTest.php b/test/PhpParser/CodeParsingTest.php index d4da650a26..b843e2860a 100644 --- a/test/PhpParser/CodeParsingTest.php +++ b/test/PhpParser/CodeParsingTest.php @@ -9,7 +9,7 @@ class CodeParsingTest extends CodeTestAbstract { /** * @dataProvider provideTestParse */ - public function testParse($name, $code, $expected, $modeLine) { + public function testParse($name, $code, $expected, $modeLine): void { $modes = $this->parseModeLine($modeLine); $parser = $this->createParser($modes['version'] ?? null); list($stmts, $output) = $this->getParseOutput($parser, $code, $modes); @@ -62,13 +62,13 @@ private function formatErrorMessage(Error $e, $code) { return $e->getMessage(); } - private function checkAttributes($stmts) { + private function checkAttributes($stmts): void { if ($stmts === null) { return; } $traverser = new NodeTraverser(new class () extends NodeVisitorAbstract { - public function enterNode(Node $node) { + public function enterNode(Node $node): void { $startLine = $node->getStartLine(); $endLine = $node->getEndLine(); $startFilePos = $node->getStartFilePos(); diff --git a/test/PhpParser/CommentTest.php b/test/PhpParser/CommentTest.php index c97308d9f1..255eccb801 100644 --- a/test/PhpParser/CommentTest.php +++ b/test/PhpParser/CommentTest.php @@ -3,7 +3,7 @@ namespace PhpParser; class CommentTest extends \PHPUnit\Framework\TestCase { - public function testGetters() { + public function testGetters(): void { $comment = new Comment('/* Some comment */', 1, 10, 2, 1, 27, 2); @@ -20,7 +20,7 @@ public function testGetters() { /** * @dataProvider provideTestReformatting */ - public function testReformatting($commentText, $reformattedText) { + public function testReformatting($commentText, $reformattedText): void { $comment = new Comment($commentText); $this->assertSame($reformattedText, $comment->getReformattedText()); } diff --git a/test/PhpParser/CompatibilityTest.php b/test/PhpParser/CompatibilityTest.php index 71f1f236b8..9928e8d85f 100644 --- a/test/PhpParser/CompatibilityTest.php +++ b/test/PhpParser/CompatibilityTest.php @@ -13,7 +13,7 @@ class CompatibilityTest extends \PHPUnit\Framework\TestCase { * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testAliases1() { + public function testAliases1(): void { $var = new Expr\Variable('x'); $node = new Node\ClosureUse($var); $this->assertTrue($node instanceof Expr\ClosureUse); @@ -41,7 +41,7 @@ public function testAliases1() { * @runInSeparateProcess * @preserveGlobalState disabled */ - public function testAliases2() { + public function testAliases2(): void { $var = new Expr\Variable('x'); $node = new Node\Expr\ClosureUse($var); $this->assertTrue($node instanceof Node\ClosureUse); diff --git a/test/PhpParser/ConstExprEvaluatorTest.php b/test/PhpParser/ConstExprEvaluatorTest.php index 9d78af88a9..0f5ac79420 100644 --- a/test/PhpParser/ConstExprEvaluatorTest.php +++ b/test/PhpParser/ConstExprEvaluatorTest.php @@ -7,7 +7,7 @@ class ConstExprEvaluatorTest extends \PHPUnit\Framework\TestCase { /** @dataProvider provideTestEvaluate */ - public function testEvaluate($exprString, $expected) { + public function testEvaluate($exprString, $expected): void { $parser = new Parser\Php7(new Lexer()); $expr = $parser->parse('expr; $evaluator = new ConstExprEvaluator(); @@ -74,14 +74,14 @@ public function provideTestEvaluate() { ]; } - public function testEvaluateFails() { + public function testEvaluateFails(): void { $this->expectException(ConstExprEvaluationException::class); $this->expectExceptionMessage('Expression of type Expr_Variable cannot be evaluated'); $evaluator = new ConstExprEvaluator(); $evaluator->evaluateDirectly(new Expr\Variable('a')); } - public function testEvaluateFallback() { + public function testEvaluateFallback(): void { $evaluator = new ConstExprEvaluator(function (Expr $expr) { if ($expr instanceof Scalar\MagicConst\Line) { return 42; @@ -98,7 +98,7 @@ public function testEvaluateFallback() { /** * @dataProvider provideTestEvaluateSilently */ - public function testEvaluateSilently($expr, $exception, $msg) { + public function testEvaluateSilently($expr, $exception, $msg): void { $evaluator = new ConstExprEvaluator(); try { diff --git a/test/PhpParser/ErrorHandler/CollectingTest.php b/test/PhpParser/ErrorHandler/CollectingTest.php index 83b1cbd0ac..631b0b0ba4 100644 --- a/test/PhpParser/ErrorHandler/CollectingTest.php +++ b/test/PhpParser/ErrorHandler/CollectingTest.php @@ -5,7 +5,7 @@ use PhpParser\Error; class CollectingTest extends \PHPUnit\Framework\TestCase { - public function testHandleError() { + public function testHandleError(): void { $errorHandler = new Collecting(); $this->assertFalse($errorHandler->hasErrors()); $this->assertEmpty($errorHandler->getErrors()); diff --git a/test/PhpParser/ErrorHandler/ThrowingTest.php b/test/PhpParser/ErrorHandler/ThrowingTest.php index 61efd7bcfd..8442600a63 100644 --- a/test/PhpParser/ErrorHandler/ThrowingTest.php +++ b/test/PhpParser/ErrorHandler/ThrowingTest.php @@ -5,7 +5,7 @@ use PhpParser\Error; class ThrowingTest extends \PHPUnit\Framework\TestCase { - public function testHandleError() { + public function testHandleError(): void { $this->expectException(Error::class); $this->expectExceptionMessage('Test'); $errorHandler = new Throwing(); diff --git a/test/PhpParser/ErrorTest.php b/test/PhpParser/ErrorTest.php index f378ab234d..b3ef521e67 100644 --- a/test/PhpParser/ErrorTest.php +++ b/test/PhpParser/ErrorTest.php @@ -22,7 +22,7 @@ public function testConstruct() { /** * @depends testConstruct */ - public function testSetMessageAndLine(Error $error) { + public function testSetMessageAndLine(Error $error): void { $error->setRawMessage('Some other error'); $this->assertSame('Some other error', $error->getRawMessage()); @@ -31,7 +31,7 @@ public function testSetMessageAndLine(Error $error) { $this->assertSame('Some other error on line 15', $error->getMessage()); } - public function testUnknownLine() { + public function testUnknownLine(): void { $error = new Error('Some error'); $this->assertSame(-1, $error->getStartLine()); @@ -40,7 +40,7 @@ public function testUnknownLine() { } /** @dataProvider provideTestColumnInfo */ - public function testColumnInfo($code, $startPos, $endPos, $startColumn, $endColumn) { + public function testColumnInfo($code, $startPos, $endPos, $startColumn, $endColumn): void { $error = new Error('Some error', [ 'startFilePos' => $startPos, 'endFilePos' => $endPos, @@ -72,7 +72,7 @@ public function provideTestColumnInfo() { ]; } - public function testNoColumnInfo() { + public function testNoColumnInfo(): void { $error = new Error('Some error', ['startLine' => 3]); $this->assertFalse($error->hasColumnInfo()); @@ -90,7 +90,7 @@ public function testNoColumnInfo() { } } - public function testInvalidPosInfo() { + public function testInvalidPosInfo(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Invalid position information'); $error = new Error('Some error', [ diff --git a/test/PhpParser/Internal/DifferTest.php b/test/PhpParser/Internal/DifferTest.php index 8b84c1a0d5..039335eee4 100644 --- a/test/PhpParser/Internal/DifferTest.php +++ b/test/PhpParser/Internal/DifferTest.php @@ -28,7 +28,7 @@ private function formatDiffString(array $diff) { } /** @dataProvider provideTestDiff */ - public function testDiff($oldStr, $newStr, $expectedDiffStr) { + public function testDiff($oldStr, $newStr, $expectedDiffStr): void { $differ = new Differ(function ($a, $b) { return $a === $b; }); @@ -49,7 +49,7 @@ public function provideTestDiff() { } /** @dataProvider provideTestDiffWithReplacements */ - public function testDiffWithReplacements($oldStr, $newStr, $expectedDiffStr) { + public function testDiffWithReplacements($oldStr, $newStr, $expectedDiffStr): void { $differ = new Differ(function ($a, $b) { return $a === $b; }); @@ -66,7 +66,7 @@ public function provideTestDiffWithReplacements() { ]; } - public function testNonContiguousIndices() { + public function testNonContiguousIndices(): void { $differ = new Differ(function ($a, $b) { return $a === $b; }); diff --git a/test/PhpParser/JsonDecoderTest.php b/test/PhpParser/JsonDecoderTest.php index 28fa4ed28b..3fb105f96d 100644 --- a/test/PhpParser/JsonDecoderTest.php +++ b/test/PhpParser/JsonDecoderTest.php @@ -3,7 +3,7 @@ namespace PhpParser; class JsonDecoderTest extends \PHPUnit\Framework\TestCase { - public function testRoundTrip() { + public function testRoundTrip(): void { $code = <<<'PHP' expectException(\RuntimeException::class); $this->expectExceptionMessage($expectedMessage); diff --git a/test/PhpParser/Lexer/EmulativeTest.php b/test/PhpParser/Lexer/EmulativeTest.php index 46ea65e449..f77da514be 100644 --- a/test/PhpParser/Lexer/EmulativeTest.php +++ b/test/PhpParser/Lexer/EmulativeTest.php @@ -19,7 +19,7 @@ protected function getLexer() { /** * @dataProvider provideTestReplaceKeywords */ - public function testReplaceKeywords(string $keyword, int $expectedToken) { + public function testReplaceKeywords(string $keyword, int $expectedToken): void { $lexer = $this->getLexer(); $code = 'assertEquals([ @@ -32,7 +32,7 @@ public function testReplaceKeywords(string $keyword, int $expectedToken) { /** * @dataProvider provideTestReplaceKeywords */ - public function testReplaceKeywordsUppercase(string $keyword, int $expectedToken) { + public function testReplaceKeywordsUppercase(string $keyword, int $expectedToken): void { $lexer = $this->getLexer(); $code = 'getLexer(); $code = '' . $keyword; @@ -61,7 +61,7 @@ public function testNoReplaceKeywordsAfterObjectOperator(string $keyword) { /** * @dataProvider provideTestReplaceKeywords */ - public function testNoReplaceKeywordsAfterObjectOperatorWithSpaces(string $keyword) { + public function testNoReplaceKeywordsAfterObjectOperatorWithSpaces(string $keyword): void { $lexer = $this->getLexer(); $code = ' ' . $keyword; @@ -77,7 +77,7 @@ public function testNoReplaceKeywordsAfterObjectOperatorWithSpaces(string $keywo /** * @dataProvider provideTestReplaceKeywords */ - public function testNoReplaceKeywordsAfterNullsafeObjectOperator(string $keyword) { + public function testNoReplaceKeywordsAfterNullsafeObjectOperator(string $keyword): void { $lexer = $this->getLexer(); $code = '' . $keyword; @@ -115,7 +115,7 @@ public function provideTestReplaceKeywords() { ]; } - private function assertSameTokens(array $expectedTokens, array $tokens) { + private function assertSameTokens(array $expectedTokens, array $tokens): void { $reducedTokens = []; foreach ($tokens as $token) { if ($token->id === 0 || $token->isIgnorable()) { @@ -129,7 +129,7 @@ private function assertSameTokens(array $expectedTokens, array $tokens) { /** * @dataProvider provideTestLexNewFeatures */ - public function testLexNewFeatures(string $code, array $expectedTokens) { + public function testLexNewFeatures(string $code, array $expectedTokens): void { $lexer = $this->getLexer(); $this->assertSameTokens($expectedTokens, $lexer->tokenize('getLexer(); @@ -153,7 +153,7 @@ public function testLeaveStuffAloneInStrings(string $code) { /** * @dataProvider provideTestLexNewFeatures */ - public function testErrorAfterEmulation($code) { + public function testErrorAfterEmulation($code): void { $errorHandler = new ErrorHandler\Collecting(); $lexer = $this->getLexer(); $lexer->tokenize('assertSameTokens($expectedTokens, $lexer->tokenize('markTestSkipped('HHVM does not throw warnings from token_get_all()'); } @@ -45,7 +45,7 @@ public function provideTestError() { ]; } - public function testDefaultErrorHandler() { + public function testDefaultErrorHandler(): void { $this->expectException(Error::class); $this->expectExceptionMessage('Unterminated comment on line 1'); $lexer = $this->getLexer(); @@ -55,7 +55,7 @@ public function testDefaultErrorHandler() { /** * @dataProvider provideTestLex */ - public function testLex($code, $expectedTokens) { + public function testLex($code, $expectedTokens): void { $lexer = $this->getLexer(); $tokens = $lexer->tokenize($code); foreach ($tokens as $token) { @@ -97,7 +97,7 @@ public function provideTestLex() { ]; } - public function testGetTokens() { + public function testGetTokens(): void { $code = 'startNamespace(new Name('NS')); $nameContext->addAlias(new Name('Foo'), 'Foo', Use_::TYPE_NORMAL); diff --git a/test/PhpParser/Node/Expr/CallableLikeTest.php b/test/PhpParser/Node/Expr/CallableLikeTest.php index 9a0349c3ac..c01bb8eb0a 100644 --- a/test/PhpParser/Node/Expr/CallableLikeTest.php +++ b/test/PhpParser/Node/Expr/CallableLikeTest.php @@ -11,7 +11,7 @@ class CallableLikeTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider provideTestIsFirstClassCallable */ - public function testIsFirstClassCallable(CallLike $node, bool $isFirstClassCallable) { + public function testIsFirstClassCallable(CallLike $node, bool $isFirstClassCallable): void { $this->assertSame($isFirstClassCallable, $node->isFirstClassCallable()); if (!$isFirstClassCallable) { $this->assertSame($node->getRawArgs(), $node->getArgs()); diff --git a/test/PhpParser/Node/IdentifierTest.php b/test/PhpParser/Node/IdentifierTest.php index 3b52806b9c..f8f328a709 100644 --- a/test/PhpParser/Node/IdentifierTest.php +++ b/test/PhpParser/Node/IdentifierTest.php @@ -3,12 +3,12 @@ namespace PhpParser\Node; class IdentifierTest extends \PHPUnit\Framework\TestCase { - public function testConstructorThrows() { + public function testConstructorThrows(): void { self::expectException(\InvalidArgumentException::class); new Identifier(''); } - public function testToString() { + public function testToString(): void { $identifier = new Identifier('Foo'); $this->assertSame('Foo', (string) $identifier); @@ -17,7 +17,7 @@ public function testToString() { } /** @dataProvider provideTestIsSpecialClassName */ - public function testIsSpecialClassName($identifier, $expected) { + public function testIsSpecialClassName($identifier, $expected): void { $identifier = new Identifier($identifier); $this->assertSame($expected, $identifier->isSpecialClassName()); } diff --git a/test/PhpParser/Node/NameTest.php b/test/PhpParser/Node/NameTest.php index 50df3624b7..262b95e2ed 100644 --- a/test/PhpParser/Node/NameTest.php +++ b/test/PhpParser/Node/NameTest.php @@ -3,7 +3,7 @@ namespace PhpParser\Node; class NameTest extends \PHPUnit\Framework\TestCase { - public function testConstruct() { + public function testConstruct(): void { $name = new Name(['foo', 'bar']); $this->assertSame('foo\bar', $name->name); @@ -14,7 +14,7 @@ public function testConstruct() { $this->assertSame('foo\bar', $name->name); } - public function testGet() { + public function testGet(): void { $name = new Name('foo'); $this->assertSame('foo', $name->getFirst()); $this->assertSame('foo', $name->getLast()); @@ -26,7 +26,7 @@ public function testGet() { $this->assertSame(['foo', 'bar'], $name->getParts()); } - public function testToString() { + public function testToString(): void { $name = new Name('Foo\Bar'); $this->assertSame('Foo\Bar', (string) $name); @@ -34,7 +34,7 @@ public function testToString() { $this->assertSame('foo\bar', $name->toLowerString()); } - public function testSlice() { + public function testSlice(): void { $name = new Name('foo\bar\baz'); $this->assertEquals(new Name('foo\bar\baz'), $name->slice(0)); $this->assertEquals(new Name('bar\baz'), $name->slice(1)); @@ -50,37 +50,37 @@ public function testSlice() { $this->assertNull($name->slice(-2, -2)); } - public function testSliceOffsetTooLarge() { + public function testSliceOffsetTooLarge(): void { $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage('Offset 4 is out of bounds'); (new Name('foo\bar\baz'))->slice(4); } - public function testSliceOffsetTooSmall() { + public function testSliceOffsetTooSmall(): void { $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage('Offset -4 is out of bounds'); (new Name('foo\bar\baz'))->slice(-4); } - public function testSliceLengthTooLarge() { + public function testSliceLengthTooLarge(): void { $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage('Length 4 is out of bounds'); (new Name('foo\bar\baz'))->slice(0, 4); } - public function testSliceLengthTooSmall() { + public function testSliceLengthTooSmall(): void { $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage('Length -4 is out of bounds'); (new Name('foo\bar\baz'))->slice(0, -4); } - public function testSliceLengthTooLargeWithOffset() { + public function testSliceLengthTooLargeWithOffset(): void { $this->expectException(\OutOfBoundsException::class); $this->expectExceptionMessage('Length 3 is out of bounds'); (new Name('foo\bar\baz'))->slice(1, 3); } - public function testConcat() { + public function testConcat(): void { $this->assertEquals(new Name('foo\bar\baz'), Name::concat('foo', 'bar\baz')); $this->assertEquals( new Name\FullyQualified('foo\bar'), @@ -98,7 +98,7 @@ public function testConcat() { $this->assertNull(Name::concat(null, null)); } - public function testNameTypes() { + public function testNameTypes(): void { $name = new Name('foo'); $this->assertTrue($name->isUnqualified()); $this->assertFalse($name->isQualified()); @@ -128,26 +128,26 @@ public function testNameTypes() { $this->assertSame('namespace\foo', $name->toCodeString()); } - public function testInvalidArg() { + public function testInvalidArg(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Expected string, array of parts or Name instance'); Name::concat('foo', new \stdClass()); } - public function testInvalidEmptyString() { + public function testInvalidEmptyString(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Name cannot be empty'); new Name(''); } - public function testInvalidEmptyArray() { + public function testInvalidEmptyArray(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Name cannot be empty'); new Name([]); } /** @dataProvider provideTestIsSpecialClassName */ - public function testIsSpecialClassName($name, $expected) { + public function testIsSpecialClassName($name, $expected): void { $name = new Name($name); $this->assertSame($expected, $name->isSpecialClassName()); } diff --git a/test/PhpParser/Node/ParamTest.php b/test/PhpParser/Node/ParamTest.php index ac0f3e79de..23b23ae052 100644 --- a/test/PhpParser/Node/ParamTest.php +++ b/test/PhpParser/Node/ParamTest.php @@ -6,7 +6,7 @@ use PhpParser\Node\Expr\Variable; class ParamTest extends \PHPUnit\Framework\TestCase { - public function testNoModifiers() { + public function testNoModifiers(): void { $node = new Param(new Variable('foo')); $this->assertFalse($node->isPromoted()); @@ -19,7 +19,7 @@ public function testNoModifiers() { /** * @dataProvider provideModifiers */ - public function testModifiers(string $modifier) { + public function testModifiers(string $modifier): void { $node = new Param(new Variable('foo')); $node->flags = constant(Modifiers::class . '::' . strtoupper($modifier)); $this->assertTrue($node->isPromoted()); diff --git a/test/PhpParser/Node/Scalar/DNumberTest.php b/test/PhpParser/Node/Scalar/DNumberTest.php index 25212a96b1..659fc61661 100644 --- a/test/PhpParser/Node/Scalar/DNumberTest.php +++ b/test/PhpParser/Node/Scalar/DNumberTest.php @@ -7,7 +7,7 @@ use PhpParser\ParserFactory; class DNumberTest extends \PHPUnit\Framework\TestCase { - public function testRawValue() { + public function testRawValue(): void { $parser = (new ParserFactory())->createForNewestSupportedVersion(); $nodes = $parser->parse('assertSame($name, $magicConst->getName()); } diff --git a/test/PhpParser/Node/Scalar/NumberTest.php b/test/PhpParser/Node/Scalar/NumberTest.php index c9f58acda9..db63ec2d12 100644 --- a/test/PhpParser/Node/Scalar/NumberTest.php +++ b/test/PhpParser/Node/Scalar/NumberTest.php @@ -6,7 +6,7 @@ use PhpParser\ParserFactory; class NumberTest extends \PHPUnit\Framework\TestCase { - public function testRawValue() { + public function testRawValue(): void { $parser = (new ParserFactory())->createForNewestSupportedVersion(); $nodes = $parser->parse('createForNewestSupportedVersion(); $nodes = $parser->parse('assertSame( $expected, String_::parseEscapeSequences($string, $quote) @@ -35,7 +35,7 @@ public function testParseEscapeSequences($expected, $string, $quote) { /** * @dataProvider provideTestParse */ - public function testCreate($expected, $string) { + public function testCreate($expected, $string): void { $this->assertSame( $expected, String_::parse($string) diff --git a/test/PhpParser/Node/Stmt/ClassConstTest.php b/test/PhpParser/Node/Stmt/ClassConstTest.php index 06e93279a7..789b9a9c79 100644 --- a/test/PhpParser/Node/Stmt/ClassConstTest.php +++ b/test/PhpParser/Node/Stmt/ClassConstTest.php @@ -8,7 +8,7 @@ class ClassConstTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider provideModifiers */ - public function testModifiers($modifier) { + public function testModifiers($modifier): void { $node = new ClassConst( [], // invalid constant(Modifiers::class . '::' . strtoupper($modifier)) @@ -17,7 +17,7 @@ public function testModifiers($modifier) { $this->assertTrue($node->{'is' . $modifier}()); } - public function testNoModifiers() { + public function testNoModifiers(): void { $node = new ClassConst([], 0); $this->assertTrue($node->isPublic()); diff --git a/test/PhpParser/Node/Stmt/ClassMethodTest.php b/test/PhpParser/Node/Stmt/ClassMethodTest.php index 0679bc557a..c3f779ea99 100644 --- a/test/PhpParser/Node/Stmt/ClassMethodTest.php +++ b/test/PhpParser/Node/Stmt/ClassMethodTest.php @@ -11,7 +11,7 @@ class ClassMethodTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider provideModifiers */ - public function testModifiers($modifier) { + public function testModifiers($modifier): void { $node = new ClassMethod('foo', [ 'type' => constant(Modifiers::class . '::' . strtoupper($modifier)) ]); @@ -19,7 +19,7 @@ public function testModifiers($modifier) { $this->assertTrue($node->{'is' . $modifier}()); } - public function testNoModifiers() { + public function testNoModifiers(): void { $node = new ClassMethod('foo', ['type' => 0]); $this->assertTrue($node->isPublic()); @@ -49,7 +49,7 @@ public function provideModifiers() { * * @param string $modifier Node type modifier */ - public function testImplicitPublic(string $modifier) { + public function testImplicitPublic(string $modifier): void { $node = new ClassMethod('foo', [ 'type' => constant(Modifiers::class . '::' . strtoupper($modifier)) ]); @@ -70,7 +70,7 @@ public function implicitPublicModifiers() { * * @param string $name Node name */ - public function testMagic(string $name) { + public function testMagic(string $name): void { $node = new ClassMethod($name); $this->assertTrue($node->isMagic(), 'Method should be magic'); } @@ -95,7 +95,7 @@ public function provideMagics() { ]; } - public function testFunctionLike() { + public function testFunctionLike(): void { $param = new Param(new Variable('a')); $type = new Name('Foo'); $return = new Return_(new Variable('a')); diff --git a/test/PhpParser/Node/Stmt/ClassTest.php b/test/PhpParser/Node/Stmt/ClassTest.php index f0295d2836..3f701b69d4 100644 --- a/test/PhpParser/Node/Stmt/ClassTest.php +++ b/test/PhpParser/Node/Stmt/ClassTest.php @@ -7,7 +7,7 @@ use PhpParser\Node\Scalar\String_; class ClassTest extends \PHPUnit\Framework\TestCase { - public function testIsAbstract() { + public function testIsAbstract(): void { $class = new Class_('Foo', ['type' => Modifiers::ABSTRACT]); $this->assertTrue($class->isAbstract()); @@ -15,7 +15,7 @@ public function testIsAbstract() { $this->assertFalse($class->isAbstract()); } - public function testIsFinal() { + public function testIsFinal(): void { $class = new Class_('Foo', ['type' => Modifiers::FINAL]); $this->assertTrue($class->isFinal()); @@ -23,7 +23,7 @@ public function testIsFinal() { $this->assertFalse($class->isFinal()); } - public function testGetTraitUses() { + public function testGetTraitUses(): void { $traitUses = [ new TraitUse([new Trait_('foo')]), new TraitUse([new Trait_('bar')]), @@ -39,7 +39,7 @@ public function testGetTraitUses() { $this->assertSame($traitUses, $class->getTraitUses()); } - public function testGetMethods() { + public function testGetMethods(): void { $methods = [ new ClassMethod('foo'), new ClassMethod('bar'), @@ -59,7 +59,7 @@ public function testGetMethods() { $this->assertSame($methods, $class->getMethods()); } - public function testGetConstants() { + public function testGetConstants(): void { $constants = [ new ClassConst([new \PhpParser\Node\Const_('foo', new String_('foo_value'))]), new ClassConst([new \PhpParser\Node\Const_('bar', new String_('bar_value'))]), @@ -76,7 +76,7 @@ public function testGetConstants() { $this->assertSame($constants, $class->getConstants()); } - public function testGetProperties() { + public function testGetProperties(): void { $properties = [ new Property(Modifiers::PUBLIC, [new PropertyItem('foo')]), new Property(Modifiers::PUBLIC, [new PropertyItem('bar')]), @@ -94,7 +94,7 @@ public function testGetProperties() { $this->assertSame($properties, $class->getProperties()); } - public function testGetProperty() { + public function testGetProperty(): void { $properties = [ $fooProp = new Property(Modifiers::PUBLIC, [new PropertyItem('foo1')]), $barProp = new Property(Modifiers::PUBLIC, [new PropertyItem('BAR1')]), @@ -119,7 +119,7 @@ public function testGetProperty() { $this->assertNull($class->getProperty('nonExisting')); } - public function testGetMethod() { + public function testGetMethod(): void { $methodConstruct = new ClassMethod('__CONSTRUCT'); $methodTest = new ClassMethod('test'); $class = new Class_('Foo', [ diff --git a/test/PhpParser/Node/Stmt/InterfaceTest.php b/test/PhpParser/Node/Stmt/InterfaceTest.php index 8d45e53add..5bb4a7840d 100644 --- a/test/PhpParser/Node/Stmt/InterfaceTest.php +++ b/test/PhpParser/Node/Stmt/InterfaceTest.php @@ -6,7 +6,7 @@ use PhpParser\Node\Scalar\String_; class InterfaceTest extends \PHPUnit\Framework\TestCase { - public function testGetMethods() { + public function testGetMethods(): void { $methods = [ new ClassMethod('foo'), new ClassMethod('bar'), @@ -24,7 +24,7 @@ public function testGetMethods() { $this->assertSame($methods, $interface->getMethods()); } - public function testGetConstants() { + public function testGetConstants(): void { $constants = [ new ClassConst([new \PhpParser\Node\Const_('foo', new String_('foo_value'))]), new ClassConst([new \PhpParser\Node\Const_('bar', new String_('bar_value'))]), diff --git a/test/PhpParser/Node/Stmt/PropertyTest.php b/test/PhpParser/Node/Stmt/PropertyTest.php index 712e93199a..8279aa7add 100644 --- a/test/PhpParser/Node/Stmt/PropertyTest.php +++ b/test/PhpParser/Node/Stmt/PropertyTest.php @@ -8,7 +8,7 @@ class PropertyTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider provideModifiers */ - public function testModifiers($modifier) { + public function testModifiers($modifier): void { $node = new Property( constant(Modifiers::class . '::' . strtoupper($modifier)), [] // invalid @@ -17,7 +17,7 @@ public function testModifiers($modifier) { $this->assertTrue($node->{'is' . $modifier}()); } - public function testNoModifiers() { + public function testNoModifiers(): void { $node = new Property(0, []); $this->assertTrue($node->isPublic()); @@ -27,7 +27,7 @@ public function testNoModifiers() { $this->assertFalse($node->isReadonly()); } - public function testStaticImplicitlyPublic() { + public function testStaticImplicitlyPublic(): void { $node = new Property(Modifiers::STATIC, []); $this->assertTrue($node->isPublic()); $this->assertFalse($node->isProtected()); diff --git a/test/PhpParser/NodeAbstractTest.php b/test/PhpParser/NodeAbstractTest.php index 3e7952aa5c..2b7c1f8cd9 100644 --- a/test/PhpParser/NodeAbstractTest.php +++ b/test/PhpParser/NodeAbstractTest.php @@ -75,7 +75,7 @@ public function testConstruct(array $attributes, Node $node) { /** * @dataProvider provideNodes */ - public function testGetDocComment(array $attributes, Node $node) { + public function testGetDocComment(array $attributes, Node $node): void { $this->assertSame('/** doc comment */', $node->getDocComment()->getText()); $comments = $node->getComments(); @@ -88,7 +88,7 @@ public function testGetDocComment(array $attributes, Node $node) { $this->assertNull($node->getDocComment()); } - public function testSetDocComment() { + public function testSetDocComment(): void { $node = new DummyNode(null, null, null, []); // Add doc comment to node without comments @@ -119,7 +119,7 @@ public function testSetDocComment() { /** * @dataProvider provideNodes */ - public function testChange(array $attributes, DummyNode $node) { + public function testChange(array $attributes, DummyNode $node): void { // direct modification $node->subNode1 = 'newValue'; $this->assertSame('newValue', $node->subNode1); @@ -137,7 +137,7 @@ public function testChange(array $attributes, DummyNode $node) { /** * @dataProvider provideNodes */ - public function testIteration(array $attributes, Node $node) { + public function testIteration(array $attributes, Node $node): void { // Iteration is simple object iteration over properties, // not over subnodes $i = 0; @@ -159,7 +159,7 @@ public function testIteration(array $attributes, Node $node) { $this->assertSame(3, $i); } - public function testAttributes() { + public function testAttributes(): void { /** @var $node Node */ $node = $this->getMockForAbstractClass(NodeAbstract::class); @@ -201,7 +201,7 @@ public function testAttributes() { ); } - public function testJsonSerialization() { + public function testJsonSerialization(): void { $code = <<<'PHP' assertSame($this->canonicalize($dump), $this->canonicalize($dumper->dump($node))); @@ -57,7 +57,7 @@ public function provideTestDump() { ]; } - public function testDumpWithPositions() { + public function testDumpWithPositions(): void { $parser = (new ParserFactory())->createForHostVersion(); $dumper = new NodeDumper(['dumpPositions' => true]); @@ -90,7 +90,7 @@ public function testDumpWithPositions() { $this->assertSame($this->canonicalize($expected), $this->canonicalize($dump)); } - public function testError() { + public function testError(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Can only dump nodes and arrays.'); $dumper = new NodeDumper(); diff --git a/test/PhpParser/NodeFinderTest.php b/test/PhpParser/NodeFinderTest.php index dd0641edbd..2929c5f869 100644 --- a/test/PhpParser/NodeFinderTest.php +++ b/test/PhpParser/NodeFinderTest.php @@ -14,7 +14,7 @@ private function getStmtsAndVars() { return [$stmts, $vars]; } - public function testFind() { + public function testFind(): void { $finder = new NodeFinder(); list($stmts, $vars) = $this->getStmtsAndVars(); $varFilter = function (Node $node) { @@ -29,7 +29,7 @@ public function testFind() { $this->assertSame([], $finder->find($stmts, $noneFilter)); } - public function testFindInstanceOf() { + public function testFindInstanceOf(): void { $finder = new NodeFinder(); list($stmts, $vars) = $this->getStmtsAndVars(); $this->assertSame($vars, $finder->findInstanceOf($stmts, Expr\Variable::class)); @@ -37,7 +37,7 @@ public function testFindInstanceOf() { $this->assertSame([], $finder->findInstanceOf($stmts, Expr\BinaryOp\Mul::class)); } - public function testFindFirst() { + public function testFindFirst(): void { $finder = new NodeFinder(); list($stmts, $vars) = $this->getStmtsAndVars(); $varFilter = function (Node $node) { @@ -52,7 +52,7 @@ public function testFindFirst() { $this->assertNull($finder->findFirst($stmts, $noneFilter)); } - public function testFindFirstInstanceOf() { + public function testFindFirstInstanceOf(): void { $finder = new NodeFinder(); list($stmts, $vars) = $this->getStmtsAndVars(); $this->assertSame($vars[0], $finder->findFirstInstanceOf($stmts, Expr\Variable::class)); diff --git a/test/PhpParser/NodeTraverserTest.php b/test/PhpParser/NodeTraverserTest.php index 255741da2c..bc84600b6c 100644 --- a/test/PhpParser/NodeTraverserTest.php +++ b/test/PhpParser/NodeTraverserTest.php @@ -9,7 +9,7 @@ use PhpParser\Node\Stmt\If_; class NodeTraverserTest extends \PHPUnit\Framework\TestCase { - public function testNonModifying() { + public function testNonModifying(): void { $str1Node = new String_('Foo'); $str2Node = new String_('Bar'); $echoNode = new Node\Stmt\Echo_([$str1Node, $str2Node]); @@ -32,7 +32,7 @@ public function testNonModifying() { ], $visitor->trace); } - public function testModifying() { + public function testModifying(): void { $str1Node = new String_('Foo'); $str2Node = new String_('Bar'); $printNode = new Expr\Print_($str1Node); @@ -75,7 +75,7 @@ public function testModifying() { ], $visitor3->trace); } - public function testRemoveFromLeave() { + public function testRemoveFromLeave(): void { $str1Node = new String_('Foo'); $str2Node = new String_('Bar'); @@ -99,7 +99,7 @@ public function testRemoveFromLeave() { ], $visitor2->trace); } - public function testRemoveFromEnter() { + public function testRemoveFromEnter(): void { $str1Node = new String_('Foo'); $str2Node = new String_('Bar'); @@ -122,7 +122,7 @@ public function testRemoveFromEnter() { ], $visitor2->trace); } - public function testReturnArrayFromEnter() { + public function testReturnArrayFromEnter(): void { $str1Node = new String_('Str1'); $str2Node = new String_('Str2'); $str3Node = new String_('Str3'); @@ -147,7 +147,7 @@ public function testReturnArrayFromEnter() { ], $visitor2->trace); } - public function testMerge() { + public function testMerge(): void { $strStart = new String_('Start'); $strMiddle = new String_('End'); $strEnd = new String_('Middle'); @@ -167,7 +167,7 @@ public function testMerge() { ); } - public function testInvalidDeepArray() { + public function testInvalidDeepArray(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Invalid node structure: Contains nested arrays'); $strNode = new String_('Foo'); @@ -177,7 +177,7 @@ public function testInvalidDeepArray() { $this->assertEquals($stmts, $traverser->traverse($stmts)); } - public function testDontTraverseChildren() { + public function testDontTraverseChildren(): void { $strNode = new String_('str'); $printNode = new Expr\Print_($strNode); $varNode = new Expr\Variable('foo'); @@ -212,7 +212,7 @@ public function testDontTraverseChildren() { $this->assertEquals($expectedTrace, $visitor2->trace); } - public function testDontTraverseCurrentAndChildren() { + public function testDontTraverseCurrentAndChildren(): void { // print 'str'; -($foo * $foo); $strNode = new String_('str'); $printNode = new Expr\Print_($strNode); @@ -254,7 +254,7 @@ public function testDontTraverseCurrentAndChildren() { ], $visitor2->trace); } - public function testStopTraversal() { + public function testStopTraversal(): void { $varNode1 = new Expr\Variable('a'); $varNode2 = new Expr\Variable('b'); $varNode3 = new Expr\Variable('c'); @@ -343,7 +343,7 @@ public function testStopTraversal() { ], $visitor->trace); } - public function testReplaceWithNull() { + public function testReplaceWithNull(): void { $one = new Int_(1); $else1 = new Else_(); $else2 = new Else_(); @@ -381,7 +381,7 @@ public function testReplaceWithNull() { ], $visitor2->trace); } - public function testRemovingVisitor() { + public function testRemovingVisitor(): void { $visitor1 = new class () extends NodeVisitorAbstract {}; $visitor2 = new class () extends NodeVisitorAbstract {}; $visitor3 = new class () extends NodeVisitorAbstract {}; @@ -404,7 +404,7 @@ public function testRemovingVisitor() { $this->assertSame($postExpected, $getVisitors()); } - public function testNoCloneNodes() { + public function testNoCloneNodes(): void { $stmts = [new Node\Stmt\Echo_([new String_('Foo'), new String_('Bar')])]; $traverser = new NodeTraverser(); @@ -415,7 +415,7 @@ public function testNoCloneNodes() { /** * @dataProvider provideTestInvalidReturn */ - public function testInvalidReturn($stmts, $visitor, $message) { + public function testInvalidReturn($stmts, $visitor, $message): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage($message); diff --git a/test/PhpParser/NodeVisitor/FindingVisitorTest.php b/test/PhpParser/NodeVisitor/FindingVisitorTest.php index 4295249c9d..195074f1b0 100644 --- a/test/PhpParser/NodeVisitor/FindingVisitorTest.php +++ b/test/PhpParser/NodeVisitor/FindingVisitorTest.php @@ -7,7 +7,7 @@ use PhpParser\NodeTraverser; class FindingVisitorTest extends \PHPUnit\Framework\TestCase { - public function testFindVariables() { + public function testFindVariables(): void { $traverser = new NodeTraverser(); $visitor = new FindingVisitor(function (Node $node) { return $node instanceof Node\Expr\Variable; @@ -27,7 +27,7 @@ public function testFindVariables() { ], $visitor->getFoundNodes()); } - public function testFindAll() { + public function testFindAll(): void { $traverser = new NodeTraverser(); $visitor = new FindingVisitor(function (Node $node) { return true; // All nodes diff --git a/test/PhpParser/NodeVisitor/FirstFindingVisitorTest.php b/test/PhpParser/NodeVisitor/FirstFindingVisitorTest.php index b79e270f42..2163d9d470 100644 --- a/test/PhpParser/NodeVisitor/FirstFindingVisitorTest.php +++ b/test/PhpParser/NodeVisitor/FirstFindingVisitorTest.php @@ -7,7 +7,7 @@ use PhpParser\NodeTraverser; class FirstFindingVisitorTest extends \PHPUnit\Framework\TestCase { - public function testFindFirstVariable() { + public function testFindFirstVariable(): void { $traverser = new NodeTraverser(); $visitor = new FirstFindingVisitor(function (Node $node) { return $node instanceof Node\Expr\Variable; @@ -21,7 +21,7 @@ public function testFindFirstVariable() { $this->assertSame($assign->var, $visitor->getFoundNode()); } - public function testFindNone() { + public function testFindNone(): void { $traverser = new NodeTraverser(); $visitor = new FirstFindingVisitor(function (Node $node) { return $node instanceof Node\Expr\BinaryOp; diff --git a/test/PhpParser/NodeVisitor/NameResolverTest.php b/test/PhpParser/NodeVisitor/NameResolverTest.php index b0065968c7..449051fbf6 100644 --- a/test/PhpParser/NodeVisitor/NameResolverTest.php +++ b/test/PhpParser/NodeVisitor/NameResolverTest.php @@ -16,7 +16,7 @@ private function canonicalize($string) { /** * @covers \PhpParser\NodeVisitor\NameResolver */ - public function testResolveNames() { + public function testResolveNames(): void { $code = <<<'EOC' assertEquals($stmts, $traverser->traverse($stmts)); } - public function testAddDeclarationNamespacedName() { + public function testAddDeclarationNamespacedName(): void { $nsStmts = [ new Stmt\Class_('A'), new Stmt\Interface_('B'), @@ -372,7 +372,7 @@ public function testAddDeclarationNamespacedName() { $this->assertSame('F', (string) $stmts[0]->stmts[6]->namespacedName); } - public function testAddRuntimeResolvedNamespacedName() { + public function testAddRuntimeResolvedNamespacedName(): void { $stmts = [ new Stmt\Namespace_(new Name('NS'), [ new Expr\FuncCall(new Name('foo')), @@ -398,7 +398,7 @@ public function testAddRuntimeResolvedNamespacedName() { /** * @dataProvider provideTestError */ - public function testError(Node $stmt, $errorMsg) { + public function testError(Node $stmt, $errorMsg): void { $this->expectException(\PhpParser\Error::class); $this->expectExceptionMessage($errorMsg); @@ -449,7 +449,7 @@ public function provideTestError() { ]; } - public function testClassNameIsCaseInsensitive() { + public function testClassNameIsCaseInsensitive(): void { $source = <<<'EOC' assertSame('Bar\\Baz', $assign->expr->class->name); } - public function testSpecialClassNamesAreCaseInsensitive() { + public function testSpecialClassNamesAreCaseInsensitive(): void { $source = <<<'EOC' assertSame('STATIC', (string) $methodStmt->stmts[2]->expr->class); } - public function testAddOriginalNames() { + public function testAddOriginalNames(): void { $traverser = new PhpParser\NodeTraverser(); $traverser->addVisitor(new NameResolver(null, ['preserveOriginalNames' => true])); @@ -520,7 +520,7 @@ public function testAddOriginalNames() { $this->assertSame($n2, $stmts[0]->stmts[1]->name->getAttribute('originalName')); } - public function testAttributeOnlyMode() { + public function testAttributeOnlyMode(): void { $traverser = new PhpParser\NodeTraverser(); $traverser->addVisitor(new NameResolver(null, ['replaceNodes' => false])); diff --git a/test/PhpParser/NodeVisitor/NodeConnectingVisitorTest.php b/test/PhpParser/NodeVisitor/NodeConnectingVisitorTest.php index 3dcb2b45a4..eab58776cd 100644 --- a/test/PhpParser/NodeVisitor/NodeConnectingVisitorTest.php +++ b/test/PhpParser/NodeVisitor/NodeConnectingVisitorTest.php @@ -10,7 +10,7 @@ use PhpParser\ParserFactory; final class NodeConnectingVisitorTest extends \PHPUnit\Framework\TestCase { - public function testConnectsNodeToItsParentNodeAndItsSiblingNodes() { + public function testConnectsNodeToItsParentNodeAndItsSiblingNodes(): void { $ast = (new ParserFactory())->createForNewestSupportedVersion()->parse( 'createForNewestSupportedVersion()->parse( 'assertInstanceOf(Php8::class, $factory->createForNewestSupportedVersion()); $this->assertInstanceOf(Parser::class, $factory->createForHostVersion()); diff --git a/test/PhpParser/ParserTest.php b/test/PhpParser/ParserTest.php index 48f5ffe8e5..8096685901 100644 --- a/test/PhpParser/ParserTest.php +++ b/test/PhpParser/ParserTest.php @@ -11,28 +11,28 @@ abstract class ParserTest extends \PHPUnit\Framework\TestCase { /** @returns Parser */ abstract protected function getParser(Lexer $lexer); - public function testParserThrowsSyntaxError() { + public function testParserThrowsSyntaxError(): void { $this->expectException(Error::class); $this->expectExceptionMessage('Syntax error, unexpected EOF on line 1'); $parser = $this->getParser(new Lexer()); $parser->parse('expectException(Error::class); $this->expectExceptionMessage('Cannot use foo as self because \'self\' is a special class name on line 1'); $parser = $this->getParser(new Lexer()); $parser->parse('expectException(Error::class); $this->expectExceptionMessage('Unterminated comment on line 1'); $parser = $this->getParser(new Lexer()); $parser->parse('getAttributes()); } - public function testInvalidToken() { + public function testInvalidToken(): void { $this->expectException(\RangeException::class); $this->expectExceptionMessage('The lexer returned an invalid token (id=999, value=foobar)'); $lexer = new InvalidTokenLexer(); @@ -118,7 +118,7 @@ public function testInvalidToken() { /** * @dataProvider provideTestExtraAttributes */ - public function testExtraAttributes($code, $expectedAttributes) { + public function testExtraAttributes($code, $expectedAttributes): void { $parser = $this->getParser(new Lexer\Emulative()); $stmts = $parser->parse("expr : $stmts[0]; @@ -180,7 +180,7 @@ public function provideTestExtraAttributes() { ]; } - public function testListKindAttribute() { + public function testListKindAttribute(): void { $parser = $this->getParser(new Lexer\Emulative()); $stmts = $parser->parse('assertSame($stmts[0]->expr->var->getAttribute('kind'), Expr\List_::KIND_LIST); @@ -189,7 +189,7 @@ public function testListKindAttribute() { $this->assertSame($stmts[1]->expr->var->items[0]->value->getAttribute('kind'), Expr\List_::KIND_ARRAY); } - public function testGetTokens() { + public function testGetTokens(): void { $lexer = new Lexer(); $parser = $this->getParser($lexer); $parser->parse('assertSame(80200, $version->id); @@ -17,13 +17,13 @@ public function testConstruction() { $this->assertSame(80200, $version->id); } - public function testInvalidVersion() { + public function testInvalidVersion(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Invalid PHP version "8"'); PhpVersion::fromString('8'); } - public function testEquals() { + public function testEquals(): void { $php74 = PhpVersion::fromComponents(7, 4); $php81 = PhpVersion::fromComponents(8, 1); $php82 = PhpVersion::fromComponents(8, 2); diff --git a/test/PhpParser/PrettyPrinterTest.php b/test/PhpParser/PrettyPrinterTest.php index 9af5510ca7..a937d74978 100644 --- a/test/PhpParser/PrettyPrinterTest.php +++ b/test/PhpParser/PrettyPrinterTest.php @@ -29,14 +29,14 @@ protected function doTestPrettyPrintMethod($method, $name, $code, $expected, $mo /** * @dataProvider provideTestPrettyPrint */ - public function testPrettyPrint($name, $code, $expected, $mode) { + public function testPrettyPrint($name, $code, $expected, $mode): void { $this->doTestPrettyPrintMethod('prettyPrint', $name, $code, $expected, $mode); } /** * @dataProvider provideTestPrettyPrintFile */ - public function testPrettyPrintFile($name, $code, $expected, $mode) { + public function testPrettyPrintFile($name, $code, $expected, $mode): void { $this->doTestPrettyPrintMethod('prettyPrintFile', $name, $code, $expected, $mode); } @@ -48,7 +48,7 @@ public function provideTestPrettyPrintFile() { return $this->getTests(__DIR__ . '/../code/prettyPrinter', 'file-test'); } - public function testPrettyPrintExpr() { + public function testPrettyPrintExpr(): void { $prettyPrinter = new Standard(); $expr = new Expr\BinaryOp\Mul( new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b')), @@ -62,7 +62,7 @@ public function testPrettyPrintExpr() { $this->assertEquals("function () {\n return 'a\nb';\n}", $prettyPrinter->prettyPrintExpr($expr)); } - public function testCommentBeforeInlineHTML() { + public function testCommentBeforeInlineHTML(): void { $prettyPrinter = new PrettyPrinter\Standard(); $comment = new Comment\Doc("/**\n * This is a comment\n */"); $stmts = [new Stmt\InlineHTML('Hello World!', ['comments' => [$comment]])]; @@ -70,7 +70,7 @@ public function testCommentBeforeInlineHTML() { $this->assertSame($expected, $prettyPrinter->prettyPrintFile($stmts)); } - public function testArraySyntaxDefault() { + public function testArraySyntaxDefault(): void { $prettyPrinter = new Standard(['shortArraySyntax' => true]); $expr = new Expr\Array_([ new Node\ArrayItem(new String_('val'), new String_('key')) @@ -82,7 +82,7 @@ public function testArraySyntaxDefault() { /** * @dataProvider provideTestKindAttributes */ - public function testKindAttributes($node, $expected) { + public function testKindAttributes($node, $expected): void { $prttyPrinter = new PrettyPrinter\Standard(); $result = $prttyPrinter->prettyPrintExpr($node); $this->assertSame($expected, $result); @@ -138,7 +138,7 @@ public function provideTestKindAttributes() { } /** @dataProvider provideTestUnnaturalLiterals */ - public function testUnnaturalLiterals($node, $expected) { + public function testUnnaturalLiterals($node, $expected): void { $prttyPrinter = new PrettyPrinter\Standard(); $result = $prttyPrinter->prettyPrintExpr($node); $this->assertSame($expected, $result); @@ -157,7 +157,7 @@ public function provideTestUnnaturalLiterals() { ]; } - public function testPrettyPrintWithError() { + public function testPrettyPrintWithError(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot pretty-print AST with Error nodes'); $stmts = [new Stmt\Expression( @@ -167,7 +167,7 @@ public function testPrettyPrintWithError() { $prettyPrinter->prettyPrint($stmts); } - public function testPrettyPrintWithErrorInClassConstFetch() { + public function testPrettyPrintWithErrorInClassConstFetch(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Cannot pretty-print AST with Error nodes'); $stmts = [new Stmt\Expression( @@ -180,7 +180,7 @@ public function testPrettyPrintWithErrorInClassConstFetch() { /** * @dataProvider provideTestFormatPreservingPrint */ - public function testFormatPreservingPrint($name, $code, $modification, $expected, $modeLine) { + public function testFormatPreservingPrint($name, $code, $modification, $expected, $modeLine): void { $lexer = new Lexer\Emulative(); $parser = new Parser\Php7($lexer); $traverser = new NodeTraverser(new NodeVisitor\CloningVisitor()); @@ -216,7 +216,7 @@ public function provideTestFormatPreservingPrint() { /** * @dataProvider provideTestRoundTripPrint */ - public function testRoundTripPrint($name, $code, $expected, $modeLine) { + public function testRoundTripPrint($name, $code, $expected, $modeLine): void { /** * This test makes sure that the format-preserving pretty printer round-trips for all * the pretty printer tests (i.e. returns the input if no changes occurred). @@ -252,7 +252,7 @@ public function provideTestRoundTripPrint() { ); } - public function testWindowsNewline() { + public function testWindowsNewline(): void { $prettyPrinter = new Standard([ 'newline' => "\r\n", 'phpVersion' => PhpVersion::fromComponents(7, 2), @@ -294,7 +294,7 @@ public function testWindowsNewline() { $code); } - public function testInvalidNewline() { + public function testInvalidNewline(): void { $this->expectException(\LogicException::class); $this->expectExceptionMessage('Option "newline" must be one of "\n" or "\r\n"'); new PrettyPrinter\Standard(['newline' => 'foo']); diff --git a/test/PhpParser/TokenTest.php b/test/PhpParser/TokenTest.php index 30787e686d..8297699c6e 100644 --- a/test/PhpParser/TokenTest.php +++ b/test/PhpParser/TokenTest.php @@ -3,14 +3,14 @@ namespace PhpParser; class TokenTest extends \PHPUnit\Framework\TestCase { - public function testGetTokenName() { + public function testGetTokenName(): void { $token = new Token(\ord(','), ','); $this->assertSame(',', $token->getTokenName()); $token = new Token(\T_WHITESPACE, ' '); $this->assertSame('T_WHITESPACE', $token->getTokenName()); } - public function testIs() { + public function testIs(): void { $token = new Token(\ord(','), ','); $this->assertTrue($token->is(\ord(','))); $this->assertFalse($token->is(\ord(';'))); @@ -23,7 +23,7 @@ public function testIs() { } /** @dataProvider provideTestIsIgnorable */ - public function testIsIgnorable(int $id, string $text, bool $isIgnorable) { + public function testIsIgnorable(int $id, string $text, bool $isIgnorable): void { $token = new Token($id, $text); $this->assertSame($isIgnorable, $token->isIgnorable()); } @@ -38,7 +38,7 @@ public function provideTestIsIgnorable() { ]; } - public function testToString() { + public function testToString(): void { $token = new Token(\ord(','), ','); $this->assertSame(',', (string) $token); $token = new Token(\T_STRING, 'foo'); diff --git a/tools/fuzzing/target.php b/tools/fuzzing/target.php index 6a7b3ebc27..8cbd619c16 100644 --- a/tools/fuzzing/target.php +++ b/tools/fuzzing/target.php @@ -39,11 +39,11 @@ private $tokens; public $hasProblematicConstruct; - public function setTokens(array $tokens) { + public function setTokens(array $tokens): void { $this->tokens = $tokens; } - public function beforeTraverse(array $nodes) { + public function beforeTraverse(array $nodes): void { $this->hasProblematicConstruct = false; }