Update PHP-CS-Fixer to v3.x (#460)

This commit is contained in:
Lorenzo Milesi
2022-08-11 09:47:33 +02:00
committed by GitHub
parent c73776698e
commit c83692f277
16 changed files with 98 additions and 106 deletions

3
.gitignore vendored
View File

@ -47,8 +47,7 @@ codeception.yml
# Code Style Checkers and Mess Detectors # Code Style Checkers and Mess Detectors
/phpcs.xml /phpcs.xml
/.php_cs.cache .php-cs-fixer.cache
/.php_cs
# composer # composer
composer.lock composer.lock

43
.php-cs-fixer.dist.php Normal file
View File

@ -0,0 +1,43 @@
<?php
$header = <<<'EOF'
This file is part of the 2amigos/yii2-usuario project.
(c) 2amigOS! <http://2amigos.us/>
For the full copyright and license information, please view
the LICENSE file that was distributed with this source code.
EOF;
$finder = PhpCsFixer\Finder::create()
->exclude(['resources'])
->in("src/User")
;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR1' => true,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'header_comment' => ['header' => $header],
'combine_consecutive_unsets' => true,
'no_extra_blank_lines' => [
'tokens' => ['break', 'case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'return', 'square_brace_block', 'switch', 'throw', 'use', 'use_trait',],
],
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_align' => true,
'no_trailing_whitespace' => true,
'no_whitespace_in_blank_line' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_whitespace_before_comma_in_array' => true,
'trim_array_spaces' => true,
'explicit_string_variable' => true,
'binary_operator_spaces' => true,
])
->setFinder($finder)
;

View File

@ -1,49 +0,0 @@
<?php
$header = <<<'EOF'
This file is part of the 2amigos/yii2-usuario project.
(c) 2amigOS! <http://2amigos.us/>
For the full copyright and license information, please view
the LICENSE file that was distributed with this source code.
EOF;
$finder = PhpCsFixer\Finder::create()
->exclude([
'.github',
'docs',
'temp',
'tests',
'vendor',
'src/User/resources'
])
->in(__DIR__);
return PhpCsFixer\Config::create()
->setRules(array(
'@PSR1' => true,
'@PSR2' => true,
'header_comment' => ['header' => $header],
'array_syntax' => array('syntax' => 'short'),
'combine_consecutive_unsets' => true,
'no_extra_consecutive_blank_lines' => array(
'break',
'continue',
'extra',
'return',
'throw',
'use',
'parenthesis_brace_block',
'square_brace_block',
'curly_brace_block'
),
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_align' => true
))
->setFinder($finder);

View File

@ -1,7 +1,6 @@
# CHANGELOG # CHANGELOG
## 1.6.0 work in progress ## 1.6.0 work in progress
**WARNING**: this release (long time due) makes a step forward in PHP **WARNING**: this release (long time due) makes a step forward in PHP
compatibility, leaving behind obsolete versions. While yii2-usuario should compatibility, leaving behind obsolete versions. While yii2-usuario should
still work without issues on 5.6, from now on testing and development will still work without issues on 5.6, from now on testing and development will
@ -24,6 +23,7 @@ look forward and manitain only >=7.4 versions.
- Ehn #412: Allow role names to support UTF-8 chars (4khobta) - Ehn #412: Allow role names to support UTF-8 chars (4khobta)
- Ehn #448: Remove deprecated SwiftMailer, use SymfonyMailer instead (TonisOrmisson) - Ehn #448: Remove deprecated SwiftMailer, use SymfonyMailer instead (TonisOrmisson)
- Ehn #428: Translations of the placeholders in the login widget (anapaulaxenon) - Ehn #428: Translations of the placeholders in the login widget (anapaulaxenon)
- Update PHP-CS-Fixer configuration to new version (maxxer)
## 1.5.1 April 5, 2020 ## 1.5.1 April 5, 2020

View File

@ -52,10 +52,9 @@
"2amigos/qrcode-library": "Needed if you want to enable 2FA with QR Code generation. Require version ^1.1" "2amigos/qrcode-library": "Needed if you want to enable 2FA with QR Code generation. Require version ^1.1"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^3",
"php": ">=7.4", "php": ">=7.4",
"yiisoft/yii2-symfonymailer": "~2.0.0", "yiisoft/yii2-symfonymailer": "~2.0.0",
"friendsofphp/php-cs-fixer": "^2.3",
"squizlabs/php_codesniffer": "*", "squizlabs/php_codesniffer": "*",
"phpmd/phpmd": "@stable", "phpmd/phpmd": "@stable",
"codeception/verify": "^0.3.3", "codeception/verify": "^0.3.3",

View File

@ -365,7 +365,7 @@ class Bootstrap implements BootstrapInterface
$mapping = array_merge($defaults, $userClassMap); $mapping = array_merge($defaults, $userClassMap);
foreach ($mapping as $name => $definition) { foreach ($mapping as $name => $definition) {
$map[$this->getRoute($routes, $name) . "\\$name"] = $definition; $map[$this->getRoute($routes, $name) . "\\{$name}"] = $definition;
} }
return $map; return $map;

View File

@ -110,13 +110,13 @@ class RegistrationController extends Controller
// Create a temporay $user so we can get the attributes, then get // Create a temporay $user so we can get the attributes, then get
// the intersection between the $form fields and the $user fields. // the intersection between the $form fields and the $user fields.
$user = $this->make(User::class, [] ); $user = $this->make(User::class, []);
$fields = array_intersect_key($form->attributes, $user->attributes); $fields = array_intersect_key($form->attributes, $user->attributes);
// Becomes password_hash // Becomes password_hash
$fields['password'] = $form['password']; $fields['password'] = $form['password'];
$user = $this->make(User::class, [], $fields ); $user = $this->make(User::class, [], $fields);
$user->setScenario('register'); $user->setScenario('register');
$mailService = MailFactory::makeWelcomeMailerService($user); $mailService = MailFactory::makeWelcomeMailerService($user);

View File

@ -37,7 +37,7 @@ class AccessRuleFilter extends AccessRule
/** @var User $identity */ /** @var User $identity */
$identity = $user->identity; $identity = $user->identity;
if (!$identity->gdpr_consent) { if (!$identity->gdpr_consent) {
Yii::$app->response->redirect([ "/$consentAction"])->send(); Yii::$app->response->redirect(["/{$consentAction}"])->send();
} }
} }
} }

View File

@ -13,8 +13,8 @@ namespace Da\User\Helper;
use Yii; use Yii;
use yii\base\Exception; use yii\base\Exception;
use yii\base\Security;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
use yii\base\Security;
class SecurityHelper class SecurityHelper
{ {
@ -76,8 +76,7 @@ class SecurityHelper
if (!isset($minPasswordRequirements)) { if (!isset($minPasswordRequirements)) {
if (isset(Yii::$app->getModule('user')->minPasswordRequirements)) { if (isset(Yii::$app->getModule('user')->minPasswordRequirements)) {
$minPasswordRequirements = Yii::$app->getModule('user')->minPasswordRequirements; $minPasswordRequirements = Yii::$app->getModule('user')->minPasswordRequirements;
} } else {
else {
$minPasswordRequirements = [ $minPasswordRequirements = [
'lower' => 1, 'lower' => 1,
'digit' => 1, 'digit' => 1,

View File

@ -10,6 +10,7 @@
*/ */
use yii\helpers\Html; use yii\helpers\Html;
use yii\helpers\Url;
/** /**
* @var \Da\User\Module $module * @var \Da\User\Module $module