Skip to content

Commit

Permalink
Update php coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia committed Sep 10, 2023
1 parent 2097d8d commit 228b7b9
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 94 deletions.
98 changes: 14 additions & 84 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,100 +5,30 @@
* This file is part of laravel-horizon-restart.
*
* @link https://github.com/huangdijia/laravel-horizon-restart
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/2.x/README.md
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/main/README.md
* @contact [email protected]
*/
$header = <<<'EOF'
This file is part of laravel-horizon-restart.
use Huangdijia\PhpCsFixer\Config;

@link https://github.com/huangdijia/laravel-horizon-restart
@document https://github.com/huangdijia/laravel-horizon-restart/blob/2.x/README.md
@contact [email protected]
EOF;
require __DIR__ . '/vendor/autoload.php';

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'@Symfony' => true,
'@DoctrineAnnotation' => true,
'@PhpCsFixer' => true,
'header_comment' => [
'comment_type' => 'PHPDoc',
'header' => $header,
'separate' => 'none',
'location' => 'after_declare_strict',
return (new Config())
->setHeaderComment(
projectName: 'laravel-horizon-restart',
projectLink: 'https://github.com/huangdijia/laravel-horizon-restart',
projectDocument: 'https://github.com/huangdijia/laravel-horizon-restart/blob/main/README.md',
contacts: [
'[email protected]',
],
'array_syntax' => [
'syntax' => 'short',
],
'list_syntax' => [
'syntax' => 'short',
],
'concat_space' => [
'spacing' => 'one',
],
'blank_line_before_statement' => [
'statements' => [
'declare',
],
],
'general_phpdoc_annotation_remove' => [
'annotations' => [
'author',
],
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => null,
],
'ordered_imports' => [
'imports_order' => [
'class', 'function', 'const',
],
'sort_algorithm' => 'alpha',
],
'single_line_comment_style' => [
'comment_types' => [
],
],
'yoda_style' => [
'always_move_variable' => false,
'equal' => false,
'identical' => false,
],
'phpdoc_align' => [
'align' => 'left',
],
'multiline_whitespace_before_semicolons' => [
'strategy' => 'no_multi_line',
],
'constant_case' => [
'case' => 'lower',
],
'class_attributes_separation' => true,
'combine_consecutive_unsets' => true,
'declare_strict_types' => true,
'linebreak_after_opening_tag' => true,
'lowercase_static_reference' => true,
'no_useless_else' => true,
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'not_operator_with_space' => false,
'ordered_class_elements' => true,
'php_unit_strict' => false,
'phpdoc_separation' => false,
'single_quote' => true,
'standardize_not_equals' => true,
'multiline_comment_opening_closing' => true,
])
)
->setFinder(
PhpCsFixer\Finder::create()
->exclude('bin')
->exclude('public')
->exclude('runtime')
->exclude('vendor')
->in(__DIR__)
->append([
__FILE__,
])
)
->setUsingCache(false);
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"editor.formatOnSave": true,
"editor.defaultFormatter": "junstyle.php-cs-fixer",
},
"php-cs-fixer.executablePath": "php-cs-fixer",
"php-cs-fixer.executablePath": "${workspaceRoot}/vendor/bin/php-cs-fixer",
"php-cs-fixer.executablePathWindows": "php-cs-fixer",
"php-cs-fixer.onsave": true,
"php-cs-fixer.rules": "@PSR2",
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"laravel/horizon": "^5.0|^6.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^1.0",
"laravel/framework": "^10.0",
"pestphp/pest":"^2.0",
"pestphp/pest-plugin-laravel": "^2.0"
"pestphp/pest-plugin-laravel": "^2.0",
"huangdijia/php-coding-standard": "1.2.x-dev"
},
"autoload": {
"psr-4": {
Expand All @@ -33,7 +33,7 @@
},
"extra": {
"branch-alias": {
"3.x-dev": "3.0-dev"
"dev-main": "3.0-dev"
},
"laravel": {
"providers": [
Expand Down
3 changes: 2 additions & 1 deletion src/Console/RestartCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* This file is part of laravel-horizon-restart.
*
* @link https://github.com/huangdijia/laravel-horizon-restart
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/2.x/README.md
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/main/README.md
* @contact [email protected]
*/

namespace Huangdijia\Horizon\Console;

use Huangdijia\Horizon\Jobs\HorizonRestartJob;
Expand Down
3 changes: 2 additions & 1 deletion src/Jobs/HorizonRestartJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* This file is part of laravel-horizon-restart.
*
* @link https://github.com/huangdijia/laravel-horizon-restart
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/2.x/README.md
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/main/README.md
* @contact [email protected]
*/

namespace Huangdijia\Horizon\Jobs;

use Illuminate\Bus\Queueable;
Expand Down
3 changes: 2 additions & 1 deletion src/RestartServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* This file is part of laravel-horizon-restart.
*
* @link https://github.com/huangdijia/laravel-horizon-restart
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/2.x/README.md
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/main/README.md
* @contact [email protected]
*/

namespace Huangdijia\Horizon;

use Illuminate\Support\ServiceProvider;
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is part of laravel-horizon-restart.
*
* @link https://github.com/huangdijia/laravel-horizon-restart
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/2.x/README.md
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/main/README.md
* @contact [email protected]
*/
test('example', function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* This file is part of laravel-horizon-restart.
*
* @link https://github.com/huangdijia/laravel-horizon-restart
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/2.x/README.md
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/main/README.md
* @contact [email protected]
*/
use Illuminate\Foundation\Testing\TestCase;
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* This file is part of laravel-horizon-restart.
*
* @link https://github.com/huangdijia/laravel-horizon-restart
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/2.x/README.md
* @document https://github.com/huangdijia/laravel-horizon-restart/blob/main/README.md
* @contact [email protected]
*/

namespace Tests;

use PHPUnit\Framework\TestCase as BaseTestCase;
Expand Down

0 comments on commit 228b7b9

Please sign in to comment.