From 29e0bebc73a56d8f5fea98c83424e24e04abde95 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 23 Jan 2021 13:27:20 -0800 Subject: [PATCH 1/4] Allow composer to run in local environments even without DB --- .php_cs => .php_cs.dist | 0 composer.json | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename .php_cs => .php_cs.dist (100%) diff --git a/.php_cs b/.php_cs.dist similarity index 100% rename from .php_cs rename to .php_cs.dist diff --git a/composer.json b/composer.json index 987d7d05d..d8e88ef3f 100644 --- a/composer.json +++ b/composer.json @@ -68,6 +68,7 @@ } }, "scripts": { + "php-cs-fixer": "php-cs-fixer fix --diff --diff-format=udiff --config=./.php_cs.dist", "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], @@ -76,7 +77,7 @@ ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", - "@php artisan package:discover" + "@php artisan package:discover || true" ] }, "prefer-stable": true, From 91cdf08489dd23d21412ce1fc2695e1e7753ec80 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 23 Jan 2021 13:37:07 -0800 Subject: [PATCH 2/4] Update .php_cs.dist --- .php_cs.dist | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 2da2c8ee4..bd4535683 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -3,15 +3,7 @@ use PhpCsFixer\Config; use PhpCsFixer\Finder; -$finder = (new Finder)->in([ - 'app', - 'bootstrap', - 'config', - 'database', - 'resources/lang', - 'routes', - 'tests', -]); +$finder = (new Finder)->in(__DIR__)->exclude(['vendor', 'node_modules', 'storage']); return (new Config) ->setRiskyAllowed(true) From b480a9e4e238d51c430144db885144e381dbcb31 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 23 Jan 2021 13:44:35 -0800 Subject: [PATCH 3/4] Make php-cs-fixer work in phpstorm --- .github/workflows/tests.yml | 2 +- .php_cs.dist | 6 ++---- app/Http/Controllers/Admin/Settings/IndexController.php | 3 +-- composer.json | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5db691bc5..adc36412a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -51,7 +51,7 @@ jobs: - name: install dependencies run: composer install --prefer-dist --no-interaction --no-progress - name: run cs-fixer - run: vendor/bin/php-cs-fixer fix --dry-run --diff --diff-format=udiff + run: vendor/bin/php-cs-fixer fix --dry-run --diff --diff-format=udiff --rules=psr_autoloading continue-on-error: true - name: execute unit tests run: vendor/bin/phpunit --bootstrap bootstrap/app.php tests/Unit diff --git a/.php_cs.dist b/.php_cs.dist index bd4535683..3eb33508b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -3,9 +3,9 @@ use PhpCsFixer\Config; use PhpCsFixer\Finder; -$finder = (new Finder)->in(__DIR__)->exclude(['vendor', 'node_modules', 'storage']); +$finder = (new Finder())->in(__DIR__)->exclude(['vendor', 'node_modules', 'storage', 'bootstrap/cache']); -return (new Config) +return (new Config()) ->setRiskyAllowed(true) ->setFinder($finder) ->setRules([ @@ -23,8 +23,6 @@ return (new Config) 'ordered_imports' => [ 'sortAlgorithm' => 'length', ], - 'psr0' => ['dir' => 'app'], - 'psr4' => true, 'random_api_migration' => true, 'ternary_to_null_coalescing' => true, 'yoda_style' => [ diff --git a/app/Http/Controllers/Admin/Settings/IndexController.php b/app/Http/Controllers/Admin/Settings/IndexController.php index 5fb225e9b..190646fd4 100644 --- a/app/Http/Controllers/Admin/Settings/IndexController.php +++ b/app/Http/Controllers/Admin/Settings/IndexController.php @@ -44,8 +44,7 @@ class IndexController extends Controller Kernel $kernel, SettingsRepositoryInterface $settings, SoftwareVersionService $versionService - ) - { + ) { $this->alert = $alert; $this->kernel = $kernel; $this->settings = $settings; diff --git a/composer.json b/composer.json index d8e88ef3f..ab9dd5a0c 100644 --- a/composer.json +++ b/composer.json @@ -68,7 +68,7 @@ } }, "scripts": { - "php-cs-fixer": "php-cs-fixer fix --diff --diff-format=udiff --config=./.php_cs.dist", + "php-cs-fixer": "php-cs-fixer fix --diff --diff-format=udiff --config=./.php_cs.dist --rules=psr_autoloading", "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], From 07798b7366225d0821941c40a97aaaaca1f210d7 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 23 Jan 2021 13:59:52 -0800 Subject: [PATCH 4/4] Update file contents --- .../ServerConfigurationStructureService.php | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/app/Services/Servers/ServerConfigurationStructureService.php b/app/Services/Servers/ServerConfigurationStructureService.php index 0972a4180..46e50e012 100644 --- a/app/Services/Servers/ServerConfigurationStructureService.php +++ b/app/Services/Servers/ServerConfigurationStructureService.php @@ -7,15 +7,10 @@ use Pterodactyl\Models\Server; class ServerConfigurationStructureService { - /** - * @var \Pterodactyl\Services\Servers\EnvironmentService - */ - private $environment; + private EnvironmentService $environment; /** * ServerConfigurationStructureService constructor. - * - * @param \Pterodactyl\Services\Servers\EnvironmentService $environment */ public function __construct(EnvironmentService $environment) { @@ -27,8 +22,6 @@ class ServerConfigurationStructureService * * DO NOT MODIFY THIS FUNCTION. This powers legacy code handling for the new Wings * daemon, if you modify the structure eggs will break unexpectedly. - * - * @param bool $legacy deprecated */ public function handle(Server $server, array $override = [], bool $legacy = false): array { @@ -49,10 +42,8 @@ class ServerConfigurationStructureService /** * Returns the new data format used for the Wings daemon. - * - * @return array */ - protected function returnCurrentFormat(Server $server) + protected function returnCurrentFormat(Server $server): array { return [ 'uuid' => $server->uuid, @@ -89,11 +80,7 @@ class ServerConfigurationStructureService }), 'egg' => [ 'id' => $server->egg->uuid, - 'file_denylist' => [ - 'config.yml', - '**/*.json', - ], - // 'file_denylist' => explode(PHP_EOL, $server->egg->inherit_file_denylist), + 'file_denylist' => explode(PHP_EOL, $server->egg->inherit_file_denylist), ], ]; } @@ -102,11 +89,9 @@ class ServerConfigurationStructureService * Returns the legacy server data format to continue support for old egg configurations * that have not yet been updated. * - * @return array - * * @deprecated */ - protected function returnLegacyFormat(Server $server) + protected function returnLegacyFormat(Server $server): array { return [ 'uuid' => $server->uuid,