From a2fbebaf44cfb8c40e917b85f60815bbc0915954 Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 12 Sep 2022 17:03:00 +0100 Subject: [PATCH] General psalm baseline reduction Signed-off-by: George Steel --- psalm-baseline.xml | 2 - test/BetweenTest.php | 25 +++------ test/CallbackTest.php | 4 +- test/CreditCardTest.php | 28 +++------- test/Db/NoRecordExistsTest.php | 36 ++++--------- test/Db/RecordExistsTest.php | 32 +++-------- test/DigitsTest.php | 17 ++---- test/EmailAddressTest.php | 68 ++++++------------------ test/File/CountTest.php | 16 ++---- test/File/Crc32Test.php | 12 ++--- test/File/ExcludeExtensionTest.php | 12 ++--- test/File/ExcludeMimeTypeTest.php | 12 ++--- test/File/ExistsTest.php | 12 ++--- test/File/ExtensionTest.php | 12 ++--- test/File/FilesSizeTest.php | 20 ++----- test/File/HashTest.php | 12 ++--- test/File/ImageSizeTest.php | 32 +++-------- test/File/IsCompressedTest.php | 12 ++--- test/File/IsImageTest.php | 12 ++--- test/File/Md5Test.php | 12 ++--- test/File/MimeTypeTest.php | 12 ++--- test/File/NotExistsTest.php | 12 ++--- test/File/Sha1Test.php | 12 ++--- test/File/SizeTest.php | 20 ++----- test/File/UploadFileTest.php | 5 +- test/File/UploadTest.php | 12 ++--- test/File/WordCountTest.php | 16 ++---- test/GreaterThanTest.php | 15 ++---- test/HexTest.php | 7 +-- test/HostnameTest.php | 14 ++--- test/InArrayTest.php | 12 ++--- test/IpTest.php | 8 +-- test/IsInstanceOfTest.php | 12 ++--- test/IsbnTest.php | 16 ++---- test/LessThanTest.php | 15 ++---- test/MessageTest.php | 40 ++++---------- test/NotEmptyTest.php | 85 +++++++++--------------------- test/RegexTest.php | 15 ++---- test/StaticValidatorTest.php | 3 +- test/StepTest.php | 4 +- test/StringLengthTest.php | 28 +++------- test/TimezoneTest.php | 4 +- test/UriTest.php | 4 +- test/ValidatorChainTest.php | 16 ++---- 44 files changed, 200 insertions(+), 575 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index b81d85979..82821b332 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2083,11 +2083,9 @@ 1 - $value - $args diff --git a/test/BetweenTest.php b/test/BetweenTest.php index 64300cd62..d6cc6f248 100644 --- a/test/BetweenTest.php +++ b/test/BetweenTest.php @@ -19,8 +19,8 @@ class BetweenTest extends TestCase { /** * @psalm-return array $min, 'max' => $max, 'inclusive' => $inclusive]); @@ -203,10 +200,8 @@ public function testBasic($min, $max, $inclusive, $expected, $value) /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $validator = new Between(['min' => 1, 'max' => 10]); $this->assertEquals([], $validator->getMessages()); @@ -214,10 +209,8 @@ public function testGetMessages() /** * Ensures that getMin() returns expected value - * - * @return void */ - public function testGetMin() + public function testGetMin(): void { $validator = new Between(['min' => 1, 'max' => 10]); $this->assertEquals(1, $validator->getMin()); @@ -225,10 +218,8 @@ public function testGetMin() /** * Ensures that getMax() returns expected value - * - * @return void */ - public function testGetMax() + public function testGetMax(): void { $validator = new Between(['min' => 1, 'max' => 10]); $this->assertEquals(10, $validator->getMax()); @@ -236,10 +227,8 @@ public function testGetMax() /** * Ensures that getInclusive() returns expected default value - * - * @return void */ - public function testGetInclusive() + public function testGetInclusive(): void { $validator = new Between(['min' => 1, 'max' => 10]); $this->assertEquals(true, $validator->getInclusive()); diff --git a/test/CallbackTest.php b/test/CallbackTest.php index 639d6e86a..c0e78f00d 100644 --- a/test/CallbackTest.php +++ b/test/CallbackTest.php @@ -19,10 +19,8 @@ class CallbackTest extends TestCase { /** * Ensures that the validator follows expected behavior - * - * @return void */ - public function testBasic() + public function testBasic(): void { $valid = new Callback([$this, 'objectCallback']); $this->assertTrue($valid->isValid('test')); diff --git a/test/CreditCardTest.php b/test/CreditCardTest.php index 31576d68a..3b56b1423 100644 --- a/test/CreditCardTest.php +++ b/test/CreditCardTest.php @@ -44,10 +44,8 @@ public function testBasic(string $input, bool $expected): void /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $validator = new CreditCard(); $this->assertEquals([], $validator->getMessages()); @@ -55,10 +53,8 @@ public function testGetMessages() /** * Ensures that get and setType works as expected - * - * @return void */ - public function testGetSetType() + public function testGetSetType(): void { $validator = new CreditCard(); $this->assertCount(12, $validator->getType()); @@ -120,10 +116,8 @@ public function testProvider(string $input, bool $expected): void /** * Test non string input - * - * @return void */ - public function testIsValidWithNonString() + public function testIsValidWithNonString(): void { $validator = new CreditCard(CreditCard::VISA); $this->assertFalse($validator->isValid(['something'])); @@ -300,10 +294,8 @@ public function testMirCard($input, $expected): void /** * Test an invalid service class - * - * @return void */ - public function testInvalidServiceClass() + public function testInvalidServiceClass(): void { $validator = new CreditCard(); $this->assertEquals(null, $validator->getService()); @@ -315,10 +307,8 @@ public function testInvalidServiceClass() /** * Test a config object - * - * @return void */ - public function testTraversableObject() + public function testTraversableObject(): void { $options = ['type' => 'Visa']; $config = new ArrayObject($options); @@ -329,10 +319,8 @@ public function testTraversableObject() /** * Test optional parameters with config object - * - * @return void */ - public function testOptionalConstructorParameterByTraversableObject() + public function testOptionalConstructorParameterByTraversableObject(): void { $config = new ArrayObject( ['type' => 'Visa', 'service' => [self::class, 'staticCallback']] @@ -345,10 +333,8 @@ public function testOptionalConstructorParameterByTraversableObject() /** * Test optional constructor parameters - * - * @return void */ - public function testOptionalConstructorParameter() + public function testOptionalConstructorParameter(): void { $validator = new CreditCard('Visa', [self::class, 'staticCallback']); $this->assertEquals(['Visa'], $validator->getType()); diff --git a/test/Db/NoRecordExistsTest.php b/test/Db/NoRecordExistsTest.php index 8dde9ae29..2e4861495 100644 --- a/test/Db/NoRecordExistsTest.php +++ b/test/Db/NoRecordExistsTest.php @@ -105,10 +105,8 @@ protected function getMockNoResult() /** * Test basic function of RecordExists (no exclusion) - * - * @return void */ - public function testBasicFindsRecord() + public function testBasicFindsRecord(): void { $validator = new NoRecordExists('users', 'field1', null, $this->getMockHasResult()); $this->assertFalse($validator->isValid('value1')); @@ -116,10 +114,8 @@ public function testBasicFindsRecord() /** * Test basic function of RecordExists (no exclusion) - * - * @return void */ - public function testBasicFindsNoRecord() + public function testBasicFindsNoRecord(): void { $validator = new NoRecordExists('users', 'field1', null, $this->getMockNoResult()); $this->assertTrue($validator->isValid('nosuchvalue')); @@ -127,10 +123,8 @@ public function testBasicFindsNoRecord() /** * Test the exclusion function - * - * @return void */ - public function testExcludeWithArray() + public function testExcludeWithArray(): void { $validator = new NoRecordExists( 'users', @@ -144,10 +138,8 @@ public function testExcludeWithArray() /** * Test the exclusion function * with an array - * - * @return void */ - public function testExcludeWithArrayNoRecord() + public function testExcludeWithArrayNoRecord(): void { $validator = new NoRecordExists( 'users', @@ -161,10 +153,8 @@ public function testExcludeWithArrayNoRecord() /** * Test the exclusion function * with a string - * - * @return void */ - public function testExcludeWithString() + public function testExcludeWithString(): void { $validator = new NoRecordExists('users', 'field1', 'id != 1', $this->getMockHasResult()); $this->assertFalse($validator->isValid('value3')); @@ -173,10 +163,8 @@ public function testExcludeWithString() /** * Test the exclusion function * with a string - * - * @return void */ - public function testExcludeWithStringNoRecord() + public function testExcludeWithStringNoRecord(): void { $validator = new NoRecordExists('users', 'field1', 'id != 1', $this->getMockNoResult()); $this->assertTrue($validator->isValid('nosuchvalue')); @@ -185,10 +173,8 @@ public function testExcludeWithStringNoRecord() /** * Test that the class throws an exception if no adapter is provided * and no default is set. - * - * @return void */ - public function testThrowsExceptionWithNoAdapter() + public function testThrowsExceptionWithNoAdapter(): void { $validator = new NoRecordExists('users', 'field1', 'id != 1'); $this->expectException(RuntimeException::class); @@ -198,10 +184,8 @@ public function testThrowsExceptionWithNoAdapter() /** * Test that schemas are supported and run without error - * - * @return void */ - public function testWithSchema() + public function testWithSchema(): void { $validator = new NoRecordExists([ 'table' => 'users', @@ -212,10 +196,8 @@ public function testWithSchema() /** * Test that schemas are supported and run without error - * - * @return void */ - public function testWithSchemaNoResult() + public function testWithSchemaNoResult(): void { $validator = new NoRecordExists([ 'table' => 'users', diff --git a/test/Db/RecordExistsTest.php b/test/Db/RecordExistsTest.php index 6511d7cc7..c0d60e1b4 100644 --- a/test/Db/RecordExistsTest.php +++ b/test/Db/RecordExistsTest.php @@ -109,10 +109,8 @@ protected function getMockNoResult() /** * Test basic function of RecordExists (no exclusion) - * - * @return void */ - public function testBasicFindsRecord() + public function testBasicFindsRecord(): void { $validator = new RecordExists([ 'table' => 'users', @@ -124,10 +122,8 @@ public function testBasicFindsRecord() /** * Test basic function of RecordExists (no exclusion) - * - * @return void */ - public function testBasicFindsNoRecord() + public function testBasicFindsNoRecord(): void { $validator = new RecordExists([ 'table' => 'users', @@ -139,10 +135,8 @@ public function testBasicFindsNoRecord() /** * Test the exclusion function - * - * @return void */ - public function testExcludeWithArray() + public function testExcludeWithArray(): void { $validator = new RecordExists([ 'table' => 'users', @@ -159,10 +153,8 @@ public function testExcludeWithArray() /** * Test the exclusion function * with an array - * - * @return void */ - public function testExcludeWithArrayNoRecord() + public function testExcludeWithArrayNoRecord(): void { $validator = new RecordExists([ 'table' => 'users', @@ -179,10 +171,8 @@ public function testExcludeWithArrayNoRecord() /** * Test the exclusion function * with a string - * - * @return void */ - public function testExcludeWithString() + public function testExcludeWithString(): void { $validator = new RecordExists([ 'table' => 'users', @@ -196,10 +186,8 @@ public function testExcludeWithString() /** * Test the exclusion function * with a string - * - * @return void */ - public function testExcludeWithStringNoRecord() + public function testExcludeWithStringNoRecord(): void { $validator = new RecordExists('users', 'field1', 'id != 1', $this->getMockNoResult()); $this->assertFalse($validator->isValid('nosuchvalue')); @@ -217,10 +205,8 @@ public function testExcludeConstructor(): void /** * Test that the class throws an exception if no adapter is provided * and no default is set. - * - * @return void */ - public function testThrowsExceptionWithNoAdapter() + public function testThrowsExceptionWithNoAdapter(): void { $validator = new RecordExists('users', 'field1', 'id != 1'); $this->expectException(RuntimeException::class); @@ -230,10 +216,8 @@ public function testThrowsExceptionWithNoAdapter() /** * Test that schemas are supported and run without error - * - * @return void */ - public function testWithSchema() + public function testWithSchema(): void { $validator = new RecordExists([ 'table' => 'users', diff --git a/test/DigitsTest.php b/test/DigitsTest.php index abc075093..445d60cbb 100644 --- a/test/DigitsTest.php +++ b/test/DigitsTest.php @@ -26,9 +26,8 @@ protected function setUp(): void * Ensures that the validator follows expected behavior for basic input values * * @dataProvider basicDataProvider - * @return void */ - public function testExpectedResultsWithBasicInputValues(string $input, bool $expected) + public function testExpectedResultsWithBasicInputValues(string $input, bool $expected): void { $this->assertSame($expected, $this->validator->isValid($input)); } @@ -56,18 +55,13 @@ public function basicDataProvider(): array /** * Ensures that getMessages() returns expected initial value - * - * @return void */ - public function testMessagesEmptyInitially() + public function testMessagesEmptyInitially(): void { $this->assertEquals([], $this->validator->getMessages()); } - /** - * @return void - */ - public function testEmptyStringValueResultsInProperValidationFailureMessages() + public function testEmptyStringValueResultsInProperValidationFailureMessages(): void { $this->assertFalse($this->validator->isValid('')); $messages = $this->validator->getMessages(); @@ -77,10 +71,7 @@ public function testEmptyStringValueResultsInProperValidationFailureMessages() $this->assertSame($arrayExpected, $messages); } - /** - * @return void - */ - public function testInvalidValueResultsInProperValidationFailureMessages() + public function testInvalidValueResultsInProperValidationFailureMessages(): void { $this->assertFalse($this->validator->isValid('#')); $messages = $this->validator->getMessages(); diff --git a/test/EmailAddressTest.php b/test/EmailAddressTest.php index 5a48f23dd..db7d6f178 100644 --- a/test/EmailAddressTest.php +++ b/test/EmailAddressTest.php @@ -45,20 +45,16 @@ protected function setUp(): void /** * Ensures that a basic valid e-mail address passes validation - * - * @return void */ - public function testBasic() + public function testBasic(): void { $this->assertTrue($this->validator->isValid('username@example.com')); } /** * Ensures that localhost address is valid - * - * @return void */ - public function testLocalhostAllowed() + public function testLocalhostAllowed(): void { $validator = new EmailAddress(Hostname::ALLOW_ALL); $this->assertTrue($validator->isValid('username@localhost')); @@ -66,10 +62,8 @@ public function testLocalhostAllowed() /** * Ensures that local domain names are valid - * - * @return void */ - public function testLocaldomainAllowed() + public function testLocalDomainAllowed(): void { $validator = new EmailAddress(Hostname::ALLOW_ALL); $this->assertTrue($validator->isValid('username@localhost.localdomain')); @@ -77,10 +71,8 @@ public function testLocaldomainAllowed() /** * Ensures that IP hostnames are valid - * - * @return void */ - public function testIPAllowed() + public function testIPAllowed(): void { $validator = new EmailAddress(Hostname::ALLOW_DNS | Hostname::ALLOW_IP); $valuesExpected = [ @@ -96,10 +88,8 @@ public function testIPAllowed() /** * Ensures that validation fails when the local part is missing - * - * @return void */ - public function testLocalPartMissing() + public function testLocalPartMissing(): void { $this->assertFalse($this->validator->isValid('@example.com')); $messages = $this->validator->getMessages(); @@ -109,10 +99,8 @@ public function testLocalPartMissing() /** * Ensures that validation fails and produces the expected messages when the local part is invalid - * - * @return void */ - public function testLocalPartInvalid() + public function testLocalPartInvalid(): void { $this->assertFalse($this->validator->isValid('Some User@example.com')); @@ -132,10 +120,8 @@ public function testLocalPartInvalid() /** * Ensures that no validation failure message is produced when the local part follows the quoted-string format - * - * @return void */ - public function testLocalPartQuotedString() + public function testLocalPartQuotedString(): void { $this->assertTrue($this->validator->isValid('"Some User"@example.com')); @@ -147,10 +133,8 @@ public function testLocalPartQuotedString() /** * Ensures that validation fails when the hostname is invalid - * - * @return void */ - public function testHostnameInvalid() + public function testHostnameInvalid(): void { $this->assertFalse($this->validator->isValid('username@ example . com')); $messages = $this->validator->getMessages(); @@ -160,10 +144,8 @@ public function testHostnameInvalid() /** * Ensures that quoted-string local part is considered valid - * - * @return void */ - public function testQuotedString() + public function testQuotedString(): void { $emailAddresses = [ '""@domain.com', // Optional @@ -195,10 +177,8 @@ public function testQuotedString() /** * Ensures that quoted-string local part is considered invalid - * - * @return void */ - public function testInvalidQuotedString() + public function testInvalidQuotedString(): void { $emailAddresses = [ "\"\x00\"@example.com", @@ -219,10 +199,8 @@ public function testInvalidQuotedString() /** * Ensures that validation fails when the e-mail is given as for display, * with angle brackets around the actual address - * - * @return void */ - public function testEmailDisplay() + public function testEmailDisplay(): void { $this->assertFalse($this->validator->isValid('User Name ')); $messages = $this->validator->getMessages(); @@ -319,10 +297,8 @@ public function testBasicInvalid(string $value): void /** * Ensures that the validator follows expected behavior for valid email addresses with complex local parts - * - * @return void */ - public function testComplexLocalValid() + public function testComplexLocalValid(): void { $emailAddresses = [ 'Bob.Jones@domain.com', @@ -341,10 +317,8 @@ public function testComplexLocalValid() /** * Ensures that the validator follows expected behavior for valid email addresses with the non-strict option - * - * @return void */ - public function testNonStrict() + public function testNonStrict(): void { $validator = new EmailAddress(['strict' => false]); $emailAddresses = [ @@ -365,10 +339,8 @@ public function testNonStrict() /** * Ensures that the validator follows expected behavior for checking MX records - * - * @return void */ - public function testMXRecords() + public function testMXRecords(): void { $this->skipIfOnlineTestsDisabled(); @@ -406,10 +378,8 @@ public function testMXRecords() * This behavior is documented in RFC 2821, section 5: "If no MX records are found, but an A RR is * found, the A RR is treated as if it was associated with an implicit MX RR, with a preference of 0, * pointing to that host. - * - * @return void */ - public function testNoMxRecordARecordFallback() + public function testNoMxRecordARecordFallback(): void { $this->skipIfOnlineTestsDisabled(); @@ -435,10 +405,8 @@ public function testNoMxRecordARecordFallback() /** * Test changing hostname settings via EmailAddress object - * - * @return void */ - public function testHostnameSettings() + public function testHostnameSettings(): void { $validator = new EmailAddress(); @@ -469,10 +437,8 @@ public function testHostnameSettings() /** * Ensures that getMessages() returns expected default value (an empty array) - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $this->assertEquals([], $this->validator->getMessages()); } diff --git a/test/File/CountTest.php b/test/File/CountTest.php index 06a370e65..a43b19fe9 100644 --- a/test/File/CountTest.php +++ b/test/File/CountTest.php @@ -66,10 +66,8 @@ public function basicDataProvider(): array /** * Ensures that getMin() returns expected value - * - * @return void */ - public function testGetMin() + public function testGetMin(): void { $validator = new File\Count(['min' => 1, 'max' => 5]); $this->assertEquals(1, $validator->getMin()); @@ -84,10 +82,8 @@ public function testGetMinGreaterThanOrEqualThrowsException(): void /** * Ensures that setMin() returns expected value - * - * @return void */ - public function testSetMin() + public function testSetMin(): void { $validator = new File\Count(['min' => 1000, 'max' => 10000]); $validator->setMin(100); @@ -100,10 +96,8 @@ public function testSetMin() /** * Ensures that getMax() returns expected value - * - * @return void */ - public function testGetMax() + public function testGetMax(): void { $validator = new File\Count(['min' => 1, 'max' => 100]); $this->assertEquals(100, $validator->getMax()); @@ -115,10 +109,8 @@ public function testGetMax() /** * Ensures that setMax() returns expected value - * - * @return void */ - public function testSetMax() + public function testSetMax(): void { $validator = new File\Count(['min' => 1000, 'max' => 10000]); $validator->setMax(1_000_000); diff --git a/test/File/Crc32Test.php b/test/File/Crc32Test.php index 84be96385..1571462cd 100644 --- a/test/File/Crc32Test.php +++ b/test/File/Crc32Test.php @@ -125,10 +125,8 @@ public function testgetCrc32() /** * Ensures that getHash() returns expected value - * - * @return void */ - public function testgetHash() + public function testgetHash(): void { $validator = new File\Crc32('12345'); $this->assertEquals(['12345' => 'crc32'], $validator->getHash()); @@ -154,10 +152,8 @@ public function testSetCrc32() /** * Ensures that setHash() returns expected value - * - * @return void */ - public function testSetHash() + public function testSetHash(): void { $validator = new File\Crc32('12345'); $validator->setHash('12333'); @@ -187,10 +183,8 @@ public function testAddCrc32() /** * Ensures that addHash() returns expected value - * - * @return void */ - public function testAddHash() + public function testAddHash(): void { $validator = new File\Crc32('12345'); $validator->addHash('12344'); diff --git a/test/File/ExcludeExtensionTest.php b/test/File/ExcludeExtensionTest.php index 16d751fcb..c7d7435b9 100644 --- a/test/File/ExcludeExtensionTest.php +++ b/test/File/ExcludeExtensionTest.php @@ -123,10 +123,8 @@ public function testCaseTesting(): void /** * Ensures that getExtension() returns expected value - * - * @return void */ - public function testGetExtension() + public function testGetExtension(): void { $validator = new File\ExcludeExtension('mo'); $this->assertEquals(['mo'], $validator->getExtension()); @@ -137,10 +135,8 @@ public function testGetExtension() /** * Ensures that setExtension() returns expected value - * - * @return void */ - public function testSetExtension() + public function testSetExtension(): void { $validator = new File\ExcludeExtension('mo'); $validator->setExtension('gif'); @@ -155,10 +151,8 @@ public function testSetExtension() /** * Ensures that addExtension() returns expected value - * - * @return void */ - public function testAddExtension() + public function testAddExtension(): void { $validator = new File\ExcludeExtension('mo'); $validator->addExtension('gif'); diff --git a/test/File/ExcludeMimeTypeTest.php b/test/File/ExcludeMimeTypeTest.php index 31c5c1268..86b18c5d0 100644 --- a/test/File/ExcludeMimeTypeTest.php +++ b/test/File/ExcludeMimeTypeTest.php @@ -92,10 +92,8 @@ public function testLegacy($options, $isValidParam, bool $expected): void /** * Ensures that getMimeType() returns expected value - * - * @return void */ - public function testGetMimeType() + public function testGetMimeType(): void { $validator = new ExcludeMimeType('image/gif'); $this->assertEquals('image/gif', $validator->getMimeType()); @@ -109,10 +107,8 @@ public function testGetMimeType() /** * Ensures that setMimeType() returns expected value - * - * @return void */ - public function testSetMimeType() + public function testSetMimeType(): void { $validator = new ExcludeMimeType('image/gif'); $validator->setMimeType('image/jpeg'); @@ -130,10 +126,8 @@ public function testSetMimeType() /** * Ensures that addMimeType() returns expected value - * - * @return void */ - public function testAddMimeType() + public function testAddMimeType(): void { $validator = new ExcludeMimeType('image/gif'); $validator->addMimeType('text'); diff --git a/test/File/ExistsTest.php b/test/File/ExistsTest.php index f416bdfc1..9fb302944 100644 --- a/test/File/ExistsTest.php +++ b/test/File/ExistsTest.php @@ -85,10 +85,8 @@ public function testLegacy(string $options, $isValidParam, bool $expected): void /** * Ensures that getDirectory() returns expected value - * - * @return void */ - public function testGetDirectory() + public function testGetDirectory(): void { $validator = new File\Exists('C:/temp'); $this->assertEquals('C:/temp', $validator->getDirectory()); @@ -102,10 +100,8 @@ public function testGetDirectory() /** * Ensures that setDirectory() returns expected value - * - * @return void */ - public function testSetDirectory() + public function testSetDirectory(): void { $validator = new File\Exists('temp'); $validator->setDirectory('gif'); @@ -123,10 +119,8 @@ public function testSetDirectory() /** * Ensures that addDirectory() returns expected value - * - * @return void */ - public function testAddDirectory() + public function testAddDirectory(): void { $validator = new File\Exists('temp'); $validator->addDirectory('gif'); diff --git a/test/File/ExtensionTest.php b/test/File/ExtensionTest.php index 5dd969f11..67abed414 100644 --- a/test/File/ExtensionTest.php +++ b/test/File/ExtensionTest.php @@ -127,10 +127,8 @@ public function testLaminas891() /** * Ensures that getExtension() returns expected value - * - * @return void */ - public function testGetExtension() + public function testGetExtension(): void { $validator = new File\Extension('mo'); $this->assertEquals(['mo'], $validator->getExtension()); @@ -141,10 +139,8 @@ public function testGetExtension() /** * Ensures that setExtension() returns expected value - * - * @return void */ - public function testSetExtension() + public function testSetExtension(): void { $validator = new File\Extension('mo'); $validator->setExtension('gif'); @@ -159,10 +155,8 @@ public function testSetExtension() /** * Ensures that addExtension() returns expected value - * - * @return void */ - public function testAddExtension() + public function testAddExtension(): void { $validator = new File\Extension('mo'); $validator->addExtension('gif'); diff --git a/test/File/FilesSizeTest.php b/test/File/FilesSizeTest.php index 3b12d36dc..77fb0cc06 100644 --- a/test/File/FilesSizeTest.php +++ b/test/File/FilesSizeTest.php @@ -98,10 +98,8 @@ public function testFileDoNotExist(): void /** * Ensures that getMin() returns expected value - * - * @return void */ - public function testGetMin() + public function testGetMin(): void { $validator = new File\FilesSize(['min' => 1, 'max' => 100]); $this->assertEquals('1B', $validator->getMin()); @@ -116,10 +114,8 @@ public function testGetMin() /** * Ensures that setMin() returns expected value - * - * @return void */ - public function testSetMin() + public function testSetMin(): void { $validator = new File\FilesSize(['min' => 1000, 'max' => 10000]); $validator->setMin(100); @@ -132,10 +128,8 @@ public function testSetMin() /** * Ensures that getMax() returns expected value - * - * @return void */ - public function testGetMax() + public function testGetMax(): void { $validator = new File\FilesSize(['min' => 1, 'max' => 100]); $this->assertEquals('100B', $validator->getMax()); @@ -155,10 +149,8 @@ public function testGetMax() /** * Ensures that setMax() returns expected value - * - * @return void */ - public function testSetMax() + public function testSetMax(): void { $validator = new File\FilesSize(['min' => 1000, 'max' => 10000]); $validator->setMax(1_000_000); @@ -177,10 +169,8 @@ public function testConstructorShouldRaiseErrorWhenPassedMultipleOptions(): void /** * Ensures that the validator returns size infos - * - * @return void */ - public function testFailureMessage() + public function testFailureMessage(): void { $validator = new File\FilesSize(['min' => 9999, 'max' => 10000]); $this->assertFalse($validator->isValid([ diff --git a/test/File/HashTest.php b/test/File/HashTest.php index 41329d79d..524fbf947 100644 --- a/test/File/HashTest.php +++ b/test/File/HashTest.php @@ -139,10 +139,8 @@ public function testLegacy($options, $isValidParam, bool $expected, string $mess /** * Ensures that getHash() returns expected value - * - * @return void */ - public function testgetHash() + public function testgetHash(): void { $validator = new File\Hash('12345'); $this->assertEquals(['12345' => 'crc32'], $validator->getHash()); @@ -153,10 +151,8 @@ public function testgetHash() /** * Ensures that setHash() returns expected value - * - * @return void */ - public function testSetHash() + public function testSetHash(): void { $validator = new File\Hash('12345'); $validator->setHash('12333'); @@ -168,10 +164,8 @@ public function testSetHash() /** * Ensures that addHash() returns expected value - * - * @return void */ - public function testAddHash() + public function testAddHash(): void { $validator = new File\Hash('12345'); $validator->addHash('12344'); diff --git a/test/File/ImageSizeTest.php b/test/File/ImageSizeTest.php index 3f2a8718e..6e46eab3f 100644 --- a/test/File/ImageSizeTest.php +++ b/test/File/ImageSizeTest.php @@ -174,10 +174,8 @@ public function testLegacy(array $options, $isValidParam, bool $expected, $messa /** * Ensures that getImageMin() returns expected value - * - * @return void */ - public function testGetImageMin() + public function testGetImageMin(): void { $validator = new File\ImageSize(['minWidth' => 1, 'minHeight' => 10, 'maxWidth' => 100, 'maxHeight' => 1000]); $this->assertEquals(['minWidth' => 1, 'minHeight' => 10], $validator->getImageMin()); @@ -189,10 +187,8 @@ public function testGetImageMin() /** * Ensures that setImageMin() returns expected value - * - * @return void */ - public function testSetImageMin() + public function testSetImageMin(): void { $validator = new File\ImageSize([ 'minWidth' => 100, @@ -213,10 +209,8 @@ public function testSetImageMin() /** * Ensures that getImageMax() returns expected value - * - * @return void */ - public function testGetImageMax() + public function testGetImageMax(): void { $validator = new File\ImageSize([ 'minWidth' => 10, @@ -238,10 +232,8 @@ public function testGetImageMax() /** * Ensures that setImageMax() returns expected value - * - * @return void */ - public function testSetImageMax() + public function testSetImageMax(): void { $validator = new File\ImageSize([ 'minWidth' => 10, @@ -268,10 +260,8 @@ public function testSetImageMax() /** * Ensures that getImageWidth() returns expected value - * - * @return void */ - public function testGetImageWidth() + public function testGetImageWidth(): void { $validator = new File\ImageSize(['minWidth' => 1, 'minHeight' => 10, 'maxWidth' => 100, 'maxHeight' => 1000]); $this->assertEquals(['minWidth' => 1, 'maxWidth' => 100], $validator->getImageWidth()); @@ -279,10 +269,8 @@ public function testGetImageWidth() /** * Ensures that setImageWidth() returns expected value - * - * @return void */ - public function testSetImageWidth() + public function testSetImageWidth(): void { $validator = new File\ImageSize([ 'minWidth' => 100, @@ -300,10 +288,8 @@ public function testSetImageWidth() /** * Ensures that getImageHeight() returns expected value - * - * @return void */ - public function testGetImageHeight() + public function testGetImageHeight(): void { $validator = new File\ImageSize(['minWidth' => 1, 'minHeight' => 10, 'maxWidth' => 100, 'maxHeight' => 1000]); $this->assertEquals(['minHeight' => 10, 'maxHeight' => 1000], $validator->getImageHeight()); @@ -311,10 +297,8 @@ public function testGetImageHeight() /** * Ensures that setImageHeight() returns expected value - * - * @return void */ - public function testSetImageHeight() + public function testSetImageHeight(): void { $validator = new File\ImageSize([ 'minWidth' => 100, diff --git a/test/File/IsCompressedTest.php b/test/File/IsCompressedTest.php index e7ea4a9df..3d90751d0 100644 --- a/test/File/IsCompressedTest.php +++ b/test/File/IsCompressedTest.php @@ -149,10 +149,8 @@ public function testLegacy($options, $isValidParam, bool $expected): void /** * Ensures that getMimeType() returns expected value - * - * @return void */ - public function testGetMimeType() + public function testGetMimeType(): void { $validator = new File\IsCompressed('image/gif'); $this->assertEquals('image/gif', $validator->getMimeType()); @@ -166,10 +164,8 @@ public function testGetMimeType() /** * Ensures that setMimeType() returns expected value - * - * @return void */ - public function testSetMimeType() + public function testSetMimeType(): void { $validator = new File\IsCompressed('image/gif'); $validator->setMimeType('image/jpeg'); @@ -187,10 +183,8 @@ public function testSetMimeType() /** * Ensures that addMimeType() returns expected value - * - * @return void */ - public function testAddMimeType() + public function testAddMimeType(): void { $validator = new File\IsCompressed('image/gif'); $validator->addMimeType('text'); diff --git a/test/File/IsImageTest.php b/test/File/IsImageTest.php index 6379a8745..cd4fe1574 100644 --- a/test/File/IsImageTest.php +++ b/test/File/IsImageTest.php @@ -84,10 +84,8 @@ public function testLegacy($options, array $isValidParam, bool $expected): void /** * Ensures that getMimeType() returns expected value - * - * @return void */ - public function testGetMimeType() + public function testGetMimeType(): void { $validator = new File\IsImage('image/gif'); $this->assertEquals('image/gif', $validator->getMimeType()); @@ -101,10 +99,8 @@ public function testGetMimeType() /** * Ensures that setMimeType() returns expected value - * - * @return void */ - public function testSetMimeType() + public function testSetMimeType(): void { $validator = new File\IsImage('image/gif'); $validator->setMimeType('image/jpeg'); @@ -122,10 +118,8 @@ public function testSetMimeType() /** * Ensures that addMimeType() returns expected value - * - * @return void */ - public function testAddMimeType() + public function testAddMimeType(): void { $validator = new File\IsImage('image/gif'); $validator->addMimeType('text'); diff --git a/test/File/Md5Test.php b/test/File/Md5Test.php index b624255b4..778370aa1 100644 --- a/test/File/Md5Test.php +++ b/test/File/Md5Test.php @@ -147,10 +147,8 @@ public function testgetMd5() /** * Ensures that getHash() returns expected value - * - * @return void */ - public function testgetHash() + public function testgetHash(): void { $validator = new File\Md5('12345'); $this->assertEquals(['12345' => 'md5'], $validator->getHash()); @@ -176,10 +174,8 @@ public function testSetMd5() /** * Ensures that setHash() returns expected value - * - * @return void */ - public function testSetHash() + public function testSetHash(): void { $validator = new File\Md5('12345'); $validator->setHash('12333'); @@ -209,10 +205,8 @@ public function testAddMd5() /** * Ensures that addHash() returns expected value - * - * @return void */ - public function testAddHash() + public function testAddHash(): void { $validator = new File\Md5('12345'); $validator->addHash('12344'); diff --git a/test/File/MimeTypeTest.php b/test/File/MimeTypeTest.php index b1708114c..9ea11d071 100644 --- a/test/File/MimeTypeTest.php +++ b/test/File/MimeTypeTest.php @@ -95,10 +95,8 @@ public function testLegacy($options, $isValidParam, bool $expected): void /** * Ensures that getMimeType() returns expected value - * - * @return void */ - public function testGetMimeType() + public function testGetMimeType(): void { $validator = new File\MimeType('image/gif'); $this->assertEquals('image/gif', $validator->getMimeType()); @@ -112,10 +110,8 @@ public function testGetMimeType() /** * Ensures that setMimeType() returns expected value - * - * @return void */ - public function testSetMimeType() + public function testSetMimeType(): void { $validator = new File\MimeType('image/gif'); $validator->setMimeType('image/jpeg'); @@ -133,10 +129,8 @@ public function testSetMimeType() /** * Ensures that addMimeType() returns expected value - * - * @return void */ - public function testAddMimeType() + public function testAddMimeType(): void { $validator = new File\MimeType('image/gif'); $validator->addMimeType('text'); diff --git a/test/File/NotExistsTest.php b/test/File/NotExistsTest.php index 642e63ce9..2299d17c3 100644 --- a/test/File/NotExistsTest.php +++ b/test/File/NotExistsTest.php @@ -86,10 +86,8 @@ public function testLegacy(string $options, $isValidParam, bool $expected): void /** * Ensures that getDirectory() returns expected value - * - * @return void */ - public function testGetDirectory() + public function testGetDirectory(): void { $validator = new File\NotExists('C:/temp'); $this->assertEquals('C:/temp', $validator->getDirectory()); @@ -103,10 +101,8 @@ public function testGetDirectory() /** * Ensures that setDirectory() returns expected value - * - * @return void */ - public function testSetDirectory() + public function testSetDirectory(): void { $validator = new File\NotExists('temp'); $validator->setDirectory('gif'); @@ -124,10 +120,8 @@ public function testSetDirectory() /** * Ensures that addDirectory() returns expected value - * - * @return void */ - public function testAddDirectory() + public function testAddDirectory(): void { $validator = new File\NotExists('temp'); $validator->addDirectory('gif'); diff --git a/test/File/Sha1Test.php b/test/File/Sha1Test.php index f386c03a5..ceec934af 100644 --- a/test/File/Sha1Test.php +++ b/test/File/Sha1Test.php @@ -130,10 +130,8 @@ public function testgetSha1() /** * Ensures that getHash() returns expected value - * - * @return void */ - public function testgetHash() + public function testGetHash(): void { $validator = new File\Sha1('12345'); $this->assertEquals(['12345' => 'sha1'], $validator->getHash()); @@ -159,10 +157,8 @@ public function testSetSha1() /** * Ensures that setHash() returns expected value - * - * @return void */ - public function testSetHash() + public function testSetHash(): void { $validator = new File\Sha1('12345'); $validator->setHash('12333'); @@ -192,10 +188,8 @@ public function testAddSha1() /** * Ensures that addHash() returns expected value - * - * @return void */ - public function testAddHash() + public function testAddHash(): void { $validator = new File\Sha1('12345'); $validator->addHash('12344'); diff --git a/test/File/SizeTest.php b/test/File/SizeTest.php index 82acbaea7..085067b29 100644 --- a/test/File/SizeTest.php +++ b/test/File/SizeTest.php @@ -94,10 +94,8 @@ public function testLegacy($options, $isValidParam, bool $expected): void /** * Ensures that getMin() returns expected value - * - * @return void */ - public function testGetMin() + public function testGetMin(): void { $validator = new File\Size(['min' => 1, 'max' => 100]); $this->assertEquals('1B', $validator->getMin()); @@ -112,10 +110,8 @@ public function testGetMin() /** * Ensures that setMin() returns expected value - * - * @return void */ - public function testSetMin() + public function testSetMin(): void { $validator = new File\Size(['min' => 1000, 'max' => 10000]); $validator->setMin(100); @@ -132,10 +128,8 @@ public function testSetMin() /** * Ensures that getMax() returns expected value - * - * @return void */ - public function testGetMax() + public function testGetMax(): void { $validator = new File\Size(['min' => 1, 'max' => 100, 'useByteString' => false]); $this->assertEquals(100, $validator->getMax()); @@ -153,10 +147,8 @@ public function testGetMax() /** * Ensures that setMax() returns expected value - * - * @return void */ - public function testSetMax() + public function testSetMax(): void { $validator = new File\Size(['max' => 0, 'useByteString' => true]); $this->assertEquals('0B', $validator->getMax()); @@ -197,10 +189,8 @@ public function testSetMax() /** * Ensures that the validator returns size infos - * - * @return void */ - public function testFailureMessage() + public function testFailureMessage(): void { $validator = new File\Size(['min' => 9999, 'max' => 10000]); $this->assertFalse($validator->isValid(__DIR__ . '/_files/testsize.mo')); diff --git a/test/File/UploadFileTest.php b/test/File/UploadFileTest.php index 37f824027..6f633040a 100644 --- a/test/File/UploadFileTest.php +++ b/test/File/UploadFileTest.php @@ -91,10 +91,7 @@ public function testBasic($fileInfo, string $messageKey): void $this->assertArrayHasKey($messageKey, $validator->getMessages()); } - /** - * @return void - */ - public function testRaisesExceptionWhenValueArrayIsBad() + public function testRaisesExceptionWhenValueArrayIsBad(): void { $validator = new File\UploadFile(); $this->expectException(InvalidArgumentException::class); diff --git a/test/File/UploadTest.php b/test/File/UploadTest.php index f92efd92d..f50e0fa4d 100644 --- a/test/File/UploadTest.php +++ b/test/File/UploadTest.php @@ -21,10 +21,8 @@ class UploadTest extends TestCase /** * Ensures that the validator follows expected behavior - * - * @return void */ - public function testBasic() + public function testBasic(): void { $_FILES = [ 'test' => [ @@ -244,10 +242,8 @@ public function testCanValidateCorrectlyFormedPsr7UploadedFiles(): void /** * Ensures that getFiles() returns expected value - * - * @return void */ - public function testGetFiles() + public function testGetFiles(): void { $_FILES = [ 'test' => [ @@ -336,10 +332,8 @@ public function testGetFilesRaisesExceptionWhenPsr7UploadedFilesArrayDoesNotCont /** * Ensures that setFiles() returns expected value - * - * @return void */ - public function testSetFiles() + public function testSetFiles(): void { $files = [ 'test' => [ diff --git a/test/File/WordCountTest.php b/test/File/WordCountTest.php index e203e9664..125b9fe18 100644 --- a/test/File/WordCountTest.php +++ b/test/File/WordCountTest.php @@ -89,10 +89,8 @@ public function testLegacy($options, $isValidParam, bool $expected): void /** * Ensures that getMin() returns expected value - * - * @return void */ - public function testGetMin() + public function testGetMin(): void { $validator = new File\WordCount(['min' => 1, 'max' => 5]); $this->assertEquals(1, $validator->getMin()); @@ -104,10 +102,8 @@ public function testGetMin() /** * Ensures that setMin() returns expected value - * - * @return void */ - public function testSetMin() + public function testSetMin(): void { $validator = new File\WordCount(['min' => 1000, 'max' => 10000]); $validator->setMin(100); @@ -120,10 +116,8 @@ public function testSetMin() /** * Ensures that getMax() returns expected value - * - * @return void */ - public function testGetMax() + public function testGetMax(): void { $validator = new File\WordCount(['min' => 1, 'max' => 100]); $this->assertEquals(100, $validator->getMax()); @@ -135,10 +129,8 @@ public function testGetMax() /** * Ensures that setMax() returns expected value - * - * @return void */ - public function testSetMax() + public function testSetMax(): void { $validator = new File\WordCount(['min' => 1000, 'max' => 10000]); $validator->setMax(1_000_000); diff --git a/test/GreaterThanTest.php b/test/GreaterThanTest.php index 0457217f0..983d7b784 100644 --- a/test/GreaterThanTest.php +++ b/test/GreaterThanTest.php @@ -19,9 +19,8 @@ class GreaterThanTest extends TestCase * * @dataProvider basicDataProvider * @param int|string $input - * @return void */ - public function testBasic(array $options, $input, bool $expected) + public function testBasic(array $options, $input, bool $expected): void { $validator = new GreaterThan(...$options); $this->assertSame($expected, $validator->isValid($input)); @@ -101,10 +100,8 @@ public function basicDataProvider(): array /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $validator = new GreaterThan(10); $this->assertEquals([], $validator->getMessages()); @@ -112,10 +109,8 @@ public function testGetMessages() /** * Ensures that getMin() returns expected value - * - * @return void */ - public function testGetMin() + public function testGetMin(): void { $validator = new GreaterThan(10); $this->assertEquals(10, $validator->getMin()); @@ -123,10 +118,8 @@ public function testGetMin() /** * Ensures that getInclusive() returns expected default value - * - * @return void */ - public function testGetInclusive() + public function testGetInclusive(): void { $validator = new GreaterThan(10); $this->assertEquals(false, $validator->getInclusive()); diff --git a/test/HexTest.php b/test/HexTest.php index 9c4b1f9cd..b25f6c30b 100644 --- a/test/HexTest.php +++ b/test/HexTest.php @@ -27,9 +27,8 @@ protected function setUp(): void * * @dataProvider basicDataProvider * @param int|string $input - * @return void */ - public function testBasic($input, bool $expected) + public function testBasic($input, bool $expected): void { $this->assertSame($expected, $this->validator->isValid($input)); } @@ -60,10 +59,8 @@ public function basicDataProvider(): array /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $this->assertEquals([], $this->validator->getMessages()); } diff --git a/test/HostnameTest.php b/test/HostnameTest.php index f97089526..61066ec7a 100644 --- a/test/HostnameTest.php +++ b/test/HostnameTest.php @@ -48,9 +48,8 @@ protected function tearDown(): void * Ensures that the validator follows expected behavior * * @dataProvider basicDataProvider - * @return void */ - public function testBasic(int $option, bool $expected, string $hostname) + public function testBasic(int $option, bool $expected, string $hostname): void { $validator = new Hostname($option); self::assertSame($expected, $validator->isValid($hostname)); @@ -87,9 +86,8 @@ public function basicDataProvider(): array /** * @dataProvider combinationDataProvider - * @return void */ - public function testCombination(int $option, bool $expected, string $hostname) + public function testCombination(int $option, bool $expected, string $hostname): void { $validator = new Hostname($option); self::assertSame($expected, $validator->isValid($hostname)); @@ -176,10 +174,8 @@ public function testValidatorHandlesUnderscoresInDomainsWithoutTldCheckCorrectly /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { self::assertSame([], $this->validator->getMessages()); } @@ -310,10 +306,8 @@ public function tldNoMatchingDataProvider(): array /** * Ensures that getAllow() returns expected default value - * - * @return void */ - public function testGetAllow() + public function testGetAllow(): void { self::assertSame(Hostname::ALLOW_DNS, $this->validator->getAllow()); } diff --git a/test/InArrayTest.php b/test/InArrayTest.php index e821bf650..8451802fe 100644 --- a/test/InArrayTest.php +++ b/test/InArrayTest.php @@ -89,20 +89,16 @@ protected function setUp(): void /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $this->assertEquals([], $this->validator->getMessages()); } /** * Ensures that getHaystack() returns expected value - * - * @return void */ - public function testGetHaystack() + public function testGetHaystack(): void { $this->assertEquals([1, 2, 3], $this->validator->getHaystack()); } @@ -117,10 +113,8 @@ public function testUnsetHaystackRaisesException(): void /** * Ensures that getStrict() returns expected default value - * - * @return void */ - public function testGetStrict() + public function testGetStrict(): void { $this->assertFalse($this->validator->getStrict()); } diff --git a/test/IpTest.php b/test/IpTest.php index 9da9dc083..874b3ec9f 100644 --- a/test/IpTest.php +++ b/test/IpTest.php @@ -42,10 +42,8 @@ protected function setUp(): void /** * Ensures that the validator follows expected behavior - * - * @return void */ - public function testBasic() + public function testBasic(): void { $this->assertTrue($this->validator->isValid('1.2.3.4')); $this->assertTrue($this->validator->isValid('10.0.0.1')); @@ -356,10 +354,8 @@ public function iPvFutureAddressesProvider(): array /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $this->assertEquals([], $this->validator->getMessages()); } diff --git a/test/IsInstanceOfTest.php b/test/IsInstanceOfTest.php index 398068e1a..b7c631659 100644 --- a/test/IsInstanceOfTest.php +++ b/test/IsInstanceOfTest.php @@ -20,10 +20,8 @@ class IsInstanceOfTest extends TestCase { /** * Ensures that the validator follows expected behavior - * - * @return void */ - public function testBasic() + public function testBasic(): void { $validator = new Validator\IsInstanceOf(DateTime::class); $this->assertTrue($validator->isValid(new DateTime())); // True @@ -41,10 +39,8 @@ public function testBasic() /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $validator = new Validator\IsInstanceOf(DateTime::class); $this->assertEquals([], $validator->getMessages()); @@ -52,10 +48,8 @@ public function testGetMessages() /** * Ensures that getClassName() returns expected value - * - * @return void */ - public function testGetClassName() + public function testGetClassName(): void { $validator = new Validator\IsInstanceOf(DateTime::class); $this->assertEquals(DateTime::class, $validator->getClassName()); diff --git a/test/IsbnTest.php b/test/IsbnTest.php index 4904daa92..1f2b71af9 100644 --- a/test/IsbnTest.php +++ b/test/IsbnTest.php @@ -50,10 +50,8 @@ public function testBasic(string $value, bool $expected): void /** * Ensures that setSeparator() works as expected - * - * @return void */ - public function testType() + public function testType(): void { $validator = new Isbn(); @@ -73,10 +71,8 @@ public function testType() /** * Ensures that setSeparator() works as expected - * - * @return void */ - public function testSeparator() + public function testSeparator(): void { $validator = new Isbn(); @@ -96,10 +92,8 @@ public function testSeparator() /** * Ensures that __construct() works as expected - * - * @return void */ - public function testInitialization() + public function testInitialization(): void { $options = [ 'type' => Isbn::AUTO, @@ -128,10 +122,8 @@ public function testInitialization() /** * Ensures that the validator follows expected behavior - * - * @return void */ - public function testTypeAuto() + public function testTypeAuto(): void { $validator = new Isbn(); diff --git a/test/LessThanTest.php b/test/LessThanTest.php index 0317b33ff..5f78bb9cf 100644 --- a/test/LessThanTest.php +++ b/test/LessThanTest.php @@ -19,9 +19,8 @@ class LessThanTest extends TestCase * * @dataProvider basicDataProvider * @param int|string $input - * @return void */ - public function testBasic(array $options, $input, bool $expected) + public function testBasic(array $options, $input, bool $expected): void { $validator = new LessThan(...$options); $this->assertSame($expected, $validator->isValid($input)); @@ -97,10 +96,8 @@ public function basicDataProvider(): array /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $validator = new LessThan(10); $this->assertEquals([], $validator->getMessages()); @@ -108,10 +105,8 @@ public function testGetMessages() /** * Ensures that getMax() returns expected value - * - * @return void */ - public function testGetMax() + public function testGetMax(): void { $validator = new LessThan(10); $this->assertEquals(10, $validator->getMax()); @@ -119,10 +114,8 @@ public function testGetMax() /** * Ensures that getInclusive() returns expected default value - * - * @return void */ - public function testGetInclusive() + public function testGetInclusive(): void { $validator = new LessThan(10); $this->assertEquals(false, $validator->getInclusive()); diff --git a/test/MessageTest.php b/test/MessageTest.php index e2cab0c14..b4867c5a6 100644 --- a/test/MessageTest.php +++ b/test/MessageTest.php @@ -27,10 +27,8 @@ protected function setUp(): void /** * Ensures that we can change a specified message template by its key * and that this message is returned when the input is invalid. - * - * @return void */ - public function testSetMessage() + public function testSetMessage(): void { $inputInvalid = 'abcdefghij'; $this->assertFalse($this->validator->isValid($inputInvalid)); @@ -52,10 +50,8 @@ public function testSetMessage() * the first one in the list of message templates. * In the case of Laminas_Validate_StringLength, TOO_SHORT is * the one we should expect to change. - * - * @return void */ - public function testSetMessageDefaultKey() + public function testSetMessageDefaultKey(): void { $this->validator->setMessage( 'Your value is too short', @@ -72,10 +68,8 @@ public function testSetMessageDefaultKey() /** * Ensures that we can include the %value% parameter in the message, * and that it is substituted with the value we are validating. - * - * @return void */ - public function testSetMessageWithValueParam() + public function testSetMessageWithValueParam(): void { $this->validator->setMessage( "Your value '%value%' is too long", @@ -91,10 +85,8 @@ public function testSetMessageWithValueParam() /** * Ensures that we can include the %length% parameter in the message, * and that it is substituted with the length of the value we are validating. - * - * @return void */ - public function testSetMessageWithLengthParam() + public function testSetMessageWithLengthParam(): void { $this->validator->setMessage( "The length of your value is '%length%'", @@ -111,10 +103,8 @@ public function testSetMessageWithLengthParam() * class-by-class basis, in the message string. * In the case of Laminas_Validate_StringLength, one such parameter * is %max%. - * - * @return void */ - public function testSetMessageWithOtherParam() + public function testSetMessageWithOtherParam(): void { $this->validator->setMessage( 'Your value is too long, it should be no longer than %max%', @@ -131,10 +121,8 @@ public function testSetMessageWithOtherParam() * Ensures that if we set a parameter in the message that is not * known to the validator class, it is not changed; %shazam% is * left as literal text in the message. - * - * @return void */ - public function testSetMessageWithUnknownParam() + public function testSetMessageWithUnknownParam(): void { $this->validator->setMessage( 'Your value is too long, and btw, %shazam%!', @@ -150,10 +138,8 @@ public function testSetMessageWithUnknownParam() /** * Ensures that the validator throws an exception when we * try to set a message for a key that is unknown to the class. - * - * @return void */ - public function testSetMessageExceptionInvalidKey() + public function testSetMessageExceptionInvalidKey(): void { $keyInvalid = 'invalidKey'; @@ -169,10 +155,8 @@ public function testSetMessageExceptionInvalidKey() * Ensures that we can set more than one message at a time, * by passing an array of key/message pairs. Both messages * should be defined. - * - * @return void */ - public function testSetMessages() + public function testSetMessages(): void { $this->validator->setMessages( [ @@ -195,10 +179,8 @@ public function testSetMessages() * that are permitted to be substituted in the message string. * The access is by the parameter name, not by the protected * property variable name. - * - * @return void */ - public function testGetProperty() + public function testGetProperty(): void { $this->validator->setMessage( 'Your value is too long', @@ -219,10 +201,8 @@ public function testGetProperty() /** * Ensures that the class throws an exception when we try to * access a property that doesn't exist as a parameter. - * - * @return void */ - public function testGetPropertyException() + public function testGetPropertyException(): void { $this->validator->setMessage( 'Your value is too long', diff --git a/test/NotEmptyTest.php b/test/NotEmptyTest.php index c09d97b6e..059651ae9 100644 --- a/test/NotEmptyTest.php +++ b/test/NotEmptyTest.php @@ -28,10 +28,9 @@ protected function setUp(): void * * @param array $types Array of type strings or constants * @param integer $expected Expected value of calculated type - * @return void * @dataProvider constructorWithTypeArrayProvider */ - public function testConstructorWithTypeArray($types, $expected) + public function testConstructorWithTypeArray($types, $expected): void { $validator = new NotEmpty($types); $this->assertEquals($expected, $validator->getType()); @@ -62,10 +61,9 @@ public function constructorWithTypeArrayProvider(): array * @param mixed $value Value to test * @param boolean $valid Expected validity of value * @group Laminas-6708 - * @return void * @dataProvider basicProvider */ - public function testBasic($value, $valid) + public function testBasic($value, $valid): void { $this->checkValidationValue($value, $valid); } @@ -101,10 +99,9 @@ public function basicProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider booleanProvider */ - public function testOnlyBoolean($value, $valid) + public function testOnlyBoolean($value, $valid): void { $this->validator->setType(NotEmpty::BOOLEAN); $this->checkValidationValue($value, $valid); @@ -139,10 +136,9 @@ public function booleanProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider integerOnlyProvider */ - public function testOnlyInteger($value, $valid) + public function testOnlyInteger($value, $valid): void { $this->validator->setType(NotEmpty::INTEGER); $this->checkValidationValue($value, $valid); @@ -177,10 +173,9 @@ public function integerOnlyProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider floatOnlyProvider */ - public function testOnlyFloat($value, $valid) + public function testOnlyFloat($value, $valid): void { $this->validator->setType(NotEmpty::FLOAT); $this->checkValidationValue($value, $valid); @@ -215,10 +210,9 @@ public function floatOnlyProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider stringOnlyProvider */ - public function testOnlyString($value, $valid) + public function testOnlyString($value, $valid): void { $this->validator->setType(NotEmpty::STRING); $this->checkValidationValue($value, $valid); @@ -253,10 +247,9 @@ public function stringOnlyProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider zeroOnlyProvider */ - public function testOnlyZero($value, $valid) + public function testOnlyZero($value, $valid): void { $this->validator->setType(NotEmpty::ZERO); $this->checkValidationValue($value, $valid); @@ -291,10 +284,9 @@ public function zeroOnlyProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider arrayOnlyProvider */ - public function testOnlyArray($value, $valid) + public function testOnlyArray($value, $valid): void { $this->validator->setType(NotEmpty::EMPTY_ARRAY); $this->checkValidationValue($value, $valid); @@ -329,10 +321,9 @@ public function arrayOnlyProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider nullOnlyProvider */ - public function testOnlyNull($value, $valid) + public function testOnlyNull($value, $valid): void { $this->validator->setType(NotEmpty::NULL); $this->checkValidationValue($value, $valid); @@ -367,10 +358,9 @@ public function nullOnlyProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider phpOnlyProvider */ - public function testOnlyPHP($value, $valid) + public function testOnlyPHP($value, $valid): void { $this->validator->setType(NotEmpty::PHP); $this->checkValidationValue($value, $valid); @@ -405,10 +395,9 @@ public function phpOnlyProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider spaceOnlyProvider */ - public function testOnlySpace($value, $valid) + public function testOnlySpace($value, $valid): void { $this->validator->setType(NotEmpty::SPACE); $this->checkValidationValue($value, $valid); @@ -443,10 +432,9 @@ public function spaceOnlyProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider onlyAllProvider */ - public function testOnlyAll($value, $valid) + public function testOnlyAll($value, $valid): void { $this->validator->setType(NotEmpty::ALL); $this->checkValidationValue($value, $valid); @@ -481,10 +469,9 @@ public function onlyAllProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider arrayConstantNotationProvider */ - public function testArrayConstantNotation($value, $valid) + public function testArrayConstantNotation($value, $valid): void { $this->validator = new NotEmpty([ 'type' => [ @@ -526,10 +513,9 @@ public function arrayConstantNotationProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider arrayConfigNotationProvider */ - public function testArrayConfigNotation($value, $valid) + public function testArrayConfigNotation($value, $valid): void { $this->validator = new NotEmpty([ 'type' => [ @@ -572,10 +558,9 @@ public function arrayConfigNotationProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider multiConstantNotationProvider */ - public function testMultiConstantNotation($value, $valid) + public function testMultiConstantNotation($value, $valid): void { $this->validator = new NotEmpty( NotEmpty::ZERO + NotEmpty::STRING + NotEmpty::BOOLEAN @@ -589,10 +574,9 @@ public function testMultiConstantNotation($value, $valid) * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider multiConstantNotationProvider */ - public function testMultiConstantBooleanOrNotation($value, $valid) + public function testMultiConstantBooleanOrNotation($value, $valid): void { $this->validator = new NotEmpty( NotEmpty::ZERO | NotEmpty::STRING | NotEmpty::BOOLEAN @@ -630,10 +614,9 @@ public function multiConstantNotationProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider stringNotationProvider */ - public function testStringNotation($value, $valid) + public function testStringNotation($value, $valid): void { $this->validator = new NotEmpty([ 'type' => ['zero', 'string', 'boolean'], @@ -672,10 +655,9 @@ public function stringNotationProvider() * * @param string $string Array of string type values * @param integer $expected Expected type setting value - * @return void * @dataProvider duplicateStringSettingProvider */ - public function testStringNotationWithDuplicate($string, $expected) + public function testStringNotationWithDuplicate($string, $expected): void { $type = [$string, $string]; $this->validator->setType($type); @@ -713,10 +695,9 @@ public function duplicateStringSettingProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider singleStringNotationProvider */ - public function testSingleStringConstructorNotation($value, $valid) + public function testSingleStringConstructorNotation($value, $valid): void { $this->validator = new NotEmpty( 'boolean' @@ -729,10 +710,9 @@ public function testSingleStringConstructorNotation($value, $valid) * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider singleStringNotationProvider */ - public function testSingleStringSetTypeNotation($value, $valid) + public function testSingleStringSetTypeNotation($value, $valid): void { $this->validator->setType('boolean'); $this->checkValidationValue($value, $valid); @@ -767,10 +747,9 @@ public function singleStringNotationProvider() * * @param mixed $value Value to test * @param boolean $valid Expected validity of value - * @return void * @dataProvider configObjectProvider */ - public function testTraversableObject($value, $valid) + public function testTraversableObject($value, $valid): void { $options = ['type' => 'all']; $config = new ArrayObject($options); @@ -808,10 +787,8 @@ public function configObjectProvider() /** * Ensures that the validator follows expected behavior - * - * @return void */ - public function testSettingFalseType() + public function testSettingFalseType(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Unknown'); @@ -820,10 +797,8 @@ public function testSettingFalseType() /** * Ensures that the validator follows expected behavior - * - * @return void */ - public function testGetType() + public function testGetType(): void { $this->assertEquals($this->validator->getDefaultType(), $this->validator->getType()); } @@ -838,10 +813,8 @@ public function testStringWithZeroShouldNotBeTreatedAsEmpty(): void /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $this->assertEquals([], $this->validator->getMessages()); } @@ -869,10 +842,7 @@ public function testLaminas8767() $this->assertStringContainsString("can't be empty", $messages['isEmpty']); } - /** - * @return void - */ - public function testObjects() + public function testObjects(): void { $valid = new NotEmpty(NotEmpty::STRING); $object = new stdClass(); @@ -883,10 +853,7 @@ public function testObjects() $this->assertTrue($valid->isValid($object)); } - /** - * @return void - */ - public function testStringObjects() + public function testStringObjects(): void { $valid = new NotEmpty(NotEmpty::STRING); diff --git a/test/RegexTest.php b/test/RegexTest.php index 4428c98bc..6827eeab0 100644 --- a/test/RegexTest.php +++ b/test/RegexTest.php @@ -21,9 +21,8 @@ class RegexTest extends TestCase * Ensures that the validator follows expected behavior * * @dataProvider basicDataProvider - * @return void */ - public function testBasic(array $options, string $input, bool $expected) + public function testBasic(array $options, string $input, bool $expected): void { $validator = new Regex(...$options); $this->assertSame($expected, $validator->isValid($input)); @@ -61,10 +60,8 @@ public function basicDataProvider(): array /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $validator = new Regex('/./'); $this->assertEquals([], $validator->getMessages()); @@ -72,10 +69,8 @@ public function testGetMessages() /** * Ensures that getPattern() returns expected value - * - * @return void */ - public function testGetPattern() + public function testGetPattern(): void { $validator = new Regex('/./'); $this->assertEquals('/./', $validator->getPattern()); @@ -83,10 +78,8 @@ public function testGetPattern() /** * Ensures that a bad pattern results in a thrown exception upon isValid() call - * - * @return void */ - public function testBadPattern() + public function testBadPattern(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Internal error parsing'); diff --git a/test/StaticValidatorTest.php b/test/StaticValidatorTest.php index d0d37ec02..7748887b4 100644 --- a/test/StaticValidatorTest.php +++ b/test/StaticValidatorTest.php @@ -193,9 +193,8 @@ public function testExecuteRaisesExceptionForIndexedOptionsArray( * Refactored to conform with Laminas-2724. * * @group Laminas-2724 - * @return void */ - public function testStaticFactoryClassNotFound() + public function testStaticFactoryClassNotFound(): void { $this->expectException(ServiceNotFoundException::class); /** @psalm-suppress ArgumentTypeCoercion, UndefinedClass */ diff --git a/test/StepTest.php b/test/StepTest.php index 179ff86c7..94210d133 100644 --- a/test/StepTest.php +++ b/test/StepTest.php @@ -197,10 +197,8 @@ public function testdecimalHundredthStep(float $value, bool $expected): void /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $this->assertEquals([], $this->validator->getMessages()); } diff --git a/test/StringLengthTest.php b/test/StringLengthTest.php index b84c696b3..b07f3a4ea 100644 --- a/test/StringLengthTest.php +++ b/test/StringLengthTest.php @@ -31,9 +31,8 @@ protected function setUp(): void * Ensures that the validator follows expected behavior * * @dataProvider basicDataProvider - * @return void */ - public function testBasic(array $options, bool $expected, string $input) + public function testBasic(array $options, bool $expected, string $input): void { ini_set('default_charset', 'UTF-8'); @@ -81,40 +80,32 @@ public function basicDataProvider(): array /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { $this->assertEquals([], $this->validator->getMessages()); } /** * Ensures that getMin() returns expected default value - * - * @return void */ - public function testGetMin() + public function testGetMin(): void { $this->assertEquals(0, $this->validator->getMin()); } /** * Ensures that getMax() returns expected default value - * - * @return void */ - public function testGetMax() + public function testGetMax(): void { $this->assertEquals(null, $this->validator->getMax()); } /** * Ensures that setMin() throws an exception when given a value greater than the maximum - * - * @return void */ - public function testSetMinExceptionGreaterThanMax() + public function testSetMinExceptionGreaterThanMax(): void { $max = 1; $min = 2; @@ -126,10 +117,8 @@ public function testSetMinExceptionGreaterThanMax() /** * Ensures that setMax() throws an exception when given a value less than the minimum - * - * @return void */ - public function testSetMaxExceptionLessThanMin() + public function testSetMaxExceptionLessThanMin(): void { $max = 1; $min = 2; @@ -139,10 +128,7 @@ public function testSetMaxExceptionLessThanMin() $this->validator->setMin($min)->setMax($max); } - /** - * @return void - */ - public function testDifferentEncodingWithValidator() + public function testDifferentEncodingWithValidator(): void { ini_set('default_charset', 'UTF-8'); diff --git a/test/TimezoneTest.php b/test/TimezoneTest.php index 7df43d7b3..67f8d3ca5 100644 --- a/test/TimezoneTest.php +++ b/test/TimezoneTest.php @@ -197,10 +197,8 @@ public function wrongTypesProvider(): array /** * Test pass `type` option through constructor - * - * @return void */ - public function testTypeThroughConstructor() + public function testTypeThroughConstructor(): void { $timezone1 = new Timezone(Timezone::LOCATION); $this->assertTrue($timezone1->isValid('Asia/Dubai')); diff --git a/test/UriTest.php b/test/UriTest.php index 7fa2cc2b1..6e03a5e48 100644 --- a/test/UriTest.php +++ b/test/UriTest.php @@ -157,10 +157,8 @@ public function testUriHandlerThrowsExceptionInParseMethodNotValid(): void /** * Ensures that getMessages() returns expected default value - * - * @return void */ - public function testGetMessages() + public function testGetMessages(): void { self::assertSame([], $this->validator->getMessages()); } diff --git a/test/ValidatorChainTest.php b/test/ValidatorChainTest.php index 999cf347a..1857af136 100644 --- a/test/ValidatorChainTest.php +++ b/test/ValidatorChainTest.php @@ -52,10 +52,8 @@ public function testValidatorChainIsEmptyByDefault(): void /** * Ensures expected results from empty validator chain - * - * @return void */ - public function testEmpty() + public function testEmpty(): void { $this->assertEquals([], $this->validator->getMessages()); $this->assertTrue($this->validator->isValid('something')); @@ -63,10 +61,8 @@ public function testEmpty() /** * Ensures expected behavior from a validator known to succeed - * - * @return void */ - public function testTrue() + public function testTrue(): void { $this->validator->attach($this->getValidatorTrue()); $this->assertTrue($this->validator->isValid(null)); @@ -75,10 +71,8 @@ public function testTrue() /** * Ensures expected behavior from a validator known to fail - * - * @return void */ - public function testFalse() + public function testFalse(): void { $this->validator->attach($this->getValidatorFalse()); $this->assertFalse($this->validator->isValid(null)); @@ -87,10 +81,8 @@ public function testFalse() /** * Ensures that a validator may break the chain - * - * @return void */ - public function testBreakChainOnFailure() + public function testBreakChainOnFailure(): void { $this->validator->attach($this->getValidatorFalse(), true) ->attach($this->getValidatorFalse());