diff --git a/tests/framework/ChangeLogTest.php b/tests/framework/ChangeLogTest.php index 52bccb4c1b..479b530df1 100644 --- a/tests/framework/ChangeLogTest.php +++ b/tests/framework/ChangeLogTest.php @@ -18,7 +18,7 @@ use yiiunit\TestCase; */ class ChangeLogTest extends TestCase { - public function changeProvider() + public static function changeProvider(): array { $lines = preg_split('~\R~', file_get_contents(__DIR__ . '/../../framework/CHANGELOG.md'), -1, PREG_SPLIT_NO_EMPTY); diff --git a/tests/framework/base/ActionFilterTest.php b/tests/framework/base/ActionFilterTest.php index 2340e30f64..2364746ce3 100644 --- a/tests/framework/base/ActionFilterTest.php +++ b/tests/framework/base/ActionFilterTest.php @@ -90,7 +90,7 @@ class ActionFilterTest extends TestCase $this->assertEquals([1, 3, 2], $controller->result); } - public function actionFilterProvider() + public static function actionFilterProvider(): array { return [ [['class' => 'yii\filters\AccessControl', 'user' => 'yiiunit\framework\base\MockUser']], diff --git a/tests/framework/base/ControllerTest.php b/tests/framework/base/ControllerTest.php index ce97daf76b..0491239ec2 100644 --- a/tests/framework/base/ControllerTest.php +++ b/tests/framework/base/ControllerTest.php @@ -68,7 +68,7 @@ class ControllerTest extends TestCase $this->assertEquals($expectedActionMethod, $actionMethod); } - public function createInlineActionProvider() + public static function createInlineActionProvider(): array { return [ ['\yiiunit\framework\base\TestController', 'non-existent-id', null], @@ -91,7 +91,7 @@ class ControllerTest extends TestCase $this->assertSame($expected, preg_match('/^(?:[a-z0-9_]+-)*[a-z0-9_]+$/', $input)); } - public function actionIdMethodProvider() + public static function actionIdMethodProvider(): array { return [ ['apple-id', 1], diff --git a/tests/framework/base/SecurityTest.php b/tests/framework/base/SecurityTest.php index 365ba6bae5..9f976fd619 100644 --- a/tests/framework/base/SecurityTest.php +++ b/tests/framework/base/SecurityTest.php @@ -182,7 +182,7 @@ TEXT; } } - public function dataProviderEncryptByKeyCompat() + public static function dataProviderEncryptByKeyCompat(): array { // these ciphertexts generated using Yii 2.0.2 which is based on mcrypt. $mcrypt = [ @@ -493,7 +493,7 @@ TEXT; $this->assertEquals($data, $this->security->decryptByKey($encrypted, $key)); } - public function dataProviderEncryptByPasswordCompat() + public static function dataProviderEncryptByPasswordCompat(): array { // these ciphertexts generated using Yii 2.0.2 which is based on mcrypt. $mcrypt = [ @@ -803,7 +803,7 @@ TEXT; $this->assertEquals($data, $this->security->decryptByPassword($encrypted, $password)); } - public function randomKeyInvalidInputs() + public static function randomKeyInvalidInputs(): array { return [ [0], @@ -873,7 +873,7 @@ TEXT; $this->assertEquals(1, preg_match('/[A-Za-z0-9_-]+/', $key)); } - public function dataProviderPbkdf2() + public static function dataProviderPbkdf2(): array { return array_filter([ [ @@ -968,7 +968,7 @@ TEXT; $this->assertEquals($okm, bin2hex($DK)); } - public function dataProviderDeriveKey() + public static function dataProviderDeriveKey(): array { // See Appendix A in https://tools.ietf.org/html/rfc5869 return [ @@ -1061,7 +1061,7 @@ TEXT; $this->assertEquals($okm, bin2hex($dk)); } - public function dataProviderCompareStrings() + public static function dataProviderCompareStrings(): array { return [ ['', ''], @@ -1120,7 +1120,7 @@ TEXT; /** * @return array */ - public function maskProvider() + public static function maskProvider(): array { return [ ['1'], diff --git a/tests/framework/behaviors/AttributeBehaviorTest.php b/tests/framework/behaviors/AttributeBehaviorTest.php index 5266ba8f86..2d9f2a8ad6 100644 --- a/tests/framework/behaviors/AttributeBehaviorTest.php +++ b/tests/framework/behaviors/AttributeBehaviorTest.php @@ -66,7 +66,7 @@ class AttributeBehaviorTest extends TestCase /** * @return array */ - public function preserveNonEmptyValuesDataProvider() + public static function preserveNonEmptyValuesDataProvider(): array { return [ [ diff --git a/tests/framework/behaviors/AttributesBehaviorTest.php b/tests/framework/behaviors/AttributesBehaviorTest.php index 3be2d584ac..c52faeda47 100644 --- a/tests/framework/behaviors/AttributesBehaviorTest.php +++ b/tests/framework/behaviors/AttributesBehaviorTest.php @@ -66,7 +66,7 @@ class AttributesBehaviorTest extends TestCase /** * @return array */ - public function preserveNonEmptyValuesDataProvider() + public static function preserveNonEmptyValuesDataProvider(): array { return [ [ @@ -121,7 +121,7 @@ class AttributesBehaviorTest extends TestCase /** * @return array */ - public function orderProvider() + public static function orderProvider(): array { return [ [ diff --git a/tests/framework/behaviors/TimestampBehaviorTest.php b/tests/framework/behaviors/TimestampBehaviorTest.php index bf1e6da74c..f9c05775a5 100644 --- a/tests/framework/behaviors/TimestampBehaviorTest.php +++ b/tests/framework/behaviors/TimestampBehaviorTest.php @@ -130,7 +130,7 @@ class TimestampBehaviorTest extends TestCase $model->save(false); } - public function expressionProvider() + public static function expressionProvider(): array { return [ [ @@ -142,7 +142,7 @@ class TimestampBehaviorTest extends TestCase [new Expression("strftime('%Y')"), date('Y')], ['2015-10-20', '2015-10-20'], [time(), time()], - [[$this, 'arrayCallable'], '2015-10-20'], + [[null, 'arrayCallable'], '2015-10-20'], ]; } @@ -153,6 +153,10 @@ class TimestampBehaviorTest extends TestCase */ public function testNewRecordExpression($expression, $expected): void { + if (is_array($expression)) { + $expression[0] ??= $this; + } + ActiveRecordTimestamp::$tableName = 'test_auto_timestamp_string'; ActiveRecordTimestamp::$behaviors = [ 'timestamp' => [ diff --git a/tests/framework/caching/CacheTestCase.php b/tests/framework/caching/CacheTestCase.php index 8147daa912..1f8113b6c2 100644 --- a/tests/framework/caching/CacheTestCase.php +++ b/tests/framework/caching/CacheTestCase.php @@ -107,7 +107,7 @@ abstract class CacheTestCase extends TestCase /** * @return array testing multiSet with and without expiry */ - public function multiSetExpiry() + public static function multiSetExpiry(): array { return [[0], [2]]; } diff --git a/tests/framework/console/RequestTest.php b/tests/framework/console/RequestTest.php index af90715a47..dd228d4560 100644 --- a/tests/framework/console/RequestTest.php +++ b/tests/framework/console/RequestTest.php @@ -16,7 +16,7 @@ use yiiunit\TestCase; */ class RequestTest extends TestCase { - public function provider() + public static function provider(): array { return [ [ diff --git a/tests/framework/console/UnknownCommandExceptionTest.php b/tests/framework/console/UnknownCommandExceptionTest.php index 179ba23d87..2318fc6c1a 100644 --- a/tests/framework/console/UnknownCommandExceptionTest.php +++ b/tests/framework/console/UnknownCommandExceptionTest.php @@ -32,7 +32,7 @@ class UnknownCommandExceptionTest extends TestCase ]); } - public function suggestedCommandsProvider() + public static function suggestedCommandsProvider(): array { return [ ['migate', ['migrate']], diff --git a/tests/framework/console/controllers/AssetControllerTest.php b/tests/framework/console/controllers/AssetControllerTest.php index 704873c4c7..77b25bf4ed 100644 --- a/tests/framework/console/controllers/AssetControllerTest.php +++ b/tests/framework/console/controllers/AssetControllerTest.php @@ -466,7 +466,7 @@ EOL; * Data provider for [[testAdjustCssUrl()]]. * @return array test data. */ - public function adjustCssUrlDataProvider() + public static function adjustCssUrlDataProvider(): array { return [ [ @@ -585,7 +585,7 @@ EOL; * Data provider for [[testFindRealPath()]]. * @return array test data */ - public function findRealPathDataProvider() + public static function findRealPathDataProvider(): array { return [ [ diff --git a/tests/framework/console/controllers/MigrateControllerTest.php b/tests/framework/console/controllers/MigrateControllerTest.php index c9e3014785..0536ef8cf4 100644 --- a/tests/framework/console/controllers/MigrateControllerTest.php +++ b/tests/framework/console/controllers/MigrateControllerTest.php @@ -159,7 +159,7 @@ class MigrateControllerTest extends TestCase /** * @return array */ - public function generateMigrationDataProvider() + public static function generateMigrationDataProvider(): array { $params = [ 'create_fields' => [ @@ -359,7 +359,7 @@ class MigrateControllerTest extends TestCase /** * @return array */ - public function generateJunctionMigrationDataProvider() + public static function generateJunctionMigrationDataProvider(): array { return [ ['create_junction_post_and_tag_tables', 'post_tag', 'post', 'tag'], @@ -487,7 +487,7 @@ class MigrateControllerTest extends TestCase $this->assertStringContainsString('No new migrations found. Your system is up-to-date.', $result); } - public function refreshMigrationDataProvider() + public static function refreshMigrationDataProvider(): array { return [ ['default'], diff --git a/tests/framework/console/controllers/PHPMessageControllerTest.php b/tests/framework/console/controllers/PHPMessageControllerTest.php index 9551eecce2..61b874397e 100644 --- a/tests/framework/console/controllers/PHPMessageControllerTest.php +++ b/tests/framework/console/controllers/PHPMessageControllerTest.php @@ -124,7 +124,7 @@ class PHPMessageControllerTest extends BaseMessageControllerTest $this->assertEqualsWithoutLE($expected, $head); } - public function messageFileCategoriesDataProvider() + public static function messageFileCategoriesDataProvider(): array { return [ 'removeUnused:false - unused category should not be removed - normal category' => ['test_delete_category', true, false, true], diff --git a/tests/framework/console/widgets/TableTest.php b/tests/framework/console/widgets/TableTest.php index 431f1afcf7..312cad9da0 100644 --- a/tests/framework/console/widgets/TableTest.php +++ b/tests/framework/console/widgets/TableTest.php @@ -23,7 +23,7 @@ class TableTest extends TestCase $this->mockApplication(); } - public function getTableData() + public static function getTableData(): array { return [ [ @@ -69,7 +69,7 @@ EXPECTED; $this->assertEqualsWithoutLE($expected, $tableContent); } - public function getMultiLineTableData() + public static function getMultiLineTableData(): array { return [ [ @@ -138,7 +138,7 @@ EXPECTED; $this->assertEqualsWithoutLE($expected, $tableContent); } - public function getNumericTableData() + public static function getNumericTableData(): array { return [ [ @@ -658,7 +658,7 @@ EXPECTED; $this->assertTrue(true); } - public function dataMinimumWidth() + public static function dataMinimumWidth(): array { return [ ['X'], diff --git a/tests/framework/data/ActiveDataFilterTest.php b/tests/framework/data/ActiveDataFilterTest.php index 57b96a6ab6..598fcca854 100644 --- a/tests/framework/data/ActiveDataFilterTest.php +++ b/tests/framework/data/ActiveDataFilterTest.php @@ -23,7 +23,7 @@ class ActiveDataFilterTest extends TestCase // Tests : - public function dataProviderBuild() + public static function dataProviderBuild(): array { return [ [ diff --git a/tests/framework/data/DataFilterTest.php b/tests/framework/data/DataFilterTest.php index c36e038c80..cd75719124 100644 --- a/tests/framework/data/DataFilterTest.php +++ b/tests/framework/data/DataFilterTest.php @@ -87,7 +87,7 @@ class DataFilterTest extends TestCase * Data provider for [[testValidate()]]. * @return array test data. */ - public function dataProviderValidate() + public static function dataProviderValidate(): array { return [ [ @@ -295,7 +295,7 @@ class DataFilterTest extends TestCase * Data provider for [[testNormalize()]]. * @return array test data. */ - public function dataProviderNormalize() + public static function dataProviderNormalize(): array { return [ [ diff --git a/tests/framework/data/PaginationTest.php b/tests/framework/data/PaginationTest.php index bc19ce165e..5d64c4af35 100644 --- a/tests/framework/data/PaginationTest.php +++ b/tests/framework/data/PaginationTest.php @@ -33,7 +33,7 @@ class PaginationTest extends TestCase * Data provider for [[testCreateUrl()]]. * @return array test data */ - public function dataProviderCreateUrl() + public static function dataProviderCreateUrl(): array { return [ [ @@ -116,7 +116,7 @@ class PaginationTest extends TestCase $this->assertEquals(999, $pagination->getPage()); } - public function dataProviderPageCount() + public static function dataProviderPageCount(): array { return [ [0, 0, 0], @@ -153,7 +153,7 @@ class PaginationTest extends TestCase $this->assertEquals(0, (new Pagination())->getPage()); } - public function dataProviderSetPage() + public static function dataProviderSetPage(): array { return [ [null, false, 0, null], @@ -188,7 +188,7 @@ class PaginationTest extends TestCase $this->assertEquals($page, $pagination->getPage()); } - public function dataProviderGetPageSize() + public static function dataProviderGetPageSize(): array { return [ [[1, 50], 20], @@ -215,7 +215,7 @@ class PaginationTest extends TestCase $this->assertEquals($pageSize, $pagination->getPageSize()); } - public function dataProviderSetPageSize() + public static function dataProviderSetPageSize(): array { return [ [null, false, false, 20], @@ -250,7 +250,7 @@ class PaginationTest extends TestCase $this->assertEquals($pageSize, $pagination->getPageSize()); } - public function dataProviderGetOffset() + public static function dataProviderGetOffset(): array { return [ [0, 0, 0], @@ -277,7 +277,7 @@ class PaginationTest extends TestCase $this->assertEquals($offset, $pagination->getOffset()); } - public function dataProviderGetLimit() + public static function dataProviderGetLimit(): array { return [ [0, -1], @@ -300,7 +300,7 @@ class PaginationTest extends TestCase $this->assertEquals($limit, $pagination->getLimit()); } - public function dataProviderGetLinks() + public static function dataProviderGetLinks(): array { return [ [0, 0, 0, '/index.php?r=list&page=1&per-page=0', null, null, null, null], diff --git a/tests/framework/data/SortTest.php b/tests/framework/data/SortTest.php index dc70179c42..78698cfac7 100644 --- a/tests/framework/data/SortTest.php +++ b/tests/framework/data/SortTest.php @@ -209,7 +209,7 @@ class SortTest extends TestCase $this->assertEquals('/index.php?r=site%2Findex&sort=age', $sort->createUrl('name')); } - public function providerForLinkWithParams() + public static function providerForLinkWithParams(): array { return [ [true, null, 'Age'], @@ -251,7 +251,7 @@ class SortTest extends TestCase $this->assertEquals($link, $sort->link('age')); } - public function providerForLinkWithParamsAndPassedButEmptySort() + public static function providerForLinkWithParamsAndPassedButEmptySort(): array { return [ [null], @@ -295,7 +295,7 @@ class SortTest extends TestCase ); } - public function providerForLinkWithoutParams() + public static function providerForLinkWithoutParams(): array { return [ [false, null, 'Age'], diff --git a/tests/framework/data/SqlDataProviderTest.php b/tests/framework/data/SqlDataProviderTest.php index e997304e64..a338b724f4 100644 --- a/tests/framework/data/SqlDataProviderTest.php +++ b/tests/framework/data/SqlDataProviderTest.php @@ -48,7 +48,7 @@ class SqlDataProviderTest extends DatabaseTestCase $this->assertEquals(3, $dataProvider->getTotalCount()); } - public function providerForOrderByColumn() + public static function providerForOrderByColumn(): array { return [ 'no marks' => ['name'], diff --git a/tests/framework/di/ContainerTest.php b/tests/framework/di/ContainerTest.php index 09d6fb963e..79f25594fc 100644 --- a/tests/framework/di/ContainerTest.php +++ b/tests/framework/di/ContainerTest.php @@ -592,7 +592,7 @@ class ContainerTest extends TestCase ]); } - public function dataNotInstantiableException() + public static function dataNotInstantiableException(): array { return [ [Bar::class], diff --git a/tests/framework/filters/AccessRuleTest.php b/tests/framework/filters/AccessRuleTest.php index 5004dba606..a152ca17b5 100644 --- a/tests/framework/filters/AccessRuleTest.php +++ b/tests/framework/filters/AccessRuleTest.php @@ -218,7 +218,7 @@ class AccessRuleTest extends TestCase * test user id * expected match result (true, false, null) */ - public function matchRoleProvider() + public static function matchRoleProvider(): array { return [ ['create', true, 'user1', [], true], diff --git a/tests/framework/filters/HostControlTest.php b/tests/framework/filters/HostControlTest.php index 9435f51e73..be34480ff8 100644 --- a/tests/framework/filters/HostControlTest.php +++ b/tests/framework/filters/HostControlTest.php @@ -33,7 +33,7 @@ class HostControlTest extends TestCase /** * @return array test data. */ - public function hostInfoValidationDataProvider() + public static function hostInfoValidationDataProvider(): array { return [ [ diff --git a/tests/framework/filters/PageCacheTest.php b/tests/framework/filters/PageCacheTest.php index e81a28aed2..067d191a91 100644 --- a/tests/framework/filters/PageCacheTest.php +++ b/tests/framework/filters/PageCacheTest.php @@ -39,7 +39,7 @@ class PageCacheTest extends TestCase CacheTestCase::$microtime = null; } - public function cacheTestCaseProvider() + public static function cacheTestCaseProvider(): array { return [ // Basic diff --git a/tests/framework/filters/auth/AuthTest.php b/tests/framework/filters/auth/AuthTest.php index 95e46d8c2e..a8fad5dc20 100644 --- a/tests/framework/filters/auth/AuthTest.php +++ b/tests/framework/filters/auth/AuthTest.php @@ -49,7 +49,7 @@ class AuthTest extends TestCase $this->mockWebApplication($appConfig); } - public function tokenProvider() + public static function tokenProvider(): array { return [ ['token1', 'user1'], @@ -136,7 +136,7 @@ class AuthTest extends TestCase $this->ensureFilterApplies($token, $login, $filter); } - public function authMethodProvider() + public static function authMethodProvider(): array { return [ ['yii\filters\auth\CompositeAuth'], diff --git a/tests/framework/filters/auth/BasicAuthTest.php b/tests/framework/filters/auth/BasicAuthTest.php index efeba37e3e..99c786f956 100644 --- a/tests/framework/filters/auth/BasicAuthTest.php +++ b/tests/framework/filters/auth/BasicAuthTest.php @@ -122,7 +122,7 @@ class BasicAuthTest extends AuthTest $session->destroy(); } - public function authMethodProvider() + public static function authMethodProvider(): array { return [ ['yii\filters\auth\HttpBasicAuth'], diff --git a/tests/framework/filters/auth/CompositeAuthTest.php b/tests/framework/filters/auth/CompositeAuthTest.php index f5524ed48e..b6d0b979b8 100644 --- a/tests/framework/filters/auth/CompositeAuthTest.php +++ b/tests/framework/filters/auth/CompositeAuthTest.php @@ -178,7 +178,7 @@ class CompositeAuthTest extends TestCase $this->assertEquals('success', $controller->run('a')); } - public function compositeAuthDataProvider() + public static function compositeAuthDataProvider(): array { return [ //base usage diff --git a/tests/framework/grid/GridViewTest.php b/tests/framework/grid/GridViewTest.php index e0261a2c87..81ae9dc010 100644 --- a/tests/framework/grid/GridViewTest.php +++ b/tests/framework/grid/GridViewTest.php @@ -44,7 +44,7 @@ class GridViewTest extends TestCase /** * @return array */ - public function emptyDataProvider() + public static function emptyDataProvider(): array { return [ [null, 'No results found.'], diff --git a/tests/framework/grid/SerialColumnTest.php b/tests/framework/grid/SerialColumnTest.php index 149264ccd6..2c5ac9ce05 100644 --- a/tests/framework/grid/SerialColumnTest.php +++ b/tests/framework/grid/SerialColumnTest.php @@ -10,6 +10,7 @@ declare(strict_types=1); namespace yiiunit\framework\grid; +use yiiunit\TestCase; use Yii; use yii\data\ArrayDataProvider; use yii\data\Pagination; @@ -19,7 +20,7 @@ use yii\grid\SerialColumn; /** * @group grid */ -class SerialColumnTest extends \yiiunit\TestCase +class SerialColumnTest extends TestCase { /** * @dataProvider provideRenderDataCellData diff --git a/tests/framework/helpers/ArrayHelperTest.php b/tests/framework/helpers/ArrayHelperTest.php index 7aae8f965d..34cbf0b7c1 100644 --- a/tests/framework/helpers/ArrayHelperTest.php +++ b/tests/framework/helpers/ArrayHelperTest.php @@ -862,7 +862,7 @@ class ArrayHelperTest extends TestCase ArrayHelper::keyExists('a', $array, false); } - public function valueProvider() + public static function valueProvider(): array { return [ ['name', 'test'], @@ -995,7 +995,7 @@ class ArrayHelperTest extends TestCase * Data provider for [[testSetValue()]]. * @return array test data */ - public function dataProviderSetValue() + public static function dataProviderSetValue(): array { return [ [ @@ -1571,7 +1571,7 @@ class ArrayHelperTest extends TestCase * Data provider for [[testRecursiveSort()]]. * @return array test data */ - public function dataProviderRecursiveSort() + public static function dataProviderRecursiveSort(): array { return [ //Normal index array diff --git a/tests/framework/helpers/BaseConsoleTest.php b/tests/framework/helpers/BaseConsoleTest.php index 8ccaee812a..04d1a8ea15 100644 --- a/tests/framework/helpers/BaseConsoleTest.php +++ b/tests/framework/helpers/BaseConsoleTest.php @@ -71,7 +71,7 @@ class BaseConsoleTest extends TestCase $this->assertEquals($ansiExpected, $ansiActual); } - public function ansiColorizedSubstr_withColors_data() + public static function ansiColorizedSubstr_withColors_data(): array { return [ ['%rFoo%gBar%n', 0, 3, '%rFoo%n'], diff --git a/tests/framework/helpers/BaseUrlTest.php b/tests/framework/helpers/BaseUrlTest.php index 28d1ca7358..48d7180340 100644 --- a/tests/framework/helpers/BaseUrlTest.php +++ b/tests/framework/helpers/BaseUrlTest.php @@ -28,7 +28,7 @@ class BaseUrlTest extends TestCase $this->assertEquals($expected, BaseUrl::ensureScheme($url, $scheme)); } - public function ensureSchemeUrlProvider() + public static function ensureSchemeUrlProvider(): array { return [ 'relative url and https scheme will return input url' => [ @@ -69,7 +69,7 @@ class BaseUrlTest extends TestCase ]; } - public function relativeTrueUrlProvider() + public static function relativeTrueUrlProvider(): array { return [ 'url url without protocol' => [ @@ -87,7 +87,7 @@ class BaseUrlTest extends TestCase ]; } - public function relativeFalseUrlProvider() + public static function relativeFalseUrlProvider(): array { return [ 'url with https protocol' => [ diff --git a/tests/framework/helpers/ConsoleTest.php b/tests/framework/helpers/ConsoleTest.php index 51698ab405..a2f3cbdf95 100644 --- a/tests/framework/helpers/ConsoleTest.php +++ b/tests/framework/helpers/ConsoleTest.php @@ -154,7 +154,7 @@ class ConsoleTest extends TestCase } }*/ - public function ansiFormats() + public static function ansiFormats(): array { return [ ['test', 'test'], diff --git a/tests/framework/helpers/FileHelperTest.php b/tests/framework/helpers/FileHelperTest.php index 7df3c08d05..785e22ae25 100644 --- a/tests/framework/helpers/FileHelperTest.php +++ b/tests/framework/helpers/FileHelperTest.php @@ -1266,7 +1266,7 @@ class FileHelperTest extends TestCase FileHelper::changeOwnership($useFile ? $file : null, $ownership, $mode); } - public function changeOwnershipInvalidArgumentsProvider() + public static function changeOwnershipInvalidArgumentsProvider(): array { return [ [false, '123:123', null], @@ -1288,7 +1288,7 @@ class FileHelperTest extends TestCase $this->assertEquals($extensions, FileHelper::getExtensionsByMimeType($mimeType)); } - public function getExtensionsByMimeTypeProvider() + public static function getExtensionsByMimeTypeProvider(): array { return [ [ @@ -1323,7 +1323,7 @@ class FileHelperTest extends TestCase $this->assertEquals($extension, FileHelper::getExtensionByMimeType($mimeType, $preferShort)); } - public function getExtensionByMimeTypeProvider() + public static function getExtensionByMimeTypeProvider(): array { return [ ['application/json', true, 'json'], diff --git a/tests/framework/helpers/FormatConverterTest.php b/tests/framework/helpers/FormatConverterTest.php index 728dbc239d..540af1f04f 100644 --- a/tests/framework/helpers/FormatConverterTest.php +++ b/tests/framework/helpers/FormatConverterTest.php @@ -73,7 +73,7 @@ class FormatConverterTest extends TestCase $this->assertEquals('\\o\\\'\\c\\l\\o\\c\\k', FormatConverter::convertDateIcuToPhp('\'o\'\'clock\'')); } - public function providerForICU2PHPPatterns() + public static function providerForICU2PHPPatterns(): array { return [ 'two single quotes produce one' => ["''", "\\'"], @@ -222,7 +222,7 @@ class FormatConverterTest extends TestCase ); } - public function providerForICU2JUIPatterns() + public static function providerForICU2JUIPatterns(): array { return [ 'era designator like (Anno Domini)' => ['G', ''], @@ -389,7 +389,7 @@ class FormatConverterTest extends TestCase $this->assertEquals($expected, $actual); } - public function providerForPHP2ICUPatterns() + public static function providerForPHP2ICUPatterns(): array { return [ 'single \' should be encoded as \'\', which internally should be encoded as \'\'\'\'' => ["'", "''"], @@ -497,7 +497,7 @@ class FormatConverterTest extends TestCase $this->assertEquals('dd-mm-yy', FormatConverter::convertDatePhpToJui('d-m-Y')); } - public function providerForPHP2JUIPatterns() + public static function providerForPHP2JUIPatterns(): array { return [ 'Day of the month, 2 digits with leading zeros 01 to 31' => ['d', 'dd'], diff --git a/tests/framework/helpers/HtmlTest.php b/tests/framework/helpers/HtmlTest.php index 0b1fe156a5..3d7fe06bef 100644 --- a/tests/framework/helpers/HtmlTest.php +++ b/tests/framework/helpers/HtmlTest.php @@ -205,7 +205,7 @@ class HtmlTest extends TestCase * Data provider for [[testBeginFormSimulateViaPost()]]. * @return array test data */ - public function dataProviderBeginFormSimulateViaPost() + public static function dataProviderBeginFormSimulateViaPost(): array { return [ ['
', 'GET'], @@ -255,7 +255,7 @@ class HtmlTest extends TestCase /** * @return array */ - public function imgDataProvider() + public static function imgDataProvider(): array { return [ [ @@ -426,7 +426,7 @@ class HtmlTest extends TestCase /** * @return array */ - public function textareaDataProvider() + public static function textareaDataProvider(): array { return [ [ @@ -618,7 +618,7 @@ EOD; ); } - public function providerForNonStrictBooleanDropDownList() + public static function providerForNonStrictBooleanDropDownList(): array { return [ [null, false, false, false], @@ -653,7 +653,7 @@ HTML; ); } - public function providerForStrictBooleanDropDownList() + public static function providerForStrictBooleanDropDownList(): array { return [ [null, false, false, false], @@ -1480,7 +1480,7 @@ EOD; * Data provider for [[testActiveTextInput()]]. * @return array test data */ - public function dataProviderActiveTextInput() + public static function dataProviderActiveTextInput(): array { return [ [ @@ -1523,7 +1523,7 @@ EOD; * Data provider for [[testActiveTextInputMaxLength]]. * @return array test data */ - public function dataProviderActiveTextInputMaxLength() + public static function dataProviderActiveTextInputMaxLength(): array { return [ [ @@ -1572,7 +1572,7 @@ EOD; * Data provider for [[testActivePasswordInput()]]. * @return array test data */ - public function dataProviderActivePasswordInput() + public static function dataProviderActivePasswordInput(): array { return [ [ @@ -1615,7 +1615,7 @@ EOD; * Data provider for [[testActiveInput_TypeText]]. * @return array test data */ - public function dataProviderActiveInput_TypeText() + public static function dataProviderActiveInput_TypeText(): array { return [ [ @@ -1654,7 +1654,7 @@ EOD; $this->assertEquals($expectedHtml, Html::activeInput('text', $model, 'name', $options)); } - public function errorSummaryDataProvider() + public static function errorSummaryDataProvider(): array { return [ [ @@ -1781,7 +1781,7 @@ EOD; * Data provider for [[testActiveTextArea()]]. * @return array test data */ - public function dataProviderActiveTextArea() + public static function dataProviderActiveTextArea(): array { return [ [ @@ -1850,7 +1850,7 @@ EOD; * Data provider for [[testActiveRadio()]]. * @return array test data */ - public function dataProviderActiveRadio() + public static function dataProviderActiveRadio(): array { return [ [ @@ -1894,7 +1894,7 @@ EOD; * Data provider for [[testActiveCheckbox()]]. * @return array test data */ - public function dataProviderActiveCheckbox() + public static function dataProviderActiveCheckbox(): array { return [ [ @@ -1938,7 +1938,7 @@ EOD; * Data provider for [[testAttributeNameValidation()]]. * @return array test data */ - public function validAttributeNamesProvider() + public static function validAttributeNamesProvider(): array { $data = [ ['asd]asdf.asdfa[asdfa', 'asdf.asdfa'], @@ -1964,7 +1964,7 @@ EOD; * Data provider for [[testAttributeNameValidation()]]. * @return array test data */ - public function invalidAttributeNamesProvider() + public static function invalidAttributeNamesProvider(): array { return [ ['. ..'], @@ -2216,7 +2216,7 @@ HTML; $this->assertStringContainsString('placeholder="My placeholder: Name"', $html); } - public static function getInputIdDataProvider() + public static function getInputIdDataProvider(): array { return [ [ @@ -2255,7 +2255,7 @@ HTML; ]; } - public static function getInputIdByNameDataProvider() + public static function getInputIdByNameDataProvider(): array { return [ [ diff --git a/tests/framework/helpers/IpHelperTest.php b/tests/framework/helpers/IpHelperTest.php index 6cf57edf61..826f0caabb 100644 --- a/tests/framework/helpers/IpHelperTest.php +++ b/tests/framework/helpers/IpHelperTest.php @@ -24,7 +24,7 @@ class IpHelperTest extends TestCase $this->assertSame($expected, $version, $message); } - public function getIpVersionProvider() + public static function getIpVersionProvider(): array { return [ ['192.168.0.1', IpHelper::IPV4], @@ -44,7 +44,7 @@ class IpHelperTest extends TestCase $this->assertSame($expected, $expanded, $message); } - public function expandIpv6Provider() + public static function expandIpv6Provider(): array { return [ ['fa01::1', 'fa01:0000:0000:0000:0000:0000:0000:0001'], @@ -75,7 +75,7 @@ class IpHelperTest extends TestCase $this->assertSame($expected, $result, $message); } - public function ip2binProvider() + public static function ip2binProvider(): array { return [ ['192.168.1.1', '11000000101010000000000100000001'], @@ -99,7 +99,7 @@ class IpHelperTest extends TestCase $this->assertSame($expected, $result); } - public function inRangeProvider() + public static function inRangeProvider(): array { return [ ['192.168.1.1/24', '192.168.0.0/23', true], diff --git a/tests/framework/helpers/StringHelperTest.php b/tests/framework/helpers/StringHelperTest.php index 3d4ae65a16..2aad94a7b8 100644 --- a/tests/framework/helpers/StringHelperTest.php +++ b/tests/framework/helpers/StringHelperTest.php @@ -167,7 +167,7 @@ class StringHelperTest extends TestCase /** * Rules that should work the same for case-sensitive and case-insensitive `startsWith()`. */ - public function providerStartsWith() + public static function providerStartsWith(): array { return [ // positive check @@ -223,7 +223,7 @@ class StringHelperTest extends TestCase /** * Rules that should work the same for case-sensitive and case-insensitive `endsWith()`. */ - public function providerEndsWith() + public static function providerEndsWith(): array { return [ // positive check @@ -307,7 +307,7 @@ class StringHelperTest extends TestCase $this->assertEquals($output, $decoded); } - public function base64UrlEncodedStringsProvider() + public static function base64UrlEncodedStringsProvider(): array { return [ ['This is an encoded string', 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=='], @@ -321,7 +321,7 @@ class StringHelperTest extends TestCase * Data provider for [[testMatchWildcard()]] * @return array test data. */ - public function dataProviderMatchWildcard() + public static function dataProviderMatchWildcard(): array { return [ // * @@ -404,7 +404,7 @@ class StringHelperTest extends TestCase $this->assertSame($expectedResult, StringHelper::matchWildcard($pattern, $string, $options)); } - public function dataProviderMb_ucfirst() + public static function dataProviderMb_ucfirst(): array { return [ ['foo', 'Foo'], @@ -426,7 +426,7 @@ class StringHelperTest extends TestCase $this->assertSame($expectedResult, StringHelper::mb_ucfirst($string)); } - public function dataProviderMb_ucwords() + public static function dataProviderMb_ucwords(): array { return [ ['foo', 'Foo'], @@ -465,7 +465,7 @@ class StringHelperTest extends TestCase $this->assertSame($expectedResult, StringHelper::dirname($string)); } - public function dataProviderDirname() + public static function dataProviderDirname(): array { return [ ['\\foo\\bar\\test', '\foo\bar'], @@ -521,7 +521,7 @@ class StringHelperTest extends TestCase $this->assertSame($expectedResult, StringHelper::findBetween($string, $start, $end)); } - public function dataProviderFindBetween() + public static function dataProviderFindBetween(): array { return [ ['hello world hello', ' hello', ' world', null], // end before start diff --git a/tests/framework/helpers/VarDumperTest.php b/tests/framework/helpers/VarDumperTest.php index 550455f993..10d9a55216 100644 --- a/tests/framework/helpers/VarDumperTest.php +++ b/tests/framework/helpers/VarDumperTest.php @@ -61,7 +61,7 @@ class VarDumperTest extends TestCase * Data provider for [[testExport()]]. * @return array test data */ - public function dataProviderExport() + public static function dataProviderExport(): array { // Regular : diff --git a/tests/framework/i18n/FallbackMessageFormatterTest.php b/tests/framework/i18n/FallbackMessageFormatterTest.php index dd4d8d4199..cf1f9297b3 100644 --- a/tests/framework/i18n/FallbackMessageFormatterTest.php +++ b/tests/framework/i18n/FallbackMessageFormatterTest.php @@ -30,7 +30,7 @@ class FallbackMessageFormatterTest extends TestCase public const SUBJECT = 'сабж'; public const SUBJECT_VALUE = 'Answer to the Ultimate Question of Life, the Universe, and Everything'; - public function patterns() + public static function patterns(): array { return [ [ diff --git a/tests/framework/i18n/FormatterDateTest.php b/tests/framework/i18n/FormatterDateTest.php index 7f4533eb02..459615d633 100644 --- a/tests/framework/i18n/FormatterDateTest.php +++ b/tests/framework/i18n/FormatterDateTest.php @@ -548,7 +548,7 @@ class FormatterDateTest extends TestCase $this->assertSame($this->formatter->nullDisplay, $this->formatter->asDuration(null)); } - public function dateInputs() + public static function dateInputs(): array { return [ ['2015-01-01 00:00:00', '2014-13-01 00:00:00'], @@ -584,7 +584,7 @@ class FormatterDateTest extends TestCase $this->assertSame($expected, $this->formatter->asDatetime($value, 'yyyy-MM-dd HH:mm:ss')); } - public function provideTimezones() + public static function provideTimezones(): array { return [ ['UTC'], diff --git a/tests/framework/i18n/FormatterNumberTest.php b/tests/framework/i18n/FormatterNumberTest.php index 6aec3faeae..00c65d62f4 100755 --- a/tests/framework/i18n/FormatterNumberTest.php +++ b/tests/framework/i18n/FormatterNumberTest.php @@ -46,7 +46,7 @@ class FormatterNumberTest extends TestCase /** * Provides some configuration that should not affect Integer formatter. */ - public function differentConfigProvider() + public static function differentConfigProvider(): array { // make this test not break when intl is not installed if (!extension_loaded('intl')) { @@ -824,7 +824,7 @@ class FormatterNumberTest extends TestCase $this->assertSame('1023 B', $this->formatter->asShortSize(1023)); } - public function providerForDirectWrongTypeAttributes() + public static function providerForDirectWrongTypeAttributes(): array { return [ 'not-int key for int options' => [ @@ -870,7 +870,7 @@ class FormatterNumberTest extends TestCase $this->formatter->asInteger(1, $intOptions, $textOptions); } - public function providerForConfiguredWrongTypeAttributes() + public static function providerForConfiguredWrongTypeAttributes(): array { return [ 'not-int key for int options' => [ diff --git a/tests/framework/i18n/FormatterTest.php b/tests/framework/i18n/FormatterTest.php index 9621a16581..a405e274a5 100644 --- a/tests/framework/i18n/FormatterTest.php +++ b/tests/framework/i18n/FormatterTest.php @@ -357,7 +357,7 @@ class FormatterTest extends TestCase $this->assertSame('1451602800', $this->formatter->asTimestamp($dateTime)); } - public function lengthDataProvider() + public static function lengthDataProvider(): array { return [ [ @@ -456,7 +456,7 @@ class FormatterTest extends TestCase $this->assertSame($expected, call_user_func_array([$this->formatter, 'asShortLength'], $arguments), 'Failed asserting that ' . $message); } - public function weightDataProvider() + public static function weightDataProvider(): array { return [ [ diff --git a/tests/framework/i18n/I18NTest.php b/tests/framework/i18n/I18NTest.php index 93cb751ea8..abfec405fb 100644 --- a/tests/framework/i18n/I18NTest.php +++ b/tests/framework/i18n/I18NTest.php @@ -230,7 +230,7 @@ class I18NTest extends TestCase Event::off(PhpMessageSource::class, PhpMessageSource::EVENT_MISSING_TRANSLATION); } - public function sourceLanguageDataProvider() + public static function sourceLanguageDataProvider(): array { return [ ['en-GB'], diff --git a/tests/framework/i18n/MessageFormatterTest.php b/tests/framework/i18n/MessageFormatterTest.php index 78358aa707..59fa3993a2 100644 --- a/tests/framework/i18n/MessageFormatterTest.php +++ b/tests/framework/i18n/MessageFormatterTest.php @@ -30,7 +30,7 @@ class MessageFormatterTest extends TestCase public const SUBJECT = 'сабж'; public const SUBJECT_VALUE = 'Answer to the Ultimate Question of Life, the Universe, and Everything'; - public function patterns() + public static function patterns(): array { return [ [ @@ -276,7 +276,7 @@ _MSG_ ]; } - public function parsePatterns() + public static function parsePatterns(): array { return [ [ diff --git a/tests/framework/log/LoggerTest.php b/tests/framework/log/LoggerTest.php index da77928138..5475a37fde 100644 --- a/tests/framework/log/LoggerTest.php +++ b/tests/framework/log/LoggerTest.php @@ -493,7 +493,7 @@ class LoggerTest extends TestCase $this->assertEquals([$fistCategory], $logger->getProfiling(['cat*'], ['category*'])); } - public function providerForNonProfilingMessages() + public static function providerForNonProfilingMessages(): array { return [ [Logger::LEVEL_ERROR], diff --git a/tests/framework/log/TargetTest.php b/tests/framework/log/TargetTest.php index 61e110ecbb..7728e9ec48 100644 --- a/tests/framework/log/TargetTest.php +++ b/tests/framework/log/TargetTest.php @@ -20,7 +20,7 @@ class TargetTest extends TestCase { public static $messages; - public function filters() + public static function filters(): array { return [ [[], ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']], diff --git a/tests/framework/mail/BaseMailerTest.php b/tests/framework/mail/BaseMailerTest.php index e3e364da33..f45da7e2db 100644 --- a/tests/framework/mail/BaseMailerTest.php +++ b/tests/framework/mail/BaseMailerTest.php @@ -216,7 +216,7 @@ class BaseMailerTest extends TestCase $this->assertEquals(strip_tags($htmlViewFileContent), $message->_textBody, 'Unable to render text by direct view!'); } - public function htmlAndPlainProvider() + public static function htmlAndPlainProvider(): array { return [ [ diff --git a/tests/framework/mutex/MutexTestTrait.php b/tests/framework/mutex/MutexTestTrait.php index 0110115011..52d93a9de1 100644 --- a/tests/framework/mutex/MutexTestTrait.php +++ b/tests/framework/mutex/MutexTestTrait.php @@ -107,7 +107,7 @@ trait MutexTestTrait $this->assertFalse($mutexOne->isAcquired('non existing')); } - public static function mutexDataProvider() + public static function mutexDataProvider(): array { $utf = <<<'UTF' 𝐘˛𝜄 ӏ𝕤 𝗮 𝔣𝖺𐑈𝝉, 𐑈ℯ𝔠u𝒓𝗲, 𝝰𝞹𝒹 𝖊𝘧𝒇𝗶𝕔𝖎ⅇπτ P𝘏𝙿 𝖿г𝖺m𝖾wσr𝐤. diff --git a/tests/framework/rbac/DbManagerTestCase.php b/tests/framework/rbac/DbManagerTestCase.php index 3a7b0d6e96..c43d5f9514 100644 --- a/tests/framework/rbac/DbManagerTestCase.php +++ b/tests/framework/rbac/DbManagerTestCase.php @@ -183,7 +183,7 @@ abstract class DbManagerTestCase extends ManagerTestCase $this->auth->assign($updatePost, $userId); } - public function emptyValuesProvider() + public static function emptyValuesProvider(): array { return [ [0, 0, true], diff --git a/tests/framework/rbac/ManagerTestCase.php b/tests/framework/rbac/ManagerTestCase.php index b2199b8dc6..19c71bcfac 100644 --- a/tests/framework/rbac/ManagerTestCase.php +++ b/tests/framework/rbac/ManagerTestCase.php @@ -466,7 +466,7 @@ abstract class ManagerTestCase extends TestCase $this->assertNotEmpty($this->auth->getRoles()); } - public function RBACItemsProvider() + public static function RBACItemsProvider(): array { return [ [Item::TYPE_ROLE], diff --git a/tests/framework/requirements/YiiRequirementCheckerTest.php b/tests/framework/requirements/YiiRequirementCheckerTest.php index c611a01863..0338ac6bf8 100644 --- a/tests/framework/requirements/YiiRequirementCheckerTest.php +++ b/tests/framework/requirements/YiiRequirementCheckerTest.php @@ -149,7 +149,7 @@ class YiiRequirementCheckerTest extends TestCase * Data provider for [[testGetByteSize()]]. * @return array */ - public function dataProviderGetByteSize() + public static function dataProviderGetByteSize(): array { return [ ['456', 456], @@ -179,7 +179,7 @@ class YiiRequirementCheckerTest extends TestCase * Data provider for [[testCompareByteSize()]] * @return array */ - public function dataProviderCompareByteSize() + public static function dataProviderCompareByteSize(): array { return [ ['2M', '2K', '>', true], diff --git a/tests/framework/rest/IndexActionTest.php b/tests/framework/rest/IndexActionTest.php index f88c2dbb8b..e56f37cf82 100644 --- a/tests/framework/rest/IndexActionTest.php +++ b/tests/framework/rest/IndexActionTest.php @@ -129,7 +129,7 @@ class IndexActionTest extends TestCase * Data provider for [[testPrepareDataProviderWithPaginationAndSorting()]]. * @return array test data */ - public function dataProviderTestPrepareDataProviderWithPaginationAndSorting() + public static function dataProviderTestPrepareDataProviderWithPaginationAndSorting(): array { return [ [ // Default config diff --git a/tests/framework/rest/SerializerTest.php b/tests/framework/rest/SerializerTest.php index 69a67dadcb..12dc546f91 100644 --- a/tests/framework/rest/SerializerTest.php +++ b/tests/framework/rest/SerializerTest.php @@ -285,7 +285,7 @@ class SerializerTest extends TestCase ], $serializer->serialize($model)); } - public function dataProviderSerializeDataProvider() + public static function dataProviderSerializeDataProvider(): array { return [ [ diff --git a/tests/framework/rest/UrlRuleTest.php b/tests/framework/rest/UrlRuleTest.php index 5557a24660..c41d744c3f 100644 --- a/tests/framework/rest/UrlRuleTest.php +++ b/tests/framework/rest/UrlRuleTest.php @@ -224,7 +224,7 @@ class UrlRuleTest extends TestCase * - first element is the route to create * - second element is the expected URL */ - public function createUrlDataProvider() + public static function createUrlDataProvider(): array { return [ // with pluralize @@ -415,7 +415,7 @@ class UrlRuleTest extends TestCase * - second element is the expected URL * - third element is the expected result of getCreateUrlStatus() method */ - public static function getCreateUrlStatusProvider() + public static function getCreateUrlStatusProvider(): array { return [ 'single controller' => [ diff --git a/tests/framework/validators/DateValidatorTest.php b/tests/framework/validators/DateValidatorTest.php index 78589e5bc1..57a567da83 100644 --- a/tests/framework/validators/DateValidatorTest.php +++ b/tests/framework/validators/DateValidatorTest.php @@ -236,7 +236,7 @@ class DateValidatorTest extends TestCase $this->assertFalse($model->hasErrors('attr_date')); } - public function provideTimezones() + public static function provideTimezones(): array { return [ ['UTC'], @@ -1074,7 +1074,7 @@ class DateValidatorTest extends TestCase $this->assertTrue($model->hasErrors('attr_date')); } - public function provideTestStrictDateFormatIntlFail() + public static function provideTestStrictDateFormatIntlFail(): array { return [ ['yyyy-MM-dd', '13-Mar-19', true], @@ -1111,7 +1111,7 @@ class DateValidatorTest extends TestCase $this->assertFalse($model->hasErrors('attr_date')); } - public function provideTestStrictDateFormatIntlPass() + public static function provideTestStrictDateFormatIntlPass(): array { return [ ['yyyy-MM-dd', '0013-03-19', true], @@ -1143,7 +1143,7 @@ class DateValidatorTest extends TestCase $this->assertTrue($model->hasErrors('attr_date')); } - public function provideTestStrictDateFormatPhpFail() + public static function provideTestStrictDateFormatPhpFail(): array { return [ ['php:Y-m-d', '13-Mar-19', true], @@ -1179,7 +1179,7 @@ class DateValidatorTest extends TestCase $this->assertFalse($model->hasErrors('attr_date')); } - public function provideTestStrictDateFormatPhpPass() + public static function provideTestStrictDateFormatPhpPass(): array { return [ ['php:Y-m-d', '0013-03-19', true], diff --git a/tests/framework/validators/EmailValidatorTest.php b/tests/framework/validators/EmailValidatorTest.php index 13e0d6e4d4..0c805f5f4d 100644 --- a/tests/framework/validators/EmailValidatorTest.php +++ b/tests/framework/validators/EmailValidatorTest.php @@ -144,7 +144,7 @@ class EmailValidatorTest extends TestCase $this->assertFalse($model->hasErrors('attr_email')); } - public function malformedAddressesProvider() + public static function malformedAddressesProvider(): array { return [ // this is the demo email used in the proof of concept of the exploit diff --git a/tests/framework/validators/FileValidatorTest.php b/tests/framework/validators/FileValidatorTest.php index 67ba98b659..c9753b0701 100644 --- a/tests/framework/validators/FileValidatorTest.php +++ b/tests/framework/validators/FileValidatorTest.php @@ -552,7 +552,7 @@ class FileValidatorTest extends TestCase $this->assertFalse($validator->validate($file)); } - public function validMimeTypes() + public static function validMimeTypes(): array { $validMimeTypes = array_filter([ ['test.svg', 'image/*', 'svg'], @@ -575,7 +575,7 @@ class FileValidatorTest extends TestCase return $validMimeTypes; } - public function invalidMimeTypes() + public static function invalidMimeTypes(): array { return [ ['test.txt', 'image/*', 'png, jpg'], @@ -684,7 +684,7 @@ class FileValidatorTest extends TestCase $this->assertEquals($expected, $validator->validate($file), sprintf('Mime type validate fail: "%s" / "%s"', $mask, $fileMimeType)); } - public function mimeTypeCaseInsensitive() + public static function mimeTypeCaseInsensitive(): array { return [ ['Image/*', 'image/jp2', true], diff --git a/tests/framework/validators/IpValidatorTest.php b/tests/framework/validators/IpValidatorTest.php index 6276e62d1e..577c4d4d1e 100644 --- a/tests/framework/validators/IpValidatorTest.php +++ b/tests/framework/validators/IpValidatorTest.php @@ -31,7 +31,7 @@ class IpValidatorTest extends TestCase new IpValidator(['ipv4' => false, 'ipv6' => false]); } - public function provideRangesForSubstitution() + public static function provideRangesForSubstitution(): array { return [ ['10.0.0.1', ['10.0.0.1']], @@ -65,7 +65,7 @@ class IpValidatorTest extends TestCase $this->assertFalse($validator->validate('babe::cafe')); } - public function provideBadIps() + public static function provideBadIps(): array { return [['not.an.ip'], [['what an array', '??']], [123456], [true], [false], ['bad:forSure']]; } diff --git a/tests/framework/web/AssetBundleTest.php b/tests/framework/web/AssetBundleTest.php index bd0e600bd4..f1e4bad481 100644 --- a/tests/framework/web/AssetBundleTest.php +++ b/tests/framework/web/AssetBundleTest.php @@ -263,7 +263,7 @@ EOF; $this->assertEqualsWithoutLE($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php')); } - public function positionProvider() + public static function positionProvider(): array { return [ [View::POS_HEAD, true], @@ -414,7 +414,7 @@ EOF; $this->assertEqualsWithoutLE($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php')); } - public function registerFileDataProvider() + public static function registerFileDataProvider(): array { return [ // JS files registration diff --git a/tests/framework/web/ErrorHandlerTest.php b/tests/framework/web/ErrorHandlerTest.php index b82ab726d9..fa4cfbdee6 100644 --- a/tests/framework/web/ErrorHandlerTest.php +++ b/tests/framework/web/ErrorHandlerTest.php @@ -129,7 +129,7 @@ Exception: yii\web\NotFoundHttpException', $out); $this->assertStringContainsString('', $out); } - public function dataHtmlEncode() + public static function dataHtmlEncode(): array { return [ [ diff --git a/tests/framework/web/JsonResponseFormatterTest.php b/tests/framework/web/JsonResponseFormatterTest.php index 6f6229729f..4e4fd41856 100644 --- a/tests/framework/web/JsonResponseFormatterTest.php +++ b/tests/framework/web/JsonResponseFormatterTest.php @@ -29,7 +29,7 @@ class JsonResponseFormatterTest extends FormatterTest return new JsonResponseFormatter($configuration); } - public function formatScalarDataProvider() + public static function formatScalarDataProvider(): array { return [ [1, 1], @@ -39,7 +39,7 @@ class JsonResponseFormatterTest extends FormatterTest ]; } - public function formatArrayDataProvider() + public static function formatArrayDataProvider(): array { return [ // input, json, pretty json @@ -76,7 +76,7 @@ class JsonResponseFormatterTest extends FormatterTest ]; } - public function formatObjectDataProvider() + public static function formatObjectDataProvider(): array { return [ [new Post(123, 'abc'), '{"id":123,"title":"abc"}'], @@ -91,7 +91,7 @@ class JsonResponseFormatterTest extends FormatterTest ]; } - public function formatTraversableObjectDataProvider() + public static function formatTraversableObjectDataProvider(): array { $postsStack = new SplStack(); $postsStack->push(new Post(915, 'record1')); @@ -102,14 +102,14 @@ class JsonResponseFormatterTest extends FormatterTest ]; } - public function formatModelDataProvider() + public static function formatModelDataProvider(): array { return [ [new ModelStub(['id' => 123, 'title' => 'abc', 'hidden' => 'hidden']), '{"id":123,"title":"abc"}'], ]; } - public function contentTypeGenerationDataProvider() + public static function contentTypeGenerationDataProvider(): array { return [ [ diff --git a/tests/framework/web/RequestTest.php b/tests/framework/web/RequestTest.php index 851443cb17..bfc61cf69c 100644 --- a/tests/framework/web/RequestTest.php +++ b/tests/framework/web/RequestTest.php @@ -389,7 +389,7 @@ class RequestTest extends TestCase $this->assertEquals($_GET, ['id' => 63]); } - public function getHostInfoDataProvider() + public static function getHostInfoDataProvider(): array { return [ // empty @@ -593,7 +593,7 @@ class RequestTest extends TestCase $this->assertNull($request->getServerPort()); } - public function isSecureServerDataProvider() + public static function isSecureServerDataProvider(): array { return [ [['HTTPS' => 1], true], @@ -721,7 +721,7 @@ class RequestTest extends TestCase $_SERVER = $original; } - public function isSecureServerWithoutTrustedHostDataProvider() + public static function isSecureServerWithoutTrustedHostDataProvider(): array { return [ // RFC 7239 forwarded header is not enabled @@ -760,7 +760,7 @@ class RequestTest extends TestCase $_SERVER = $original; } - public function getUserIPDataProvider() + public static function getUserIPDataProvider(): array { return [ [ @@ -938,7 +938,7 @@ class RequestTest extends TestCase $_SERVER = $original; } - public function getUserIPWithoutTruestHostDataProvider() + public static function getUserIPWithoutTruestHostDataProvider(): array { return [ // RFC 7239 forwarded is not enabled @@ -980,7 +980,7 @@ class RequestTest extends TestCase $_SERVER = $original; } - public function getMethodDataProvider() + public static function getMethodDataProvider(): array { return [ [ @@ -1014,7 +1014,7 @@ class RequestTest extends TestCase $_SERVER = $original; } - public function getIsAjaxDataProvider() + public static function getIsAjaxDataProvider(): array { return [ [ @@ -1046,7 +1046,7 @@ class RequestTest extends TestCase $_SERVER = $original; } - public function getIsPjaxDataProvider() + public static function getIsPjaxDataProvider(): array { return [ [ @@ -1090,7 +1090,7 @@ class RequestTest extends TestCase $this->assertNull($request->getOrigin()); } - public function httpAuthorizationHeadersProvider() + public static function httpAuthorizationHeadersProvider(): array { return [ ['not a base64 at all', [base64_decode('not a base64 at all'), null]], @@ -1169,7 +1169,7 @@ class RequestTest extends TestCase $this->assertSame('default', $request->getBodyParam('unexisting', 'default')); } - public function getBodyParamsDataProvider() + public static function getBodyParamsDataProvider(): array { return [ 'json' => ['application/json', '{"foo":"bar","baz":1}', ['foo' => 'bar', 'baz' => 1]], @@ -1193,7 +1193,7 @@ class RequestTest extends TestCase $this->assertSame($expected, $request->getBodyParams()); } - public function trustedHostAndInjectedXForwardedForDataProvider() + public static function trustedHostAndInjectedXForwardedForDataProvider(): array { return [ 'emptyIPs' => ['1.1.1.1', '', null, ['10.10.10.10'], '1.1.1.1'], @@ -1230,7 +1230,7 @@ class RequestTest extends TestCase $this->assertSame($expectedUserIp, $request->getUserIP()); } - public function trustedHostAndXForwardedPortDataProvider() + public static function trustedHostAndXForwardedPortDataProvider(): array { return [ 'defaultPlain' => ['1.1.1.1', 80, null, null, 80], @@ -1274,7 +1274,7 @@ class RequestTest extends TestCase $this->assertSame($expectedMethod, $request->getMethod()); } - public function alreadyResolvedIpDataProvider() + public static function alreadyResolvedIpDataProvider(): array { return [ 'resolvedXForwardedFor' => [ @@ -1317,7 +1317,7 @@ class RequestTest extends TestCase $this->assertSame($expectedIsSecureConnection, $request->isSecureConnection, 'Secure connection fail!'); } - public function parseForwardedHeaderDataProvider() + public static function parseForwardedHeaderDataProvider(): array { return [ [ diff --git a/tests/framework/web/ResponseTest.php b/tests/framework/web/ResponseTest.php index a9e695bbab..2d9f08037d 100644 --- a/tests/framework/web/ResponseTest.php +++ b/tests/framework/web/ResponseTest.php @@ -44,7 +44,7 @@ class ResponseTest extends TestCase $this->response = new Response(); } - public function rightRanges() + public static function rightRanges(): array { // TODO test more cases for range requests and check for rfc compatibility // https://tools.ietf.org/html/rfc2616 @@ -83,7 +83,7 @@ class ResponseTest extends TestCase $this->assertEquals((string)$length, $headers->get('Content-Length')); } - public function wrongRanges() + public static function wrongRanges(): array { // TODO test more cases for range requests and check for rfc compatibility // https://tools.ietf.org/html/rfc2616 @@ -213,7 +213,7 @@ class ResponseTest extends TestCase * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox * @return array */ - public function dataProviderAjaxRedirectInternetExplorer11() + public static function dataProviderAjaxRedirectInternetExplorer11(): array { return [ ['Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0', [301 => 301, 302 => 302]], // Firefox @@ -260,7 +260,7 @@ class ResponseTest extends TestCase static::assertEquals(200, $this->response->statusCode); } - public function dataProviderSetStatusCodeByException() + public static function dataProviderSetStatusCodeByException(): array { $data = [ [ @@ -303,7 +303,7 @@ class ResponseTest extends TestCase return $data; } - public function formatDataProvider() + public static function formatDataProvider(): array { return [ [Response::FORMAT_JSON, '{"value":1}'], @@ -415,7 +415,7 @@ class ResponseTest extends TestCase } } - public function cookiesTestProvider() + public static function cookiesTestProvider(): array { $expireInt = time() + 3600; $expireString = date('D, d-M-Y H:i:s', $expireInt) . ' GMT'; diff --git a/tests/framework/web/UrlManagerCreateUrlTest.php b/tests/framework/web/UrlManagerCreateUrlTest.php index 959c551558..a17c780d65 100644 --- a/tests/framework/web/UrlManagerCreateUrlTest.php +++ b/tests/framework/web/UrlManagerCreateUrlTest.php @@ -69,7 +69,7 @@ class UrlManagerCreateUrlTest extends TestCase return new UrlManager($config); } - public function variationsProvider() + public static function variationsProvider(): array { $baseUrlConfig = [ 'baseUrl' => '/test', @@ -521,7 +521,7 @@ class UrlManagerCreateUrlTest extends TestCase $assertations($manager); } - public function absolutePatternsVariations() + public static function absolutePatternsVariations(): array { $baseUrlConfig = [ 'baseUrl' => '/test', @@ -682,7 +682,7 @@ class UrlManagerCreateUrlTest extends TestCase $this->assertEquals($expected, $manager->createAbsoluteUrl($urlParams)); } - public function multipleHostsRulesDataProvider() + public static function multipleHostsRulesDataProvider(): array { return [ ['http://example.com'], diff --git a/tests/framework/web/UrlManagerParseUrlTest.php b/tests/framework/web/UrlManagerParseUrlTest.php index b4343c9dcd..9bdddeae0d 100644 --- a/tests/framework/web/UrlManagerParseUrlTest.php +++ b/tests/framework/web/UrlManagerParseUrlTest.php @@ -106,7 +106,7 @@ class UrlManagerParseUrlTest extends TestCase $this->assertFalse($manager->parseRequest($this->getRequest('module/site/index/'))); } - public function suffixProvider() + public static function suffixProvider(): array { return [ ['.html'], diff --git a/tests/framework/web/UrlManagerTest.php b/tests/framework/web/UrlManagerTest.php index 04726ea00e..c2506c8d7b 100644 --- a/tests/framework/web/UrlManagerTest.php +++ b/tests/framework/web/UrlManagerTest.php @@ -62,7 +62,7 @@ class UrlManagerTest extends TestCase * $showScriptName and $enableStrictParsing should have no effect in default format. * Passing these options ensures that. */ - public function ignoredOptionsProvider() + public static function ignoredOptionsProvider(): array { return [ [false, false], @@ -215,7 +215,7 @@ class UrlManagerTest extends TestCase /** * @return array provides different names for UrlManager::$routeParam */ - public function routeParamProvider() + public static function routeParamProvider(): array { return [ ['r'], // default value diff --git a/tests/framework/web/UrlRuleTest.php b/tests/framework/web/UrlRuleTest.php index bd851c7fc0..21d348da07 100644 --- a/tests/framework/web/UrlRuleTest.php +++ b/tests/framework/web/UrlRuleTest.php @@ -1355,7 +1355,7 @@ class UrlRuleTest extends TestCase * - third element is the expected URL * - fourth element is the expected result of getCreateUrlStatus() method */ - public static function getCreateUrlStatusProvider() + public static function getCreateUrlStatusProvider(): array { return [ 'route' => [ diff --git a/tests/framework/widgets/ActiveFieldTest.php b/tests/framework/widgets/ActiveFieldTest.php index fc13bd7964..cb48d3df87 100644 --- a/tests/framework/widgets/ActiveFieldTest.php +++ b/tests/framework/widgets/ActiveFieldTest.php @@ -266,7 +266,7 @@ EOT; $this->assertEquals($expectedValue, $actualValue); } - public function hintDataProvider() + public static function hintDataProvider(): array { return [ ['Hint Content', '
Hint Content
'], diff --git a/tests/framework/widgets/ListViewTest.php b/tests/framework/widgets/ListViewTest.php index 2e0420016e..6ae431a841 100644 --- a/tests/framework/widgets/ListViewTest.php +++ b/tests/framework/widgets/ListViewTest.php @@ -129,7 +129,7 @@ HTML, ); } - public function itemViewOptions() + public static function itemViewOptions(): array { return [ [ @@ -175,7 +175,7 @@ HTML, $this->assertEqualsWithoutLE($expected, $out); } - public function itemOptions() + public static function itemOptions(): array { return [ [ @@ -348,7 +348,7 @@ HTML, ', $out); } - public function providerForSummary() + public static function providerForSummary(): array { return [ 'empty' => ['', '