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
27 changes: 27 additions & 0 deletions .github/workflows/rector-cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Rector + PHP CS Fixer

on:
pull_request_target:
paths:
- 'src/**'
- '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'
20 changes: 0 additions & 20 deletions .github/workflows/rector.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ phpunit.phar
/node_modules
/package-lock.json
.phpunit.result.cache

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

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

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

return (new Config())
->setRiskyAllowed(true)
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
'@PER-CS3.0' => true,
'no_unused_imports' => true,
'ordered_class_elements' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one']],
'declare_strict_types' => true,
'native_function_invocation' => true,
'native_constant_invocation' => true,
'fully_qualified_strict_types' => [
'import_symbols' => true
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
])
->setFinder($finder);
87 changes: 0 additions & 87 deletions .styleci.yml

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Enh #287: Allow `Dropdown::togglerVariant()` to be `null`, avoiding it setting a variant class (@Mister-42)
- Bug #288: Add support for custom togglerClasses in `Dropdown` widget, and `addDropdownClass()` method (@terabytesoftw)
- Enh #291: Add `navId()` method to `NavBar` widget (@terabytesoftw)
- Enh #294: Explicitly import classes and functions in "use" section (@mspirkov)

## 1.0.0 April 13, 2025

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"yiisoft/widget": "^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.92.5",
"maglnet/composer-require-checker": "^4.1",
"phpunit/phpunit": "^10.5",
"rector/rector": "^2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Accordion.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final class Accordion extends Widget

private array $togglerAttributes = [];

private string|null $togglerTag = null;
private ?string $togglerTag = null;

/**
* Adds a sets of attributes.
Expand Down
5 changes: 2 additions & 3 deletions src/AccordionItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ private function __construct(
private bool $encodeHeader,
private string $header,
private bool|string $id,
) {
}
) {}

/**
* Creates a new {@see AccordionItem} instance.
Expand All @@ -59,7 +58,7 @@ public static function to(
bool|string $id = true,
bool $encodeHeader = true,
bool $encodeBody = true,
bool $active = false
bool $active = false,
): self {
return new self($active, $body, $encodeBody, $encodeHeader, $header, $id);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ final class Alert extends Widget

private array $closeButtonAttributes = [];

private string|null $closeButtonTag = null;
private ?string $closeButtonTag = null;

private string $closeButtonLabel = '';

private bool $dismissable = false;

private bool $fade = false;

private string|null $header = null;
private ?string $header = null;

private array $headerAttributes = [];

Expand Down Expand Up @@ -417,7 +417,7 @@ public function fade(bool $enabled): self
* $alert->header('Header content');
* ```
*/
public function header(string|null $content, bool $encode = true): self
public function header(?string $content, bool $encode = true): self
{
if ($encode) {
$content = Html::encode($content);
Expand Down Expand Up @@ -562,7 +562,7 @@ public function render(): string
'{header}' => $this->renderHeader(),
'{body}' => $this->body,
'{toggler}' => $toggler,
]
],
);

$content = preg_replace("/\n{2}/", "\n", $content) ?? '';
Expand All @@ -577,7 +577,7 @@ public function render(): string
*
* @psalm-return non-empty-string|null The generated ID.
*/
private function getId(): string|null
private function getId(): ?string
{
return match ($this->id) {
true => $this->attributes['id'] ?? Html::generateId(self::NAME . '-'),
Expand Down
13 changes: 6 additions & 7 deletions src/BreadcrumbLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ final class BreadcrumbLink
*/
private function __construct(
private string $label,
private string|null $url,
private ?string $url,
private bool $active,
private bool $encodeLabel,
private array $attributes,
) {
}
) {}

/**
* Creates a new {@see BreadcrumbLink} instance.
Expand All @@ -51,10 +50,10 @@ private function __construct(
*/
public static function to(
string $label,
string|null $url = null,
?string $url = null,
bool $active = false,
array $attributes = [],
bool $encodeLabel = true
bool $encodeLabel = true,
): self {
return new self($label, $url, $active, $encodeLabel, $attributes);
}
Expand Down Expand Up @@ -128,7 +127,7 @@ public function label(string $label): self
*
* @return self A new instance with the specified URL.
*/
public function url(string|null $url): self
public function url(?string $url): self
{
$new = clone $this;
$new->url = $url;
Expand Down Expand Up @@ -156,7 +155,7 @@ public function getLabel(): string
/**
* @return string|null The URL for the link.
*/
public function getUrl(): string|null
public function getUrl(): ?string
{
return $this->url;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ public function render(): string
*
* @psalm-return non-empty-string|null The generated ID.
*/
private function getId(): string|null
private function getId(): ?string
{
return match ($this->listId) {
true => $this->listAttributes['id'] ?? Html::generateId(self::LIST_NAME . '-'),
Expand Down
Loading