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
/phpcs.xml
/.php_cs.cache
/.php_cs
.php-cs-fixer.cache
# composer
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
## 1.6.0 work in progress
**WARNING**: this release (long time due) makes a step forward in PHP
compatibility, leaving behind obsolete versions. While yii2-usuario should
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 #448: Remove deprecated SwiftMailer, use SymfonyMailer instead (TonisOrmisson)
- 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

View File

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

View File

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

View File

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

View File

@ -37,7 +37,7 @@ class AccessRuleFilter extends AccessRule
/** @var User $identity */
$identity = $user->identity;
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\base\Exception;
use yii\base\Security;
use yii\base\InvalidConfigException;
use yii\base\Security;
class SecurityHelper
{
@ -76,8 +76,7 @@ class SecurityHelper
if (!isset($minPasswordRequirements)) {
if (isset(Yii::$app->getModule('user')->minPasswordRequirements)) {
$minPasswordRequirements = Yii::$app->getModule('user')->minPasswordRequirements;
}
else {
} else {
$minPasswordRequirements = [
'lower' => 1,
'digit' => 1,

View File

@ -25,7 +25,7 @@ use yii\base\InvalidParamException;
use yii\db\ActiveRecord;
/**
* @property int $user_id
* @property int $user_id
* @property string $name
* @property string $public_email
* @property string $gravatar_email
@ -34,7 +34,7 @@ use yii\db\ActiveRecord;
* @property string $website
* @property string $bio
* @property string $timezone
* @property User $user
* @property User $user
*/
class Profile extends ActiveRecord
{

View File

@ -22,17 +22,17 @@ use yii\helpers\Url;
/**
* /**
* @property int $id Id
* @property int $user_id User id, null if account is not bind to user
* @property string $provider Name of service
* @property string $client_id Account id
* @property string $data Account properties returned by social network (json encoded)
* @property string $decodedData Json-decoded properties
* @property int $id Id
* @property int $user_id User id, null if account is not bind to user
* @property string $provider Name of service
* @property string $client_id Account id
* @property string $data Account properties returned by social network (json encoded)
* @property string $decodedData Json-decoded properties
* @property string $code
* @property string $email
* @property string $username
* @property int $created_at
* @property User $user User that this account is connected for
* @property int $created_at
* @property User $user User that this account is connected for
*/
class SocialNetworkAccount extends ActiveRecord
{

View File

@ -24,13 +24,13 @@ use yii\helpers\Url;
/**
* Token Active Record model.
*
* @property int $user_id
* @property int $user_id
* @property string $code
* @property int $type
* @property int $type
* @property string $url
* @property bool $isExpired
* @property int $created_at
* @property User $user
* @property bool $isExpired
* @property int $created_at
* @property User $user
*/
class Token extends ActiveRecord
{

View File

@ -31,33 +31,33 @@ use yii\web\IdentityInterface;
*
* @property bool $isAdmin
* @property bool $isBlocked
* @property bool $isConfirmed whether user account has been confirmed or not
* @property bool $gdpr_deleted whether user requested deletion of his account
* @property bool $gdpr_consent whether user has consent personal data processing
* @property bool $isConfirmed whether user account has been confirmed or not
* @property bool $gdpr_deleted whether user requested deletion of his account
* @property bool $gdpr_consent whether user has consent personal data processing
*
* Database fields:
* @property int $id
* @property string $username
* @property string $email
* @property string $unconfirmed_email
* @property string $password_hash
* @property string $auth_key
* @property string $auth_tf_key
* @property int $auth_tf_enabled
* @property string $registration_ip
* @property int $confirmed_at
* @property int $blocked_at
* @property int $flags
* @property int $created_at
* @property int $updated_at
* @property int $last_login_at
* @property int $gdpr_consent_date date of agreement of data processing
* @property string $last_login_ip
* @property int $password_changed_at
* @property int $password_age
* Defined relations:
* @property int $id
* @property string $username
* @property string $email
* @property string $unconfirmed_email
* @property string $password_hash
* @property string $auth_key
* @property string $auth_tf_key
* @property int $auth_tf_enabled
* @property string $registration_ip
* @property int $confirmed_at
* @property int $blocked_at
* @property int $flags
* @property int $created_at
* @property int $updated_at
* @property int $last_login_at
* @property int $gdpr_consent_date date of agreement of data processing
* @property string $last_login_ip
* @property int $password_changed_at
* @property int $password_age
* Defined relations:
* @property SocialNetworkAccount[] $socialNetworkAccounts
* @property Profile $profile
* @property Profile $profile
*/
class User extends ActiveRecord implements IdentityInterface
{

View File

@ -229,11 +229,11 @@ class Module extends BaseModule
* @var boolean whether to disable IP logging into user table
*/
public $disableIpLogging = false;
/**
* @var array Minimum requirements when a new password is automatically generated.
* Array structure: `requirement => minimum number characters`.
*
* Array structure: `requirement => minimum number characters`.
*
* Possible array keys:
* - lower: minimum number of lowercase characters;
* - upper: minimum number of uppercase characters;

View File

@ -19,7 +19,7 @@ use Da\User\Traits\MailAwareTrait;
class UserConfirmationService implements ServiceInterface
{
use MailAwareTrait;
protected $model;
public function __construct(User $model)
@ -31,7 +31,7 @@ class UserConfirmationService implements ServiceInterface
{
$model = $this->model;
$event = $this->make(UserEvent::class, [$model]);
$this->model->trigger(UserEvent::EVENT_BEFORE_CONFIRMATION, $event);
if ((bool)$this->model->updateAttributes(['confirmed_at' => time()])) {
$this->model->trigger(UserEvent::EVENT_AFTER_CONFIRMATION, $event);

View File

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