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: '7.4'
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 @@ -29,3 +29,7 @@ phpunit.phar
/phpunit.xml
# phpunit cache
.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);
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.3.1 under development

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

## 1.3.0 November 25, 2025

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"friendsofphp/php-cs-fixer": "^3.92",
"maglnet/composer-require-checker": "^3.8 || ^4.3",
"phpunit/phpunit": "^9.6.22",
"rector/rector": "^2.0.10",
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withPhpSets(php74: true)
->withPhp74Sets()
->withRules([
InlineConstructorDefaultToPropertyRector::class,
])
Expand Down
2 changes: 1 addition & 1 deletion src/ContentDispositionHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
{
if (!in_array($type, [self::INLINE, self::ATTACHMENT])) {
throw new InvalidArgumentException(
'Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".'
'Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".',

Check warning on line 65 in src/ContentDispositionHeader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ public static function value(string $type, ?string $fileName = null): string { if (!in_array($type, [self::INLINE, self::ATTACHMENT])) { - throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".'); + throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE); } $header = $type; if ($fileName === null) {

Check warning on line 65 in src/ContentDispositionHeader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "Concat": @@ @@ public static function value(string $type, ?string $fileName = null): string { if (!in_array($type, [self::INLINE, self::ATTACHMENT])) { - throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".'); + throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . '" or "' . '".' . self::INLINE); } $header = $type; if ($fileName === null) {

Check warning on line 65 in src/ContentDispositionHeader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ public static function value(string $type, ?string $fileName = null): string { if (!in_array($type, [self::INLINE, self::ATTACHMENT])) { - throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".'); + throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . '" or "' . '".'); } $header = $type; if ($fileName === null) {

Check warning on line 65 in src/ContentDispositionHeader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "Concat": @@ @@ public static function value(string $type, ?string $fileName = null): string { if (!in_array($type, [self::INLINE, self::ATTACHMENT])) { - throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".'); + throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . self::INLINE . '" or "' . '".'); } $header = $type; if ($fileName === null) {

Check warning on line 65 in src/ContentDispositionHeader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ public static function value(string $type, ?string $fileName = null): string { if (!in_array($type, [self::INLINE, self::ATTACHMENT])) { - throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".'); + throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . self::INLINE . '".'); } $header = $type; if ($fileName === null) {

Check warning on line 65 in src/ContentDispositionHeader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "Concat": @@ @@ public static function value(string $type, ?string $fileName = null): string { if (!in_array($type, [self::INLINE, self::ATTACHMENT])) { - throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".'); + throw new InvalidArgumentException('Disposition type must be either "' . '" or "' . self::ATTACHMENT . self::INLINE . '".'); } $header = $type; if ($fileName === null) {

Check warning on line 65 in src/ContentDispositionHeader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "ConcatOperandRemoval": @@ @@ public static function value(string $type, ?string $fileName = null): string { if (!in_array($type, [self::INLINE, self::ATTACHMENT])) { - throw new InvalidArgumentException('Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".'); + throw new InvalidArgumentException('Disposition type must be either "' . '" or "' . self::INLINE . '".'); } $header = $type; if ($fileName === null) {
);
}

Expand Down
9 changes: 6 additions & 3 deletions src/HeaderValueHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
use function trim;
use function usort;

use const PREG_SPLIT_NO_EMPTY;
use const SORT_STRING;

/**
* `HeaderValueHelper` parses the header value parameters.
*
Expand Down Expand Up @@ -76,8 +79,8 @@
*/
public static function getValueAndParameters(
string $headerValue,
bool $lowerCaseValue = true,

Check warning on line 82 in src/HeaderValueHelper.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "TrueValue": @@ @@ * * @return string[] First element is the value, and key-value are the parameters. */ - public static function getValueAndParameters(string $headerValue, bool $lowerCaseValue = true, bool $lowerCaseParameter = true, bool $lowerCaseParameterValue = true): array + public static function getValueAndParameters(string $headerValue, bool $lowerCaseValue = false, bool $lowerCaseParameter = true, bool $lowerCaseParameterValue = true): array { $headerValue = trim($headerValue); if ($headerValue === '') {
bool $lowerCaseParameter = true,

Check warning on line 83 in src/HeaderValueHelper.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.5-ubuntu-latest

Escaped Mutant for Mutator "TrueValue": @@ @@ * * @return string[] First element is the value, and key-value are the parameters. */ - public static function getValueAndParameters(string $headerValue, bool $lowerCaseValue = true, bool $lowerCaseParameter = true, bool $lowerCaseParameterValue = true): array + public static function getValueAndParameters(string $headerValue, bool $lowerCaseValue = true, bool $lowerCaseParameter = false, bool $lowerCaseParameterValue = true): array { $headerValue = trim($headerValue); if ($headerValue === '') {
bool $lowerCaseParameterValue = true
): array {
$headerValue = trim($headerValue);
Expand Down Expand Up @@ -159,7 +162,7 @@
},
$headerValueParameters,
1,
$count
$count,
);

if ($count !== 1) {
Expand Down Expand Up @@ -223,7 +226,7 @@
$value,
$lowerCaseValue,
$lowerCaseParameter,
$lowerCaseParameterValue
$lowerCaseParameterValue,
);
// case-insensitive "q" parameter
$q = $parse['q'] ?? $parse['Q'] ?? 1.0;
Expand All @@ -242,7 +245,7 @@
$output,
static function (array $a, array $b) {
return $b['q'] <=> $a['q'];
}
},
);

return $output;
Expand Down
Loading