Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
2 changes: 1 addition & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
28 changes: 28 additions & 0 deletions .github/workflows/rector-cs.yml
Original file line number Diff line number Diff line change
@@ -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'
24 changes: 0 additions & 24 deletions .github/workflows/rector.yml

This file was deleted.

10 changes: 1 addition & 9 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ phpunit.phar
/phpunit.xml
# phpunit cache
.phpunit.result.cache

# PHP CS Fixer
/.php-cs-fixer.cache
/.php-cs-fixer.php
21 changes: 21 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
use Yiisoft\CodeStyle\ConfigBuilder;

$finder = (new Finder())->in([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

return ConfigBuilder::build()
->setRiskyAllowed(true)
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
'@Yiisoft/Core' => true,
'@Yiisoft/Core:risky' => true,
])
->setFinder($finder);
85 changes: 0 additions & 85 deletions .styleci.yml

This file was deleted.

4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,22 @@
}
],
"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",
"yiisoft/view": "10 - 12",
"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"
},
Expand All @@ -55,6 +57,7 @@
}
},
"scripts": {
"cs-fix": "php-cs-fixer fix",
"test": "phpunit --testdox --no-interaction",
"test-watch": "phpunit-watcher watch"
},
Expand Down
19 changes: 0 additions & 19 deletions psalm80.xml

This file was deleted.

14 changes: 8 additions & 6 deletions src/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use function strtr;
use function trim;

use const PHP_EOL;

/**
* Alert renders an alert component.
*
Expand Down Expand Up @@ -134,7 +136,7 @@
*/
public function bodyContainerClass(string $value): self
{
$new = clone $this;

Check warning on line 139 in src/Alert.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": @@ @@ */ public function bodyContainerClass(string $value): self { - $new = clone $this; + $new = $this; Html::addCssClass($new->bodyContainerAttributes, $value); return $new;
Html::addCssClass($new->bodyContainerAttributes, $value);

return $new;
Expand Down Expand Up @@ -472,8 +474,8 @@
*/
private function renderButton(): string
{
return PHP_EOL .
Button::tag()
return PHP_EOL
. Button::tag()
->attributes($this->buttonAttributes)
->content($this->buttonLabel)
->encode(false)
Expand All @@ -486,13 +488,13 @@
*/
private function renderIcon(): string
{
return PHP_EOL .
Div::tag()
return PHP_EOL

Check warning on line 491 in src/Alert.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ */ private function renderIcon(): string { - return PHP_EOL - . Div::tag() - ->attributes($this->iconContainerAttributes) - ->content(I::tag()->attributes($this->iconAttributes)->content($this->iconText)->render()) - ->encode(false) - ->render() + return Div::tag() + ->attributes($this->iconContainerAttributes) + ->content(I::tag()->attributes($this->iconAttributes)->content($this->iconText)->render()) + ->encode(false) + ->render() . 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;
}

/**
Expand All @@ -510,7 +512,7 @@
*/
private function renderHeader(): string
{
return Html::normalTag($this->headerTag, $this->header, $this->headerAttributes)->encode(false)->render();

Check warning on line 515 in src/Alert.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "FalseValue": @@ @@ */ private function renderHeader(): string { - return Html::normalTag($this->headerTag, $this->header, $this->headerAttributes)->encode(false)->render(); + return Html::normalTag($this->headerTag, $this->header, $this->headerAttributes)->encode(true)->render(); } /**
}

/**
Expand All @@ -518,7 +520,7 @@
*/
private function renderHeaderContainer(array $parts): string
{
$headerHtml = trim(strtr($this->layoutHeader, $parts));

Check warning on line 523 in src/Alert.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "UnwrapTrim": @@ @@ */ private function renderHeaderContainer(array $parts): string { - $headerHtml = trim(strtr($this->layoutHeader, $parts)); + $headerHtml = strtr($this->layoutHeader, $parts); return $this->headerContainer && $headerHtml !== '' ? Div::tag()

return $this->headerContainer && $headerHtml !== ''
? Div::tag()
Expand Down
6 changes: 2 additions & 4 deletions src/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 4 additions & 2 deletions src/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -52,7 +54,7 @@ final class Breadcrumbs extends Widget
{
private string $activeItemTemplate = "<li class=\"active\">{link}</li>\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 = "<li>{link}</li>\n";
private string $tag = 'ul';
Expand Down Expand Up @@ -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,
);
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/ContentDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion src/Dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use function str_contains;
use function trim;

use const PHP_EOL;

final class Dropdown extends Widget
{
private string $activeClass = 'active';
Expand Down Expand Up @@ -488,7 +490,7 @@
}

return $this->renderItemContainer(
Html::tag($this->dividerTag, '', $dividerAttributes)->encode(false)->render(),

Check warning on line 493 in src/Dropdown.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "FalseValue": @@ @@ } return $this->renderItemContainer( - Html::tag($this->dividerTag, '', $dividerAttributes)->encode(false)->render(), + Html::tag($this->dividerTag, '', $dividerAttributes)->encode(true)->render(), ); }
);
}

Expand All @@ -506,7 +508,7 @@
->itemContainerAttributes($this->itemContainerAttributes)
->itemContainerTag($this->itemContainerTag)
->items($items)
->itemsContainerAttributes(array_merge($this->itemsContainerAttributes))

Check warning on line 511 in src/Dropdown.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMerge": @@ @@ ->itemContainerAttributes($this->itemContainerAttributes) ->itemContainerTag($this->itemContainerTag) ->items($items) - ->itemsContainerAttributes(array_merge($this->itemsContainerAttributes)) + ->itemsContainerAttributes($this->itemsContainerAttributes) ->itemTag($this->itemTag) ->toggleAttributes($this->toggleAttributes) ->toggleType($this->toggleType)
->itemTag($this->itemTag)
->toggleAttributes($this->toggleAttributes)
->toggleType($this->toggleType)
Expand All @@ -524,7 +526,7 @@
}

return $this->renderItemContainer(
Html::normalTag($this->headerTag, $label, $headerAttributes)->encode(false)->render(),

Check warning on line 529 in src/Dropdown.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "FalseValue": @@ @@ } return $this->renderItemContainer( - Html::normalTag($this->headerTag, $label, $headerAttributes)->encode(false)->render(), + Html::normalTag($this->headerTag, $label, $headerAttributes)->encode(true)->render(), ); }
);
}

Expand Down Expand Up @@ -585,7 +587,7 @@

if ($this->toggleType === 'split' && !str_contains($this->containerClass, 'dropstart')) {
$lines[] = $toggleSplitButton . PHP_EOL . $toggle . PHP_EOL . $itemContainer;
} elseif ($this->toggleType === 'split' && str_contains($this->containerClass, 'dropstart')) {

Check warning on line 590 in src/Dropdown.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "LogicalAnd": @@ @@ if ($this->toggleType === 'split' && !str_contains($this->containerClass, 'dropstart')) { $lines[] = $toggleSplitButton . PHP_EOL . $toggle . PHP_EOL . $itemContainer; - } elseif ($this->toggleType === 'split' && str_contains($this->containerClass, 'dropstart')) { + } elseif ($this->toggleType === 'split' || str_contains($this->containerClass, 'dropstart')) { $lines[] = $toggle . PHP_EOL . $itemContainer . PHP_EOL . $toggleSplitButton; } else { $lines[] = $toggle . PHP_EOL . $itemContainer;
$lines[] = $toggle . PHP_EOL . $itemContainer . PHP_EOL . $toggleSplitButton;
} else {
$lines[] = $toggle . PHP_EOL . $itemContainer;
Expand Down Expand Up @@ -636,7 +638,7 @@
array $headerAttributes = [],
array $itemContainerAttributes = [],
): string {
return match (true) {

Check warning on line 641 in src/Dropdown.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "MatchArmRemoval": @@ @@ ): string { return match (true) { $label === '-' => $this->renderDivider(), - $enclose === false => $label, $link === '' => $this->renderHeader($label, $headerAttributes), default => $this->renderItemLink($label, $link, $linkAttributes, $itemContainerAttributes), };

Check warning on line 641 in src/Dropdown.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.4-ubuntu-latest

Escaped Mutant for Mutator "MatchArmRemoval": @@ @@ array $itemContainerAttributes = [], ): string { return match (true) { - $label === '-' => $this->renderDivider(), $enclose === false => $label, $link === '' => $this->renderHeader($label, $headerAttributes), default => $this->renderItemLink($label, $link, $linkAttributes, $itemContainerAttributes),
$label === '-' => $this->renderDivider(),
$enclose === false => $label,
$link === '' => $this->renderHeader($label, $headerAttributes),
Expand Down Expand Up @@ -686,7 +688,7 @@
string $label,
string $link,
array $linkAttributes = [],
array $itemContainerAttributes = []
array $itemContainerAttributes = [],
): string {
$linkAttributes['href'] = $link;

Expand Down
6 changes: 2 additions & 4 deletions src/FragmentCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] */
Expand All @@ -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.
Expand Down
Loading
Loading