Skip to content

Commit

Permalink
Optimize PHP CS Fixer rules
Browse files Browse the repository at this point in the history
  • Loading branch information
s-damian committed Aug 8, 2023
1 parent 8384e0d commit fd1adf8
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 25 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/Admin/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function store(Validator $validator)
$article->fill(Request::getPost()->all());
$article->save();

// Success. Redirect or JSON response...
// Success. Redirect or JSON response...
} else {
// Error. Redirect or JSON response...
}
Expand Down Expand Up @@ -112,7 +112,7 @@ public function update(Validator $validator, int $id)
$article->fill(Request::getPost()->all());
$article->save();

// Success. Redirect or JSON response...
// Success. Redirect or JSON response...
} else {
// Error. Redirect or JSON response...
}
Expand Down
20 changes: 10 additions & 10 deletions app/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
*/
class Article extends BaseModel
{
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [
'title',
'description',
'content',
'slug',
];

/*
|--------------------------------------------------------------------------
| Columns:
Expand Down Expand Up @@ -50,6 +40,16 @@ class Article extends BaseModel
*/
public string $slug;

/**
* The attributes that are mass assignable.
*/
protected array $fillable = [
'title',
'description',
'content',
'slug',
];

public static function getFakeArticles(): array
{
$articles = [];
Expand Down
22 changes: 11 additions & 11 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@
*/
class User extends BaseModel
{
/**
* Les attributs qui sont assignables en masse.
*/
protected array $fillable = [
'email',
'first_name',
'last_name',
'tel',
'username',
];

/*
|--------------------------------------------------------------------------
| Columns:
Expand Down Expand Up @@ -98,4 +87,15 @@ class User extends BaseModel
* Type varchar(255) - Null no - Index unique key
*/
public string $username;

/**
* Les attributs qui sont assignables en masse.
*/
protected array $fillable = [
'email',
'first_name',
'last_name',
'tel',
'username',
];
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"require-dev": {
"phpunit/phpunit": "9.5.*",
"guzzlehttp/guzzle": "6.3.*",
"phpstan/phpstan": "^1.9"
"phpstan/phpstan": "^1.10"
},
"autoload": {
"psr-4" : {
Expand Down
2 changes: 1 addition & 1 deletion tools/php-cs-fixer/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": {
"friendsofphp/php-cs-fixer": "^3.13"
"friendsofphp/php-cs-fixer": "^3.22"
}
}
30 changes: 30 additions & 0 deletions tools/php-cs-fixer/php-cs-fixer-rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'exit', 'return', 'throw', 'try'],
],
'class_attributes_separation' => [
'elements' => ['const' => 'one', 'method' => 'one', 'property' => 'one'],
],
'no_extra_blank_lines' => [
'tokens' => ['curly_brace_block', 'extra', 'use'],
],
Expand All @@ -19,6 +22,33 @@
'no_whitespace_in_blank_line' => true,
'not_operator_with_successor_space' => true,
'object_operator_without_whitespace' => true,
'ordered_class_elements' => [
'order' => [
'use_trait',
'case',
'constant',
'constant_public',
'constant_protected',
'constant_private',
'property',
'property_static',
'property_public',
'property_protected',
'property_private',
'property_public_readonly',
'property_protected_readonly',
'property_private_readonly',
'property_public_static',
'property_protected_static',
'property_private_static',
'construct',
'destruct',
'magic',
'phpunit',
'method_abstract',
'method',
]
],
'space_after_semicolon' => true,
'strict_comparison' => false,
'ternary_operator_spaces' => true,
Expand Down

0 comments on commit fd1adf8

Please sign in to comment.