diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 68fac01..1b1e2d8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -31,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
- ['8.0', '8.1', '8.2', '8.3', '8.4']
+ ['8.1', '8.2', '8.3', '8.4', '8.5']
diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml
index a93390b..d2ef508 100644
--- a/.github/workflows/composer-require-checker.yml
+++ b/.github/workflows/composer-require-checker.yml
@@ -31,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
- ['8.1', '8.2', '8.3', '8.4']
+ ['8.1', '8.2', '8.3', '8.4', '8.5']
diff --git a/.github/workflows/rector-cs.yml b/.github/workflows/rector-cs.yml
new file mode 100644
index 0000000..b716daf
--- /dev/null
+++ b/.github/workflows/rector-cs.yml
@@ -0,0 +1,28 @@
+name: Rector + PHP CS Fixer
+
+on:
+ pull_request_target:
+ paths:
+ - 'src/**'
+ - 'config/**'
+ - 'tests/**'
+ - '.github/workflows/rector-cs.yml'
+ - 'composer.json'
+ - 'rector.php'
+ - '.php-cs-fixer.dist.php'
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ rector:
+ uses: yiisoft/actions/.github/workflows/rector-cs.yml@master
+ secrets:
+ token: ${{ secrets.YIISOFT_GITHUB_TOKEN }}
+ with:
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
+ php: '8.1'
diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml
deleted file mode 100644
index 5d6931d..0000000
--- a/.github/workflows/rector.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-on:
- pull_request_target:
- paths-ignore:
- - 'docs/**'
- - 'README.md'
- - 'CHANGELOG.md'
- - '.gitignore'
- - '.gitattributes'
- - 'infection.json.dist'
- - 'psalm.xml'
-
-name: rector
-
-jobs:
- rector:
- uses: yiisoft/actions/.github/workflows/rector.yml@master
- secrets:
- token: ${{ secrets.YIISOFT_GITHUB_TOKEN }}
- with:
- repository: ${{ github.event.pull_request.head.repo.full_name }}
- os: >-
- ['ubuntu-latest']
- php: >-
- ['8.4']
diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml
index 64b476e..6135d08 100644
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -30,12 +30,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
- ['8.1', '8.2', '8.3', '8.4']
- psalm80:
- uses: yiisoft/actions/.github/workflows/psalm.yml@master
- with:
- psalm-config: psalm80.xml
- os: >-
- ['ubuntu-latest']
- php: >-
- ['8.0']
+ ['8.1', '8.2', '8.3', '8.4', '8.5']
diff --git a/.gitignore b/.gitignore
index ffca5ff..5e58ce0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,7 @@ phpunit.phar
/phpunit.xml
# phpunit cache
.phpunit.result.cache
+
+# PHP CS Fixer
+/.php-cs-fixer.cache
+/.php-cs-fixer.php
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
new file mode 100644
index 0000000..2477e66
--- /dev/null
+++ b/.php-cs-fixer.dist.php
@@ -0,0 +1,21 @@
+in([
+ __DIR__ . '/src',
+ __DIR__ . '/tests',
+]);
+
+return ConfigBuilder::build()
+ ->setRiskyAllowed(true)
+ ->setParallelConfig(ParallelConfigFactory::detect())
+ ->setRules([
+ '@Yiisoft/Core' => true,
+ '@Yiisoft/Core:risky' => true,
+ ])
+ ->setFinder($finder);
diff --git a/.styleci.yml b/.styleci.yml
deleted file mode 100644
index 1ab379b..0000000
--- a/.styleci.yml
+++ /dev/null
@@ -1,85 +0,0 @@
-preset: psr12
-risky: true
-
-version: 8.1
-
-finder:
- exclude:
- - docs
- - vendor
-
-enabled:
- - alpha_ordered_traits
- - array_indentation
- - array_push
- - combine_consecutive_issets
- - combine_consecutive_unsets
- - combine_nested_dirname
- - declare_strict_types
- - dir_constant
- - fully_qualified_strict_types
- - function_to_constant
- - hash_to_slash_comment
- - is_null
- - logical_operators
- - magic_constant_casing
- - magic_method_casing
- - method_separation
- - modernize_types_casting
- - native_function_casing
- - native_function_type_declaration_casing
- - no_alias_functions
- - no_empty_comment
- - no_empty_phpdoc
- - no_empty_statement
- - no_extra_block_blank_lines
- - no_short_bool_cast
- - no_superfluous_elseif
- - no_unneeded_control_parentheses
- - no_unneeded_curly_braces
- - no_unneeded_final_method
- - no_unset_cast
- - no_unused_imports
- - no_unused_lambda_imports
- - no_useless_else
- - no_useless_return
- - normalize_index_brace
- - php_unit_dedicate_assert
- - php_unit_dedicate_assert_internal_type
- - php_unit_expectation
- - php_unit_mock
- - php_unit_mock_short_will_return
- - php_unit_namespaced
- - php_unit_no_expectation_annotation
- - phpdoc_no_empty_return
- - phpdoc_no_useless_inheritdoc
- - phpdoc_order
- - phpdoc_property
- - phpdoc_scalar
- - phpdoc_singular_inheritdoc
- - phpdoc_trim
- - phpdoc_trim_consecutive_blank_line_separation
- - phpdoc_type_to_var
- - phpdoc_types
- - phpdoc_types_order
- - print_to_echo
- - regular_callable_call
- - return_assignment
- - self_accessor
- - self_static_accessor
- - set_type_to_cast
- - short_array_syntax
- - short_list_syntax
- - simplified_if_return
- - single_quote
- - standardize_not_equals
- - ternary_to_null_coalescing
- - trailing_comma_in_multiline_array
- - unalign_double_arrow
- - unalign_equals
- - empty_loop_body_braces
- - integer_literal_case
- - union_type_without_spaces
-
-disabled:
- - function_declaration
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 25cd7b3..5abe3a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,9 @@
## 2.1.2 under development
-- no changes in this release.
+- Enh #105: Explicitly import classes, functions, and constants in "use" section (@rustamwin)
+- Chg #105: Raise the minimum PHP version to `8.1` (@rustamwin)
+- Chg #105: Change PHP constraint in `composer.json` to `8.1 - 8.5` (@rustamwin)
## 2.1.1 September 23, 2025
diff --git a/composer.json b/composer.json
index 34fb34d..4a8cbcf 100644
--- a/composer.json
+++ b/composer.json
@@ -27,7 +27,7 @@
}
],
"require": {
- "php": "^8.0",
+ "php": "8.1 - 8.5",
"yiisoft/aliases": "^3.0",
"yiisoft/cache": "^2.0|^3.0",
"yiisoft/html": "^2.5|^3.0",
@@ -35,12 +35,14 @@
"yiisoft/widget": "^2.0"
},
"require-dev": {
+ "friendsofphp/php-cs-fixer": "^3.92.5",
"maglnet/composer-require-checker": "^4.4",
"phpunit/phpunit": "^9.6.23",
"rector/rector": "^2.0.17",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23.6",
"vimeo/psalm": "^4.30|^5.26.1|^6.12",
+ "yiisoft/code-style": "^1.0",
"yiisoft/psr-dummy-provider": "^1.0.2",
"yiisoft/test-support": "^3.0.2"
},
@@ -55,6 +57,7 @@
}
},
"scripts": {
+ "cs-fix": "php-cs-fixer fix",
"test": "phpunit --testdox --no-interaction",
"test-watch": "phpunit-watcher watch"
},
diff --git a/psalm80.xml b/psalm80.xml
deleted file mode 100644
index d091d59..0000000
--- a/psalm80.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Alert.php b/src/Alert.php
index a837b81..191117a 100644
--- a/src/Alert.php
+++ b/src/Alert.php
@@ -15,6 +15,8 @@
use function strtr;
use function trim;
+use const PHP_EOL;
+
/**
* Alert renders an alert component.
*
@@ -472,8 +474,8 @@ public function render(): string
*/
private function renderButton(): string
{
- return PHP_EOL .
- Button::tag()
+ return PHP_EOL
+ . Button::tag()
->attributes($this->buttonAttributes)
->content($this->buttonLabel)
->encode(false)
@@ -486,13 +488,13 @@ private function renderButton(): string
*/
private function renderIcon(): string
{
- return PHP_EOL .
- Div::tag()
+ return PHP_EOL
+ . Div::tag()
->attributes($this->iconContainerAttributes)
->content(I::tag()->attributes($this->iconAttributes)->content($this->iconText)->render())
->encode(false)
- ->render() .
- PHP_EOL;
+ ->render()
+ . PHP_EOL;
}
/**
diff --git a/src/Block.php b/src/Block.php
index e739418..63279d8 100644
--- a/src/Block.php
+++ b/src/Block.php
@@ -46,14 +46,12 @@ final class Block extends Widget
private string $id = '';
private bool $renderInPlace = false;
- public function __construct(private WebView $webView)
- {
- }
+ public function __construct(private WebView $webView) {}
/**
* Starts recording a block.
*/
- public function begin(): string|null
+ public function begin(): ?string
{
parent::begin();
diff --git a/src/Breadcrumbs.php b/src/Breadcrumbs.php
index c0b5126..7621afe 100644
--- a/src/Breadcrumbs.php
+++ b/src/Breadcrumbs.php
@@ -14,6 +14,8 @@
use function is_string;
use function strtr;
+use const PHP_EOL;
+
/**
* Breadcrumbs displays a list of items indicating the position of the current page in the whole site hierarchy.
*
@@ -52,7 +54,7 @@ final class Breadcrumbs extends Widget
{
private string $activeItemTemplate = "
{link}\n";
private array $attributes = ['class' => 'breadcrumb'];
- private array|null $homeItem = ['label' => 'Home', 'url' => '/'];
+ private ?array $homeItem = ['label' => 'Home', 'url' => '/'];
private array $items = [];
private string $itemTemplate = "{link}\n";
private string $tag = 'ul';
@@ -204,7 +206,7 @@ public function render(): string
if ($item !== []) {
$items[] = $this->renderItem(
$item,
- isset($item['url']) ? $this->itemTemplate : $this->activeItemTemplate
+ isset($item['url']) ? $this->itemTemplate : $this->activeItemTemplate,
);
}
}
diff --git a/src/ContentDecorator.php b/src/ContentDecorator.php
index c669069..f77336a 100644
--- a/src/ContentDecorator.php
+++ b/src/ContentDecorator.php
@@ -34,9 +34,7 @@ final class ContentDecorator extends Widget
private array $parameters = [];
private string $viewFile = '';
- public function __construct(private Aliases $aliases, private WebView $webView)
- {
- }
+ public function __construct(private Aliases $aliases, private WebView $webView) {}
/**
* Returns a new instance with the specified parameters.
diff --git a/src/Dropdown.php b/src/Dropdown.php
index 14279d0..3f9648d 100644
--- a/src/Dropdown.php
+++ b/src/Dropdown.php
@@ -21,6 +21,8 @@
use function str_contains;
use function trim;
+use const PHP_EOL;
+
final class Dropdown extends Widget
{
private string $activeClass = 'active';
@@ -686,7 +688,7 @@ private function renderItemLink(
string $label,
string $link,
array $linkAttributes = [],
- array $itemContainerAttributes = []
+ array $itemContainerAttributes = [],
): string {
$linkAttributes['href'] = $link;
diff --git a/src/FragmentCache.php b/src/FragmentCache.php
index 977fd60..ed00af1 100644
--- a/src/FragmentCache.php
+++ b/src/FragmentCache.php
@@ -41,7 +41,7 @@
*/
final class FragmentCache extends Widget
{
- private Dependency|null $dependency = null;
+ private ?Dependency $dependency = null;
private string $id = '';
private int $ttl = 60;
/** @psalm-var string[] */
@@ -52,9 +52,7 @@ final class FragmentCache extends Widget
*/
private array $dynamicContents = [];
- public function __construct(private CacheInterface $cache)
- {
- }
+ public function __construct(private CacheInterface $cache) {}
/**
* Returns a new instance with the specified dynamic contents.
diff --git a/src/Helper/Normalizer.php b/src/Helper/Normalizer.php
index bc05333..637621b 100644
--- a/src/Helper/Normalizer.php
+++ b/src/Helper/Normalizer.php
@@ -9,6 +9,11 @@
use Yiisoft\Html\Tag\I;
use Yiisoft\Html\Tag\Span;
+use function array_key_exists;
+use function is_array;
+use function is_bool;
+use function is_string;
+
final class Normalizer
{
/**
@@ -57,7 +62,7 @@ public static function menu(
array $items,
string $currentPath,
bool $activateItems,
- array $iconContainerAttributes = []
+ array $iconContainerAttributes = [],
): array {
/**
* @psalm-var array[] $items
@@ -79,7 +84,7 @@ public static function menu(
$child,
$items[$i]['link'],
$currentPath,
- $activateItems
+ $activateItems,
);
$items[$i]['disabled'] = self::disabled($child);
$items[$i]['visible'] = self::visible($child);
@@ -102,7 +107,7 @@ public static function renderLabel(
string $icon,
array $iconAttributes,
string $iconClass,
- array $iconContainerAttributes
+ array $iconContainerAttributes,
): string {
$html = '';
diff --git a/src/Menu.php b/src/Menu.php
index be7efdf..704f2fc 100644
--- a/src/Menu.php
+++ b/src/Menu.php
@@ -19,6 +19,8 @@
use function strtr;
use function trim;
+use const PHP_EOL;
+
/**
* Menu displays a multi-level menu using nested HTML lists.
*
@@ -535,8 +537,8 @@ private function renderAfterContent(): string
throw new InvalidArgumentException('Tag name must be a string and cannot be empty.');
}
- return PHP_EOL .
- Html::normalTag($this->afterTag, $this->afterContent, $this->afterAttributes)
+ return PHP_EOL
+ . Html::normalTag($this->afterTag, $this->afterContent, $this->afterAttributes)
->encode(false)
->render();
}
@@ -740,9 +742,9 @@ private function renderMenu(array $items): string
return match ($this->container) {
false => $beforeContent . trim($content) . $afterContent,
- default => $beforeContent .
- Html::normalTag($this->tagName, $content, $attributes)->encode(false) .
- $afterContent,
+ default => $beforeContent
+ . Html::normalTag($this->tagName, $content, $attributes)->encode(false)
+ . $afterContent,
};
}
}
diff --git a/tests/Alert/AlertTest.php b/tests/Alert/AlertTest.php
index c498a61..60c778b 100644
--- a/tests/Alert/AlertTest.php
+++ b/tests/Alert/AlertTest.php
@@ -186,7 +186,7 @@ public function testIconAttributes(): void
->iconAttributes(['class' => 'tests-class'])
->id('w0-alert')
->layoutBody('{icon}{body}')
- ->render()
+ ->render(),
);
}
diff --git a/tests/Alert/Bootstrap5Test.php b/tests/Alert/Bootstrap5Test.php
index 9d73150..e101f78 100644
--- a/tests/Alert/Bootstrap5Test.php
+++ b/tests/Alert/Bootstrap5Test.php
@@ -13,6 +13,8 @@
use Yiisoft\Yii\Widgets\Tests\Support\Assert;
use Yiisoft\Yii\Widgets\Tests\Support\TestTrait;
+use const PHP_EOL;
+
/**
* @psalm-suppress PropertyNotSetInConstructor
*/
@@ -42,10 +44,10 @@ public function testAdditionalContent(): void
HTML,
Alert::widget()
->body(
- 'Aww yeah, you successfully read this important alert message. This example text is going to run ' .
- 'a bit longer so that you can see how spacing within an alert works with this kind of content.
' .
- PHP_EOL . '
' . PHP_EOL .
- 'Whenever you need to, be sure to use margin utilities to keep things nice and tidy
'
+ 'Aww yeah, you successfully read this important alert message. This example text is going to run '
+ . 'a bit longer so that you can see how spacing within an alert works with this kind of content.
'
+ . PHP_EOL . '
' . PHP_EOL
+ . 'Whenever you need to, be sure to use margin utilities to keep things nice and tidy
',
)
->buttonAttributes(['data-bs-dismiss' => 'alert', 'aria-label' => 'Close'])
->buttonClass('btn-close')
@@ -142,8 +144,8 @@ public function testLinkColor(): void
HTML,
Alert::widget()
->body(
- 'A simple primary alert with an example link.' .
- 'Give it a click if you like.'
+ 'A simple primary alert with an example link.'
+ . 'Give it a click if you like.',
)
->buttonAttributes(['data-bs-dismiss' => 'alert', 'aria-label' => 'Close'])
->buttonClass('float-right')
diff --git a/tests/Alert/TailwindTest.php b/tests/Alert/TailwindTest.php
index 32660f4..be74aca 100644
--- a/tests/Alert/TailwindTest.php
+++ b/tests/Alert/TailwindTest.php
@@ -39,8 +39,8 @@ public function testBanner(): void
HTML,
Alert::widget()
->body(
- 'Informational message
' .
- 'Some additional text to explain said message.
'
+ 'Informational message
'
+ . 'Some additional text to explain said message.
',
)
->bodyClass('align-middle inline-block mr-8')
->buttonClass('float-right px-4 py-3')
@@ -240,8 +240,8 @@ public function testTopAccentBorder(): void
Alert::widget()
->attributes(['id' => 'w0-alert'])
->body(
- 'Our privacy policy has changed
' .
- 'Make sure you know how these changes affect you.
'
+ 'Our privacy policy has changed
'
+ . 'Make sure you know how these changes affect you.
',
)
->bodyClass('align-middle inline-block flex-grow mr-8')
->bodyContainer(true)
diff --git a/tests/Breadcrumbs/BreadcrumbsTest.php b/tests/Breadcrumbs/BreadcrumbsTest.php
index 8ea96bd..8f18c38 100644
--- a/tests/Breadcrumbs/BreadcrumbsTest.php
+++ b/tests/Breadcrumbs/BreadcrumbsTest.php
@@ -39,7 +39,7 @@ public function testAttributes(): void
->attributes(['class' => 'breadcrumb external'])
->homeItem(null)
->items(['label' => 'My Home Page', 'url' => 'http://my.example.com/yii2/link/page'])
- ->render()
+ ->render(),
);
}
@@ -120,7 +120,7 @@ public function testItemsWithTemplate(): void
[
['label' => 'Link', 'url' => 'https://my.example.com/yii/link/page'],
['label' => 'Text', 'template' => "{link}\n"],
- ]
+ ],
)
->render(),
);
@@ -141,7 +141,7 @@ public function testRenderItemLabelOnlyEncodeLabelFalse(): void
->homeItem(null)
->items([['label' => 'My-
Test-Label', 'encode' => false]]) // encode label false
->tag('')
- ->render()
+ ->render(),
);
}
@@ -160,7 +160,7 @@ public function testRenderItemLabelOnlyEncodeLabelTrue(): void
->homeItem(null)
->items(['label' => 'My-
Test-Label'])
->tag('')
- ->render()
+ ->render(),
);
}
diff --git a/tests/Dropdown/Bootstrap5Test.php b/tests/Dropdown/Bootstrap5Test.php
index 0a64e21..12c5c07 100644
--- a/tests/Dropdown/Bootstrap5Test.php
+++ b/tests/Dropdown/Bootstrap5Test.php
@@ -65,9 +65,9 @@ public function testHeaders(): void
['label' => 'Another action', 'link' => '#'],
],
],
- ]
+ ],
)
- ->render()
+ ->render(),
);
}
@@ -128,11 +128,11 @@ public function testSplit(): void
['label' => 'Separated link', 'link' => '#'],
],
],
- ]
+ ],
)
->toggleType('link')
->toggleType('split')
- ->render()
+ ->render(),
);
}
@@ -186,11 +186,11 @@ public function testSplitDropend(): void
['label' => 'Separated link', 'link' => '#'],
],
],
- ]
+ ],
)
->toggleType('link')
->toggleType('split')
- ->render()
+ ->render(),
);
}
@@ -244,11 +244,11 @@ public function testSplitDropStart(): void
['label' => 'Separated link', 'link' => '#'],
],
],
- ]
+ ],
)
->toggleType('link')
->toggleType('split')
- ->render()
+ ->render(),
);
}
@@ -302,11 +302,11 @@ public function testSplitDropup(): void
['label' => 'Separated link', 'link' => '#'],
],
],
- ]
+ ],
)
->toggleType('link')
->toggleType('split')
- ->render()
+ ->render(),
);
}
@@ -360,10 +360,10 @@ public function testSplitSizingWithLargeButton(): void
['label' => 'Separated link', 'link' => '#'],
],
],
- ]
+ ],
)
->toggleType('split')
- ->render()
+ ->render(),
);
}
@@ -417,10 +417,10 @@ public function testSplitSizingWithSmallButton(): void
['label' => 'Separated link', 'link' => '#'],
],
],
- ]
+ ],
)
->toggleType('split')
- ->render()
+ ->render(),
);
}
}
diff --git a/tests/Dropdown/DropdownTest.php b/tests/Dropdown/DropdownTest.php
index 4cfbbb7..cdc355f 100644
--- a/tests/Dropdown/DropdownTest.php
+++ b/tests/Dropdown/DropdownTest.php
@@ -342,7 +342,7 @@ public function testItemsIconAttributes(): void
['label' => 'Home', 'link' => '/active', 'iconAttributes' => ['class' => 'bi bi-house']],
['label' => 'Contact', 'link' => '#', 'iconAttributes' => ['class' => 'bi bi-envelope']],
['label' => 'Login', 'link' => '#', 'iconAttributes' => ['class' => 'bi bi-lock']],
- ]
+ ],
)->render(),
);
}
@@ -475,7 +475,7 @@ public function testItemsVisible(): void
['label' => 'Black & White'],
['label' => 'Red & Yellow', 'visible' => false],
['label' => 'Green & Blue', 'visible' => true],
- ]
+ ],
)
->render(),
);
diff --git a/tests/Dropdown/ExceptionTest.php b/tests/Dropdown/ExceptionTest.php
index 3b0ef10..f2553a2 100644
--- a/tests/Dropdown/ExceptionTest.php
+++ b/tests/Dropdown/ExceptionTest.php
@@ -58,7 +58,7 @@ public function testHeaderTag(): void
['label' => 'Another action', 'link' => '#'],
],
],
- ]
+ ],
)
->render();
}
@@ -131,7 +131,7 @@ public function testItemsContainerTag(): void
['label' => 'Separated link', 'link' => '#'],
],
],
- ]
+ ],
)
->render();
}
diff --git a/tests/FragmentCache/FragmentCacheTest.php b/tests/FragmentCache/FragmentCacheTest.php
index ee9a2b4..dd6d680 100644
--- a/tests/FragmentCache/FragmentCacheTest.php
+++ b/tests/FragmentCache/FragmentCacheTest.php
@@ -65,7 +65,7 @@ public function testSingleDynamicFragment(): void
for ($counter = 0; $counter < 42; $counter++) {
$dynamicContent = new DynamicContent(
'dynamic-test',
- static fn ($params) => (string) $params['counter'],
+ static fn($params) => (string) $params['counter'],
['counter' => $counter],
);
@@ -91,12 +91,12 @@ public function testMultipleDynamicFragments(): void
for ($counter = 0; $counter < 42; $counter++) {
$dynamicContent1 = new DynamicContent(
'dynamic-test-1',
- static fn ($params) => md5((string) $params['counter']),
+ static fn($params) => md5((string) $params['counter']),
['counter' => $counter],
);
$dynamicContent2 = new DynamicContent(
'dynamic-test-2',
- static fn ($params) => (string) $params['counter'],
+ static fn($params) => (string) $params['counter'],
['counter' => $counter],
);
@@ -132,17 +132,17 @@ public function testNestedDynamicFragments(): void
for ($counter = 0; $counter < 42; $counter++) {
$dynamicContent1 = new DynamicContent(
'dynamic-test-1',
- static fn ($params) => md5((string) $params['counter']),
+ static fn($params) => md5((string) $params['counter']),
['counter' => $counter],
);
$dynamicContent2 = new DynamicContent(
'dynamic-test-2',
- static fn ($params) => sha1((string) $params['counter']),
+ static fn($params) => sha1((string) $params['counter']),
['counter' => $counter],
);
$dynamicContent3 = new DynamicContent(
'dynamic-test-3',
- static fn ($params) => (string) ($params['counter'] + 1),
+ static fn($params) => (string) ($params['counter'] + 1),
['counter' => $counter],
);
@@ -168,7 +168,6 @@ public function testNestedDynamicFragments(): void
$counter + 1,
);
-
$this->assertSame($expectedContent, $content);
}
}
@@ -181,7 +180,7 @@ public function testNestedDynamicFragments(): void
*/
public function testVariations(): void
{
- $this->setOutputCallback(static fn () => null);
+ $this->setOutputCallback(static fn() => null);
FragmentCache::widget()->id($id = 'test')->variations($variation = 'ru')->begin();
echo 'cached fragment';
@@ -223,7 +222,7 @@ public function testVariations(): void
private function hasCache(string $id, ?string $variation = null): bool
{
$key = (new CacheKeyNormalizer())->normalize(
- array_merge([CachedContent::class, $id], (array) ($variation ?? []))
+ array_merge([CachedContent::class, $id], (array) ($variation ?? [])),
);
return $this->cache->psr()->has($key);
diff --git a/tests/FragmentCache/ImmutableTest.php b/tests/FragmentCache/ImmutableTest.php
index a180985..64cfc69 100644
--- a/tests/FragmentCache/ImmutableTest.php
+++ b/tests/FragmentCache/ImmutableTest.php
@@ -33,7 +33,7 @@ public function testImmutable(): void
$this->assertNotSame($widget, $widget->id(''));
$this->assertNotSame($widget, $widget->ttl(3600));
$this->assertNotSame($widget, $widget->dependency(new TagDependency('test')));
- $this->assertNotSame($widget, $widget->dynamicContents(new DynamicContent('test', fn (): string => 'test')));
+ $this->assertNotSame($widget, $widget->dynamicContents(new DynamicContent('test', fn(): string => 'test')));
$this->assertNotSame($widget, $widget->variations(''));
}
}
diff --git a/tests/Menu/MenuTest.php b/tests/Menu/MenuTest.php
index ce0d9fe..331dcc8 100644
--- a/tests/Menu/MenuTest.php
+++ b/tests/Menu/MenuTest.php
@@ -283,7 +283,7 @@ public function testDropdown(): void
],
['label' => 'Link', 'link' => '#'],
['label' => 'Disabled', 'link' => '#', 'disabled' => true],
- ]
+ ],
)
->render(),
);
@@ -334,7 +334,7 @@ public function testDropdownContainerClass(): void
],
['label' => 'Link', 'link' => '#'],
['label' => 'Disabled', 'link' => '#', 'disabled' => true],
- ]
+ ],
)
->render(),
);
@@ -384,7 +384,7 @@ public function testDropdownDefinitions(): void
],
'toggleClass()' => ['dropdown-toggle'],
'toggleType()' => ['link'],
- ]
+ ],
)
->items(
[
@@ -402,7 +402,7 @@ public function testDropdownDefinitions(): void
],
['label' => 'Link', 'link' => '#'],
['label' => 'Disabled', 'link' => '#', 'disabled' => true],
- ]
+ ],
)
->render(),
);
diff --git a/tests/Support/TestTrait.php b/tests/Support/TestTrait.php
index 374ad22..2e16fa7 100644
--- a/tests/Support/TestTrait.php
+++ b/tests/Support/TestTrait.php
@@ -27,7 +27,7 @@ protected function setUp(): void
Aliases::class => new Aliases(['@public' => __DIR__]),
CacheInterface::class => new Cache(new MemorySimpleCache()),
WebView::class => new WebView(__DIR__ . '/public/view', new SimpleEventDispatcher()),
- ]
+ ],
);
WidgetFactory::initialize($container, []);
@@ -39,6 +39,4 @@ protected function setUp(): void
namespace Yiisoft\Html;
-function hrtime(bool $getAsNumber = false): void
-{
-}
+function hrtime(bool $getAsNumber = false): void {}