' => 'site/index',
@@ -471,13 +490,15 @@ class UrlManagerCreateUrlTest extends TestCase
* with empty pattern.
*
* @dataProvider variationsProvider
+ *
* @see https://github.com/yiisoft/yii2/issues/6717
- * @param string $method
- * @param bool $showScriptName
- * @param string $prefix
- * @param array $config
+ *
+ * @param string $method The method.
+ * @param bool $showScriptName Whether to show script name.
+ * @param string $prefix The prefix.
+ * @param array $config The config.
*/
- public function testWithEmptyPattern($method, $showScriptName, $prefix, $config)
+ public function testWithEmptyPattern(string $method, bool $showScriptName, string $prefix, array $config): void
{
$assertations = function ($manager) use ($method, $prefix) {
// match first rule
@@ -523,7 +544,7 @@ class UrlManagerCreateUrlTest extends TestCase
}
- public static function absolutePatternsVariations()
+ public static function absolutePatternsVariations(): array
{
$baseUrlConfig = [
'baseUrl' => '/test',
@@ -543,12 +564,14 @@ class UrlManagerCreateUrlTest extends TestCase
/**
* Test rules that have host info in the patterns.
+ *
* @dataProvider absolutePatternsVariations
- * @param bool $showScriptName
- * @param string $prefix
- * @param array $config
+ *
+ * @param bool $showScriptName Whether to show script name in URL.
+ * @param string $prefix The expected URL prefix.
+ * @param array $config The URL manager config.
*/
- public function testAbsolutePatterns($showScriptName, $prefix, $config)
+ public function testAbsolutePatterns(bool $showScriptName, string $prefix, array $config): void
{
$config['rules'] = [
[
@@ -603,13 +626,16 @@ class UrlManagerCreateUrlTest extends TestCase
/**
* Test rules that have host info in the patterns, that are protocol relative.
+ *
* @dataProvider absolutePatternsVariations
+ *
* @see https://github.com/yiisoft/yii2/issues/12691
- * @param bool $showScriptName
- * @param string $prefix
- * @param array $config
+ *
+ * @param bool $showScriptName Whether to show script name in URL.
+ * @param string $prefix The expected URL prefix.
+ * @param array $config The URL manager config.
*/
- public function testProtocolRelativeAbsolutePattern($showScriptName, $prefix, $config)
+ public function testProtocolRelativeAbsolutePattern(bool $showScriptName, string $prefix, array $config): void
{
$config['rules'] = [
[
@@ -684,7 +710,7 @@ class UrlManagerCreateUrlTest extends TestCase
$this->assertEquals($expected, $manager->createAbsoluteUrl($urlParams));
}
- public static function multipleHostsRulesDataProvider()
+ public static function multipleHostsRulesDataProvider(): array
{
return [
['http://example.com'],
@@ -698,10 +724,12 @@ class UrlManagerCreateUrlTest extends TestCase
* Test matching of Url rules dependent on the current host info.
*
* @dataProvider multipleHostsRulesDataProvider
+ *
* @see https://github.com/yiisoft/yii2/issues/7948
- * @param string $host
+ *
+ * @param string $host The host info.
*/
- public function testMultipleHostsRules($host)
+ public function testMultipleHostsRules(string $host): void
{
$manager = new UrlManager([
'enablePrettyUrl' => true,
diff --git a/tests/framework/web/UrlManagerParseUrlTest.php b/tests/framework/web/UrlManagerParseUrlTest.php
index 8588676a7d..f384e806fb 100644
--- a/tests/framework/web/UrlManagerParseUrlTest.php
+++ b/tests/framework/web/UrlManagerParseUrlTest.php
@@ -45,7 +45,7 @@ use yiiunit\TestCase;
*/
class UrlManagerParseUrlTest extends TestCase
{
- protected function getUrlManager($config = [])
+ protected function getUrlManager(array $config = []): UrlManager
{
// in this test class, all tests have enablePrettyUrl enabled.
$config['enablePrettyUrl'] = true;
@@ -57,7 +57,7 @@ class UrlManagerParseUrlTest extends TestCase
], $config));
}
- protected function getRequest($pathInfo, $hostInfo = 'http://www.example.com', $method = 'GET', $config = [])
+ protected function getRequest($pathInfo, $hostInfo = 'http://www.example.com', $method = 'GET', $config = []): Request
{
$config['pathInfo'] = $pathInfo;
$config['hostInfo'] = $hostInfo;
@@ -71,7 +71,7 @@ class UrlManagerParseUrlTest extends TestCase
parent::tearDown();
}
- public function testWithoutRules()
+ public function testWithoutRules(): void
{
$manager = $this->getUrlManager();
@@ -89,7 +89,7 @@ class UrlManagerParseUrlTest extends TestCase
$this->assertEquals(['module/site/index/', []], $result);
}
- public function testWithoutRulesStrict()
+ public function testWithoutRulesStrict(): void
{
$manager = $this->getUrlManager();
$manager->enableStrictParsing = true;
@@ -104,7 +104,7 @@ class UrlManagerParseUrlTest extends TestCase
$this->assertFalse($manager->parseRequest($this->getRequest('module/site/index/')));
}
- public static function suffixProvider()
+ public static function suffixProvider(): array
{
return [
['.html'],
@@ -114,9 +114,10 @@ class UrlManagerParseUrlTest extends TestCase
/**
* @dataProvider suffixProvider
- * @param string $suffix
+ *
+ * @param string $suffix The URL suffix.
*/
- public function testWithoutRulesWithSuffix($suffix)
+ public function testWithoutRulesWithSuffix(string $suffix): void
{
$manager = $this->getUrlManager(['suffix' => $suffix]);
@@ -201,9 +202,10 @@ class UrlManagerParseUrlTest extends TestCase
/**
* @dataProvider suffixProvider
- * @param string $suffix
+ *
+ * @param string $suffix The URL suffix.
*/
- public function testSimpleRulesWithSuffix($suffix)
+ public function testSimpleRulesWithSuffix(string $suffix): void
{
$config = [
'rules' => [
@@ -246,9 +248,10 @@ class UrlManagerParseUrlTest extends TestCase
/**
* @dataProvider suffixProvider
- * @param string $suffix
+ *
+ * @param string $suffix The URL suffix.
*/
- public function testSimpleRulesWithSuffixStrict($suffix)
+ public function testSimpleRulesWithSuffixStrict(string $suffix): void
{
$config = [
'rules' => [
diff --git a/tests/framework/web/UrlManagerTest.php b/tests/framework/web/UrlManagerTest.php
index 6735ad991f..1c2d72ca03 100644
--- a/tests/framework/web/UrlManagerTest.php
+++ b/tests/framework/web/UrlManagerTest.php
@@ -32,7 +32,7 @@ use yiiunit\TestCase;
*/
class UrlManagerTest extends TestCase
{
- protected function getUrlManager($config = [], $showScriptName = true, $enableStrictParsing = false)
+ protected function getUrlManager(array $config = [], bool $showScriptName = true, bool $enableStrictParsing = false)
{
// in this test class, all tests have enablePrettyUrl disabled.
$config['enablePrettyUrl'] = false;
@@ -61,7 +61,7 @@ class UrlManagerTest extends TestCase
* $showScriptName and $enableStrictParsing should have no effect in default format.
* Passing these options ensures that.
*/
- public static function ignoredOptionsProvider()
+ public static function ignoredOptionsProvider(): array
{
return [
[false, false],
@@ -73,10 +73,11 @@ class UrlManagerTest extends TestCase
/**
* @dataProvider ignoredOptionsProvider
- * @param bool $showScriptName
- * @param bool $enableStrictParsing
+ *
+ * @param bool $showScriptName Whether to show script name in URL.
+ * @param bool $enableStrictParsing Whether to enable strict parsing.
*/
- public function testCreateUrlSimple($showScriptName, $enableStrictParsing)
+ public function testCreateUrlSimple(bool $showScriptName, bool $enableStrictParsing): void
{
// default setting with '/' as base url
$manager = $this->getUrlManager([], $showScriptName, $enableStrictParsing);
@@ -98,10 +99,11 @@ class UrlManagerTest extends TestCase
/**
* @dataProvider ignoredOptionsProvider
- * @param bool $showScriptName
- * @param bool $enableStrictParsing
+ *
+ * @param bool $showScriptName Whether to show script name in URL.
+ * @param bool $enableStrictParsing Whether to enable strict parsing.
*/
- public function testCreateUrlWithParams($showScriptName, $enableStrictParsing)
+ public function testCreateUrlWithParams(bool $showScriptName, bool $enableStrictParsing): void
{
// default setting with '/' as base url
$manager = $this->getUrlManager([], $showScriptName, $enableStrictParsing);
@@ -121,10 +123,11 @@ class UrlManagerTest extends TestCase
* @dataProvider ignoredOptionsProvider
*
* @see https://github.com/yiisoft/yii2/pull/9596
- * @param bool $showScriptName
- * @param bool $enableStrictParsing
+ *
+ * @param bool $showScriptName Whether to show script name in URL.
+ * @param bool $enableStrictParsing Whether to enable strict parsing.
*/
- public function testCreateUrlWithAnchor($showScriptName, $enableStrictParsing)
+ public function testCreateUrlWithAnchor(bool $showScriptName, bool $enableStrictParsing): void
{
// default setting with '/' as base url
$manager = $this->getUrlManager([], $showScriptName, $enableStrictParsing);
@@ -146,10 +149,11 @@ class UrlManagerTest extends TestCase
/**
* @dataProvider ignoredOptionsProvider
- * @param bool $showScriptName
- * @param bool $enableStrictParsing
+ *
+ * @param bool $showScriptName Whether to show script name in URL.
+ * @param bool $enableStrictParsing Whether to enable strict parsing.
*/
- public function testCreateAbsoluteUrl($showScriptName, $enableStrictParsing)
+ public function testCreateAbsoluteUrl(bool $showScriptName, bool $enableStrictParsing): void
{
$manager = $this->getUrlManager([], $showScriptName, $enableStrictParsing);
$url = $manager->createAbsoluteUrl('post/view');
@@ -193,11 +197,13 @@ class UrlManagerTest extends TestCase
/**
* Test normalisation of different routes.
+ *
* @dataProvider ignoredOptionsProvider
- * @param bool $showScriptName
- * @param bool $enableStrictParsing
+ *
+ * @param bool $showScriptName Whether to show script name in URL.
+ * @param bool $enableStrictParsing Whether to enable strict parsing.
*/
- public function testCreateUrlRouteVariants($showScriptName, $enableStrictParsing)
+ public function testCreateUrlRouteVariants(bool $showScriptName, bool $enableStrictParsing): void
{
// default setting with '/' as base url
$manager = $this->getUrlManager([], $showScriptName, $enableStrictParsing);
@@ -215,7 +221,7 @@ class UrlManagerTest extends TestCase
/**
* @return array provides different names for UrlManager::$routeParam
*/
- public static function routeParamProvider()
+ public static function routeParamProvider(): array
{
return [
['r'], // default value
@@ -226,9 +232,10 @@ class UrlManagerTest extends TestCase
/**
* @dataProvider routeParamProvider
- * @param string $routeParam
+ *
+ * @param string $routeParam The name of the route parameter.
*/
- public function testParseRequest($routeParam)
+ public function testParseRequest(string $routeParam): void
{
$manager = $this->getUrlManager(['routeParam' => $routeParam]);
$request = new Request();
diff --git a/tests/framework/web/UrlRuleTest.php b/tests/framework/web/UrlRuleTest.php
index 03f4b9f53d..cb1c035b42 100644
--- a/tests/framework/web/UrlRuleTest.php
+++ b/tests/framework/web/UrlRuleTest.php
@@ -1293,10 +1293,11 @@ class UrlRuleTest extends TestCase
/**
* @dataProvider getCreateUrlStatusProvider
- * @param array $config
- * @param array $tests
+ *
+ * @param array $config UrlRule config.
+ * @param array $tests Array of tests.
*/
- public function testGetCreateUrlStatus($config, $tests)
+ public function testGetCreateUrlStatus(array $config, array $tests): void
{
foreach ($tests as $test) {
list($route, $params, $expected, $status) = $test;
@@ -1329,7 +1330,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 a9b3bc6414..3f001e0295 100644
--- a/tests/framework/widgets/ActiveFieldTest.php
+++ b/tests/framework/widgets/ActiveFieldTest.php
@@ -262,7 +262,7 @@ EOT;
$this->assertEquals($expectedValue, $actualValue);
}
- public static function hintDataProvider()
+ public static function hintDataProvider(): array
{
return [
['Hint Content', 'Hint Content
'],
@@ -273,10 +273,11 @@ EOT;
/**
* @dataProvider hintDataProvider
- * @param mixed $hint
- * @param string $expectedHtml
+ *
+ * @param mixed $hint The hint content.
+ * @param string $expectedHtml The expected HTML.
*/
- public function testHint($hint, $expectedHtml)
+ public function testHint(mixed $hint, string $expectedHtml): void
{
$this->activeField->hint($hint);
diff --git a/tests/framework/widgets/ListViewTest.php b/tests/framework/widgets/ListViewTest.php
index 2c007b1877..d0ad95fb2f 100644
--- a/tests/framework/widgets/ListViewTest.php
+++ b/tests/framework/widgets/ListViewTest.php
@@ -155,10 +155,11 @@ HTML
/**
* @dataProvider itemViewOptions
- * @param mixed $itemView
- * @param string $expected
+ *
+ * @param mixed $itemView The item view to be used.
+ * @param string $expected The expected result.
*/
- public function testItemViewOptions($itemView, $expected)
+ public function testItemViewOptions(mixed $itemView, string $expected): void
{
ob_start();
$this->getListView(['itemView' => $itemView])->run();
@@ -167,7 +168,7 @@ HTML
$this->assertEqualsWithoutLE($expected, $out);
}
- public static function itemOptions()
+ public static function itemOptions(): array
{
return [
[
@@ -201,10 +202,11 @@ HTML
/**
* @dataProvider itemOptions
- * @param mixed $itemOptions
- * @param string $expected
+ *
+ * @param mixed $itemOptions The item options.
+ * @param string $expected The expected result.
*/
- public function testItemOptions($itemOptions, $expected)
+ public function testItemOptions(mixed $itemOptions, string $expected): void
{
ob_start();
$this->getListView(['itemOptions' => $itemOptions])->run();
@@ -272,7 +274,7 @@ HTML
(new ListView())->run();
}
- public static function providerForNoSorter()
+ public static function providerForNoSorter(): array
{
return [
'no sort attributes' => [[]],
@@ -282,8 +284,10 @@ HTML
/**
* @dataProvider providerForNoSorter
+ *
+ * @param array $additionalConfig Additional configuration for the list view.
*/
- public function testRenderNoSorter($additionalConfig)
+ public function testRenderNoSorter(array $additionalConfig): void
{
$config = array_merge(['layout' => '{sorter}'], $additionalConfig);
@@ -339,7 +343,7 @@ HTML
', $out);
}
- public static function providerForSummary()
+ public static function providerForSummary(): array
{
return [
'empty' => ['', '
@@ -357,8 +361,11 @@ HTML
/**
* @dataProvider providerForSummary
+ *
+ * @param string $summary Summary template.
+ * @param string $result Expected result.
*/
- public function testRenderSummaryWhenSummaryIsCustom($summary, $result)
+ public function testRenderSummaryWhenSummaryIsCustom(string $summary, string $result): void
{
ob_start();
$this->getListView(['summary' => $summary])->run();