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
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:
- 'config/**'
- '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'
24 changes: 0 additions & 24 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 @@ -28,3 +28,7 @@ phpunit.phar
/phpunit.xml
# phpunit cache
/.phpunit.cache/

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

declare(strict_types=1);

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

$finder = (new Finder())->in([
__DIR__ . '/config',
__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);
85 changes: 0 additions & 85 deletions .styleci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 1.5.2 under development

- no changes in this release.
- Enh #384: Explicitly import functions and constants in "use" section (@mspirkov)

## 1.5.1 December 23, 2025

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"yiisoft/widget": "^2.2"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.92",
"bamarni/composer-bin-plugin": "^1.8.3",
"maglnet/composer-require-checker": "^4.7.1",
"phpunit/phpunit": "^10.5.45",
Expand Down
10 changes: 3 additions & 7 deletions src/Field/Base/BaseField.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ final public function containerId(?string $id): static
final public function containerClass(?string ...$class): static
{
$new = clone $this;
$new->containerAttributes['class'] = array_filter($class, static fn ($c) => $c !== null);
$new->containerAttributes['class'] = array_filter($class, static fn($c) => $c !== null);
return $new;
}

Expand Down Expand Up @@ -127,9 +127,7 @@ final public function render(): string
return $result;
}

protected function beforeRender(): void
{
}
protected function beforeRender(): void {}

abstract protected function generateContent(): ?string;

Expand All @@ -143,9 +141,7 @@ protected function generateEndContent(): string
return '';
}

protected function prepareContainerAttributes(array &$attributes): void
{
}
protected function prepareContainerAttributes(array &$attributes): void {}

final protected static function getThemeConfig(?string $theme): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Field/Base/ButtonField.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final public function buttonId(?string $id): static
final public function buttonClass(?string ...$class): static
{
$new = clone $this;
$new->buttonAttributes['class'] = array_filter($class, static fn ($c) => $c !== null);
$new->buttonAttributes['class'] = array_filter($class, static fn($c) => $c !== null);
return $new;
}

Expand Down Expand Up @@ -92,7 +92,7 @@ final public function name(?string $name): self
final public function ariaDescribedBy(?string ...$value): static
{
$new = clone $this;
$new->buttonAttributes['aria-describedby'] = array_filter($value, static fn (?string $v): bool => $v !== null);
$new->buttonAttributes['aria-describedby'] = array_filter($value, static fn(?string $v): bool => $v !== null);
return $new;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Field/Base/DateTimeInputField.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final public function min(?string $value): static
final public function ariaDescribedBy(?string ...$value): static
{
$new = clone $this;
$new->inputAttributes['aria-describedby'] = array_filter($value, static fn (?string $v): bool => $v !== null);
$new->inputAttributes['aria-describedby'] = array_filter($value, static fn(?string $v): bool => $v !== null);
return $new;
}

Expand Down Expand Up @@ -157,15 +157,15 @@ final protected function generateInput(): string
$value = $this->formatDateTime($value);
} elseif (!is_string($value) && $value !== null) {
throw new InvalidArgumentException(
(new ReflectionClass($this))->getShortName() .
' field requires a string or null value.'
(new ReflectionClass($this))->getShortName()
. ' field requires a string or null value.',
);
}

/** @psalm-suppress MixedArgument We guess that enrichment contain correct values. */
$inputAttributes = array_merge(
$this->enrichment['inputAttributes'] ?? [],
$this->getInputAttributes()
$this->getInputAttributes(),
);

return Html::input($this->getInputType(), $this->getName(), $value, $inputAttributes)->render();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ final public function inputData(InputDataInterface $inputData): static
return $new;
}

final protected function getInputData(): InputDataInterface
{
if ($this->inputData === null) {
$this->inputData = new InputData();
}

return $this->inputData;
}

final public function name(?string $name): static
{
$new = clone $this;
Expand All @@ -66,6 +57,15 @@ final public function prepareValue(?callable $callback): static
return $new;
}

final protected function getInputData(): InputDataInterface
{
if ($this->inputData === null) {
$this->inputData = new InputData();
}

return $this->inputData;
}

final protected function getName(): ?string
{
return $this->useCustomName
Expand Down
6 changes: 2 additions & 4 deletions src/Field/Base/InputField.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final public function addInputAttributes(array $attributes): static
final public function inputClass(?string ...$class): static
{
$new = clone $this;
$new->inputAttributes['class'] = array_filter($class, static fn ($c) => $c !== null);
$new->inputAttributes['class'] = array_filter($class, static fn($c) => $c !== null);
return $new;
}

Expand All @@ -96,9 +96,7 @@ final protected function getInputAttributes(): array
return $attributes;
}

protected function prepareInputAttributes(array &$attributes): void
{
}
protected function prepareInputAttributes(array &$attributes): void {}

final protected function prepareIdInInputAttributes(array &$attributes): void
{
Expand Down
Loading