Skip to content

Commit c399079

Browse files
authored
Update the PHP CS Fixer configuration (#787)
1 parent 5809625 commit c399079

33 files changed

+77
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ composer.phar
2929

3030
# PHP CS Fixer
3131
/.php-cs-fixer.cache
32+
/.php-cs-fixer.php
3233

3334
# po4a .mo files
3435
*.mo

.php-cs-fixer.dist.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,29 @@
77
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
88

99
$finder = (new Finder())->in([
10+
__DIR__ . '/config',
1011
__DIR__ . '/src',
1112
__DIR__ . '/tests',
1213
]);
1314

1415
return (new Config())
16+
->setRiskyAllowed(true)
1517
->setParallelConfig(ParallelConfigFactory::detect())
1618
->setRules([
1719
'@PER-CS3.0' => true,
1820
'no_unused_imports' => true,
1921
'ordered_class_elements' => true,
2022
'class_attributes_separation' => ['elements' => ['method' => 'one']],
23+
'declare_strict_types' => true,
24+
'native_function_invocation' => true,
25+
'native_constant_invocation' => true,
26+
'fully_qualified_strict_types' => [
27+
'import_symbols' => true
28+
],
29+
'global_namespace_import' => [
30+
'import_classes' => true,
31+
'import_constants' => true,
32+
'import_functions' => true,
33+
],
2134
])
2235
->setFinder($finder);

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 2.5.2 under development
44

5-
- no changes in this release.
5+
- Enh #787: Explicitly import classes, functions, and constants in "use" section (@mspirkov)
66

77
## 2.5.1 December 12, 2025
88

config/di.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
'yii.validator.categorySource' => [
2626
'definition' => static function () use ($params): CategorySource {
2727
$reader = class_exists(MessageSource::class)
28-
? new MessageSource(dirname(__DIR__) . '/messages')
28+
? new MessageSource(\dirname(__DIR__) . '/messages')
2929
: new IdMessageReader(); // @codeCoverageIgnore
3030

31-
$formatter = extension_loaded('intl')
31+
$formatter = \extension_loaded('intl')
3232
? new IntlMessageFormatter()
3333
: new SimpleMessageFormatter();
3434

src/Debug/ValidatorCollector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Yiisoft\Yii\Debug\Collector\CollectorTrait;
1010
use Yiisoft\Yii\Debug\Collector\SummaryCollectorInterface;
1111

12+
use function count;
13+
1214
final class ValidatorCollector implements SummaryCollectorInterface
1315
{
1416
use CollectorTrait;

src/Exception/InvalidCallbackReturnTypeException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Yiisoft\Validator\Rule\Callback;
1212
use Yiisoft\Validator\Rule\CallbackHandler;
1313

14+
use function sprintf;
15+
1416
/**
1517
* An exception used by the handler ({@see CallbackHandler}) of {@see Callback} rule for the cases when returned value
1618
* is not a {@see Result} instance.

src/Exception/RuleHandlerInterfaceNotImplementedException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
use Yiisoft\Validator\RuleHandlerInterface;
1111
use Yiisoft\Validator\RuleHandlerResolverInterface;
1212

13+
use function sprintf;
14+
1315
/**
1416
* An exception used by {@see RuleHandlerResolverInterface} implementations (e. g., {@see RuleHandlerContainer}) for
1517
* the case when a retrieved value is not an object or an object that does not implement {@see RuleHandlerInterface}.

src/Exception/RuleHandlerNotFoundException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Throwable;
99
use Yiisoft\Validator\RuleHandlerResolver\RuleHandlerContainer;
1010

11+
use function sprintf;
12+
1113
/**
1214
* An exception used by {@see RuleHandlerContainer} for the case when a given class name was not found in the container.
1315
*/

src/Exception/UnexpectedRuleException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use InvalidArgumentException;
88
use Throwable;
99

10+
use function sprintf;
11+
1012
/**
1113
* An exception used by rule handlers to guarantee that passed rule have desired type. Every handler's validation code
1214
* must start with this check. An example for `MyRule` and `MyRuleHandler`:

src/Helper/ObjectParser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use function is_int;
2323
use function is_object;
2424
use function is_string;
25+
use function sprintf;
2526

2627
/**
2728
* A helper class used to parse rules from PHP attributes (attached to class properties and class itself) and data from

0 commit comments

Comments
 (0)