Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce PSR-12 and organise imports on Winter CMS core files #1188

Draft
wants to merge 32 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e7ebbb2
Enforce PSR-12 on Winter CMS core files
bennothommo Aug 23, 2024
66bd3f3
Additional code style fixes to improve future diffs and IDE support
bennothommo Aug 23, 2024
dbf6019
Use Composer-derived PHPCS, udpate GitHub Actions
bennothommo Aug 23, 2024
ce14395
Update GitHub Actions
bennothommo Aug 23, 2024
87171ca
Reset modules before checking code quality
bennothommo Aug 23, 2024
e23c0b2
Exclude some rules for partials and views
bennothommo Aug 23, 2024
b2ffbe9
Add rule for array indentation
bennothommo Aug 23, 2024
7b72f82
Fix reference to File facade
bennothommo Aug 23, 2024
2643609
Merge branch 'develop' into fix/psr-12
bennothommo Sep 2, 2024
52a824f
Split off Winter CMS code style ruleset to its own XML
bennothommo Sep 2, 2024
a6b814b
Remove partial from exclusion list
bennothommo Sep 2, 2024
236c459
Add "winter:sniff" command
bennothommo Sep 2, 2024
47fbf2a
Merge branch 'develop' into fix/psr-12
bennothommo Dec 7, 2024
9d1b92f
Fix remaining code smells
bennothommo Dec 7, 2024
b1a5a79
Change alias command
bennothommo Dec 7, 2024
1da2568
Add support for `--fix` option to `sniff` command
LukeTowers Dec 7, 2024
51af67d
Alias `winter:test` to `test`
LukeTowers Dec 7, 2024
0ae77a8
Improve / relocate PHPCS stubs
LukeTowers Dec 11, 2024
1dd04fc
Update composer scripts
LukeTowers Dec 11, 2024
f2e7289
Add class constant visibility
LukeTowers Dec 11, 2024
041dbb1
Fix remaining warnings
LukeTowers Dec 11, 2024
61b127f
Add progress flag to phpcs
LukeTowers Dec 11, 2024
33a1518
Add initial version of NoGlobalAliasesSniffTest
LukeTowers Dec 16, 2024
afedfb9
Add support for --parallel option to winter:sniff
LukeTowers Dec 16, 2024
69f19e3
Fix remaining global imports
LukeTowers Dec 16, 2024
bace8e7
Ignore the project's phpcs.xml file when exporting it as a new project
LukeTowers Dec 16, 2024
16d7cc2
Fix overzealous find/replace
LukeTowers Dec 16, 2024
09b945e
Remove debug code
LukeTowers Dec 16, 2024
02c8469
Use Winter's Url facade instead of Laravel's
LukeTowers Dec 16, 2024
6fe5671
Typo fix
LukeTowers Dec 17, 2024
fb92ce3
Allow use statements to reference classes in the same namespace
LukeTowers Dec 17, 2024
27207c2
Fix default scaffolding stub files to conform to coding standard
LukeTowers Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 10 additions & 3 deletions .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
access_token: ${{ github.token }}

- name: Checkout changes
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -29,7 +29,14 @@ jobs:
with:
php-version: 8.0
extensions: curl, fileinfo, gd, mbstring, openssl, pdo, pdo_sqlite, sqlite3, xml, zip
tools: phpcs

- name: Install Composer dependencies
run: composer install --no-interaction --no-progress --no-scripts

- name: Reset modules
run: |
git reset --hard
git clean -fd

- name: Run code quality checks (on push)
if: github.event_name == 'push'
Expand All @@ -43,7 +50,7 @@ jobs:
name: JavaScript
steps:
- name: Checkout changes
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
40 changes: 2 additions & 38 deletions .github/workflows/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,15 @@ jobs:
extensions: curl, fileinfo, gd, mbstring, openssl, pdo, pdo_sqlite, sqlite3, xml, zip
key: winter-cms-cache-develop
steps:
- name: Cancel previous incomplete runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout changes
uses: actions/checkout@v3

- name: Setup extension cache
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ env.phpVersion }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.phpVersion }}
extensions: ${{ env.extensions }}

- name: Setup dependency cache
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-interaction --no-progress --no-scripts

Expand All @@ -74,13 +43,8 @@ jobs:
runs-on: ubuntu-latest
needs: updateManifest
steps:
- name: Cancel previous incomplete runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
LukeTowers marked this conversation as resolved.
Show resolved Hide resolved

- name: Checkout changes
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: wintercms/meta
ref: master
Expand Down
65 changes: 6 additions & 59 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
- develop
pull_request:

concurrency:
group: phpunit-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
frontendTests:
strategy:
Expand All @@ -28,22 +32,7 @@ jobs:
access_token: ${{ github.token }}

- name: Checkout changes
uses: actions/checkout@v3

- name: Setup extension cache
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ env.phpVersion }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
Expand All @@ -64,17 +53,6 @@ jobs:
if: github.head_ref == '1.2' || github.ref == 'refs/heads/1.2' || github.base_ref == '1.2'
run: php ./.github/workflows/utilities/library-switcher "1.2.x-dev as 1.2"

- name: Setup dependency cache
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-interaction --no-progress --no-scripts

Expand Down Expand Up @@ -104,28 +82,8 @@ jobs:
extensions: curl, fileinfo, gd, mbstring, openssl, pdo, pdo_sqlite, sqlite3, xml, zip
key: winter-cms-cache-develop
steps:
- name: Cancel previous incomplete runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout changes
uses: actions/checkout@v2

- name: Setup extension cache
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.phpVersion }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}

- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
Expand All @@ -149,17 +107,6 @@ jobs:
if: github.head_ref == '1.2' || github.ref == 'refs/heads/1.2' || github.base_ref == '1.2'
run: php ./.github/workflows/utilities/library-switcher "1.2.x-dev as 1.2"

- name: Setup dependency cache
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-interaction --no-progress --no-scripts

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/utilities/phpcs-pr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (!count($files)) {
}

// Run all changed files through the PHPCS code sniffer and generate a CSV report
$csv = shell_exec('phpcs --colors -nq --report="csv" --extensions="php" ' . implode(' ', $files));
$csv = shell_exec('./vendor/bin/phpcs --colors -nq --report="csv" --extensions="php" ' . implode(' ', $files));
$lines = array_map(function ($row) {
return array_map(function ($column) {
return trim($column, '"');
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/utilities/phpcs-push
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (!count($files)) {
}

// Run all changed files through the PHPCS code sniffer and generate a CSV report
$csv = shell_exec('phpcs --colors -nq --report="csv" --extensions="php" ' . implode(' ', $files));
$csv = shell_exec('./vendor/bin/phpcs --colors -nq --report="csv" --extensions="php" ' . implode(' ', $files));
$lines = array_map(function ($row) {
return array_map(function ($column) {
return trim($column, '"');
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

$app = new Winter\Storm\Foundation\Application(
realpath(__DIR__.'/../')
realpath(__DIR__ . '/../')
);

/*
Expand Down
6 changes: 3 additions & 3 deletions bootstrap/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
|
*/

$helperPath = __DIR__.'/../vendor/winter/storm/src/Support/helpers.php';
$helperPath = __DIR__ . '/../vendor/winter/storm/src/Support/helpers.php';

if (!file_exists($helperPath)) {
echo 'Missing vendor files, try running "composer install" or use the Wizard installer.'.PHP_EOL;
echo 'Missing vendor files, try running "composer install" or use the Wizard installer.' . PHP_EOL;
exit(1);
}

Expand All @@ -34,4 +34,4 @@
|
*/

require __DIR__.'/../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"mockery/mockery": "^1.4.4",
"fakerphp/faker": "^1.9.2",
"squizlabs/php_codesniffer": "^3.2",
"slevomat/coding-standard": "^8.15.0",
LukeTowers marked this conversation as resolved.
Show resolved Hide resolved
"php-parallel-lint/php-parallel-lint": "^1.0",
"dms/phpunit-arraysubset-asserts": "^0.1.0|^0.2.1"
},
Expand Down Expand Up @@ -79,7 +80,8 @@
"config": {
"allow-plugins": {
"composer/installers": true,
"wikimedia/composer-merge-plugin": true
"wikimedia/composer-merge-plugin": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
*/

'asset_url' => env('ASSET_URL', null),

/*
|--------------------------------------------------------------------------
| Temporary Path
Expand Down
34 changes: 18 additions & 16 deletions modules/backend/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php namespace Backend;
<?php

namespace Backend;

use Backend;
use BackendMenu;
use BackendAuth;
use Backend\Models\UserRole;
use Backend\Classes\WidgetManager;
use System\Classes\MailManager;
use Backend\Facades\Backend;
use Backend\Facades\BackendAuth;
use Backend\Facades\BackendMenu;
use Backend\Models\UserRole;
use System\Classes\CombineAssets;
use System\Classes\MailManager;
use System\Classes\SettingsManager;
use Winter\Storm\Support\ModuleServiceProvider;

Expand Down Expand Up @@ -117,16 +119,16 @@ protected function registerBackendNavigation()
'iconSvg' => 'modules/backend/assets/images/dashboard-icon.svg',
'url' => Backend::url('backend'),
'permissions' => ['backend.access_dashboard'],
'order' => 10
'order' => 10,
],
'media' => [
'label' => 'backend::lang.media.menu_label',
'icon' => 'icon-folder',
'iconSvg' => 'modules/backend/assets/images/media-icon.svg',
'url' => Backend::url('backend/media'),
'permissions' => ['media.*'],
'order' => 200
]
'order' => 200,
],
]);
$manager->registerOwnerAlias('Winter.Backend', 'October.Backend');
});
Expand All @@ -140,7 +142,7 @@ protected function registerBackendReportWidgets()
WidgetManager::instance()->registerReportWidgets(function ($manager) {
$manager->registerReportWidget(\Backend\ReportWidgets\Welcome::class, [
'label' => 'backend::lang.dashboard.welcome.widget_title_default',
'context' => 'dashboard'
'context' => 'dashboard',
]);
});
}
Expand Down Expand Up @@ -248,7 +250,7 @@ protected function registerBackendSettings()
'class' => 'Backend\Models\BrandSetting',
'permissions' => ['backend.manage_branding'],
'order' => 500,
'keywords' => 'brand style'
'keywords' => 'brand style',
],
'editor' => [
'label' => 'backend::lang.editor.menu_label',
Expand All @@ -258,7 +260,7 @@ protected function registerBackendSettings()
'class' => 'Backend\Models\EditorSetting',
'permissions' => ['backend.manage_editor'],
'order' => 500,
'keywords' => 'html code class style'
'keywords' => 'html code class style',
],
'myaccount' => [
'label' => 'backend::lang.myaccount.menu_label',
Expand All @@ -268,7 +270,7 @@ protected function registerBackendSettings()
'url' => Backend::url('backend/users/myaccount'),
'order' => 500,
'context' => 'mysettings',
'keywords' => 'backend::lang.myaccount.menu_keywords'
'keywords' => 'backend::lang.myaccount.menu_keywords',
],
'preferences' => [
'label' => 'backend::lang.backend_preferences.menu_label',
Expand All @@ -278,7 +280,7 @@ protected function registerBackendSettings()
'url' => Backend::url('backend/preferences'),
'permissions' => ['backend.manage_preferences'],
'order' => 510,
'context' => 'mysettings'
'context' => 'mysettings',
],
'access_logs' => [
'label' => 'backend::lang.access_log.menu_label',
Expand All @@ -287,8 +289,8 @@ protected function registerBackendSettings()
'icon' => 'icon-lock',
'url' => Backend::url('backend/accesslogs'),
'permissions' => ['system.access_logs'],
'order' => 920
]
'order' => 920,
],
]);
$manager->registerOwnerAlias('Winter.Backend', 'October.Backend');
});
Expand Down
Loading
Loading