Skip to content

Commit

Permalink
Fix remaining code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Dec 7, 2024
1 parent 47fbf2a commit 9d1b92f
Show file tree
Hide file tree
Showing 19 changed files with 160 additions and 128 deletions.
2 changes: 1 addition & 1 deletion modules/backend/widgets/Lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ public function getColumnValue($record, $column)
{
$value = $this->getColumnValueRaw($record, $column);

$customMethod = 'eval'. studly_case($column->type) .'TypeValue';
$customMethod = 'eval' . studly_case($column->type) . 'TypeValue';
if ($this->methodExists($customMethod)) {
$value = $this->{$customMethod}($record, $column, $value);
} else {
Expand Down
2 changes: 1 addition & 1 deletion modules/cms/classes/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public static function resolveMenuItem(object $item, string $url, Theme $theme,
return null;
}

$controller = Controller::getController() ?: new Controller;
$controller = Controller::getController() ?: new Controller();
$pageUrl = $controller->pageUrl($item->reference, [], $routePersistence);

$result = [];
Expand Down
2 changes: 1 addition & 1 deletion modules/cms/classes/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ public function getDatasource(): DatasourceInterface
public function __get($name)
{
if (in_array(strtolower($name), ['id', 'path', 'dirname', 'config', 'formconfig', 'previewimageurl'])) {
$method = 'get'. ucfirst($name);
$method = 'get' . ucfirst($name);
return $this->$method();
}

Expand Down
12 changes: 6 additions & 6 deletions modules/cms/console/CreateTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ protected function tailwindPostCreate(string $processor): void
'--no-interaction' => true,
'--force' => true,
'--silent' => true,
'--tailwind' => true
]
'--tailwind' => true,
],
],
// Ensure all require packages are available for the new theme and add the new theme to our npm workspaces
$processor . ':install' => [
Expand All @@ -188,8 +188,8 @@ protected function tailwindPostCreate(string $processor): void
'assetPackage' => ['theme-' . $this->getNameInput()],
'--no-interaction' => true,
'--silent' => false,
'--disable-tty' => true
]
'--disable-tty' => true,
],
],
// Run an initial compile to ensure styles are available for first load
$processor . ':compile' => [
Expand All @@ -198,8 +198,8 @@ protected function tailwindPostCreate(string $processor): void
'--package' => ['theme-' . $this->getNameInput()],
'--no-interaction' => true,
'--silent' => true,
]
]
],
],
];

foreach ($commands as $command => $data) {
Expand Down
2 changes: 1 addition & 1 deletion modules/system/classes/asset/PackageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public function registerPackage(string $name, string $path, string $type = 'mix'
$this->packages[$type][$name] = [
'path' => $path,
'package' => $package,
'config' => $config
'config' => $config,
];
}

Expand Down
4 changes: 2 additions & 2 deletions modules/system/console/CreateFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace System\Console;
<?php

use System\Console\BaseScaffoldCommand;
namespace System\Console;

class CreateFactory extends BaseScaffoldCommand
{
Expand Down
1 change: 0 additions & 1 deletion modules/system/console/asset/npm/NpmInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace System\Console\Asset\Npm;

use System\Console\Asset\Npm\NpmCommand;
use Winter\Storm\Exception\SystemException;

class NpmInstall extends NpmCommand
Expand Down
4 changes: 1 addition & 3 deletions modules/system/console/asset/npm/NpmRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace System\Console\Asset\Npm;

use System\Console\Asset\Npm\NpmCommand;

class NpmRun extends NpmCommand
{
/**
Expand Down Expand Up @@ -31,7 +29,7 @@ class NpmRun extends NpmCommand
* @var array List of commands that this command replaces (aliases)
*/
protected $replaces = [
'mix:run'
'mix:run',
];

/**
Expand Down
3 changes: 1 addition & 2 deletions modules/system/console/asset/npm/NpmUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace System\Console\Asset\Npm;

use System\Console\Asset\Npm\NpmCommand;
use Winter\Storm\Exception\SystemException;

class NpmUpdate extends NpmCommand
Expand Down Expand Up @@ -32,7 +31,7 @@ class NpmUpdate extends NpmCommand
* @inheritDoc
*/
public $replaces = [
'mix:update'
'mix:update',
];

/**
Expand Down
1 change: 0 additions & 1 deletion modules/system/console/asset/npm/NpmVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace System\Console\Asset\Npm;

use Symfony\Component\Process\Process;
use System\Console\Asset\Npm\NpmCommand;

class NpmVersion extends NpmCommand
{
Expand Down
2 changes: 0 additions & 2 deletions modules/system/console/asset/vite/ViteWatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace System\Console\Asset\Vite;

use Winter\Storm\Support\Facades\File;

class ViteWatch extends ViteCompile
{
/**
Expand Down
3 changes: 1 addition & 2 deletions modules/system/tests/console/CreateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

namespace System\Tests\Console;

use File;
use InvalidArgumentException;
use System\Tests\Bootstrap\TestCase;
use Winter\Storm\Support\Facades\File;

class CreateCommandTest extends TestCase
{
Expand Down
18 changes: 9 additions & 9 deletions modules/system/tests/console/asset/mix/MixInstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testMixInstallMissingPackageJson(): void
$this->artisan('mix:install', [
'assetPackage' => ['theme-assettest'],
'--package-json' => '/some/file',
'--no-install' => true
'--no-install' => true,
])
->expectsOutputToContain('The supplied --package-json path does not exist.')
->assertExitCode(1);
Expand All @@ -58,7 +58,7 @@ public function testMixInstallSinglePackage(): void
$this->artisan('mix:install', [
'assetPackage' => ['theme-assettest'],
'--package-json' => $this->jsonPath,
'--no-install' => true
'--no-install' => true,
])
->expectsQuestion('laravel-mix was not found as a dependency in package.json, would you like to add it?', true)
->expectsOutput('Adding theme-assettest (modules/system/tests/fixtures/themes/assettest) to the workspaces.packages property in package.json')
Expand All @@ -81,7 +81,7 @@ public function testMixInstallMultiplePackages(): void
$this->artisan('mix:install', [
'assetPackage' => ['theme-assettest', 'theme-npmtest'],
'--package-json' => $this->jsonPath,
'--no-install' => true
'--no-install' => true,
])
->expectsQuestion('laravel-mix was not found as a dependency in package.json, would you like to add it?', true)
->expectsOutput('Adding theme-assettest (modules/system/tests/fixtures/themes/assettest) to the workspaces.packages property in package.json')
Expand Down Expand Up @@ -109,7 +109,7 @@ public function testMixInstallMissingPackage(): void
$this->artisan('mix:install', [
'assetPackage' => ['theme-assettest2'],
'--package-json' => $this->jsonPath,
'--no-install' => true
'--no-install' => true,
])
->assertExitCode(1);
});
Expand All @@ -121,7 +121,7 @@ public function testMixInstallRelativePath(): void
$this->artisan('mix:install', [
'assetPackage' => ['theme-assettest'],
'--package-json' => 'modules/system/tests/package.json',
'--no-install' => true
'--no-install' => true,
])
->expectsQuestion('laravel-mix was not found as a dependency in package.json, would you like to add it?', true)
->expectsOutput('Adding theme-assettest (modules/system/tests/fixtures/themes/assettest) to the workspaces.packages property in package.json')
Expand All @@ -135,15 +135,15 @@ public function testMixInstallIgnoredPackage(): void
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
$packageJson['workspaces'] = [
'ignoredPackages' => [
'modules/system/tests/fixtures/themes/assettest'
]
'modules/system/tests/fixtures/themes/assettest',
],
];
File::put($this->jsonPath, json_encode($packageJson, JSON_PRETTY_PRINT));

$this->artisan('mix:install', [
'assetPackage' => ['theme-assettest'],
'--package-json' => $this->jsonPath,
'--no-install' => true
'--no-install' => true,
])
->expectsQuestion('laravel-mix was not found as a dependency in package.json, would you like to add it?', false)
->expectsOutput('The requested package theme-assettest (modules/system/tests/fixtures/themes/assettest) is ignored, remove it from package.json to continue.')
Expand All @@ -165,7 +165,7 @@ public function testMixInstallWithNpmInstall(): void
$this->artisan('mix:install', [
'assetPackage' => ['theme-assettest'],
'--package-json' => $this->jsonPath,
'--disable-tty' => true
'--disable-tty' => true,
])
->expectsQuestion('laravel-mix was not found as a dependency in package.json, would you like to add it?', true)
->expectsOutput('Adding theme-assettest (modules/system/tests/fixtures/themes/assettest) to the workspaces.packages property in package.json')
Expand Down
8 changes: 4 additions & 4 deletions modules/system/tests/console/asset/npm/NpmInstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testNpmInstallSingle(): void
$this->artisan('npm:install', [
'package' => 'theme-npmtest',
'npmArgs' => ['is-odd'],
'--disable-tty' => true
'--disable-tty' => true,
])
->assertExitCode(0);

Expand Down Expand Up @@ -92,7 +92,7 @@ public function testNpmInstallMultiple(): void
$this->artisan('npm:install', [
'package' => 'theme-npmtest',
'npmArgs' => ['is-odd', 'is-even'],
'--disable-tty' => true
'--disable-tty' => true,
])
->assertExitCode(0);

Expand Down Expand Up @@ -132,7 +132,7 @@ public function testNpmInstallSingleDev(): void
'package' => 'theme-npmtest',
'npmArgs' => ['is-odd'],
'--dev' => true,
'--disable-tty' => true
'--disable-tty' => true,
])
->assertExitCode(0);

Expand Down Expand Up @@ -169,7 +169,7 @@ public function testNpmInstallMultipleDev(): void
'package' => 'theme-npmtest',
'npmArgs' => ['is-odd', 'is-even'],
'--dev' => true,
'--disable-tty' => true
'--disable-tty' => true,
])
->assertExitCode(0);

Expand Down
4 changes: 2 additions & 2 deletions modules/system/tests/console/asset/npm/NpmRunTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testNpmRunScript(): void
$this->artisan('npm:run', [
'package' => 'theme-npmtest',
'script' => 'testScript',
'--disable-tty' => true
'--disable-tty' => true,
])
->expectsOutputToContain('> echo "Winter says $((1+2))"')
->expectsOutputToContain('Winter says 3')
Expand All @@ -47,7 +47,7 @@ public function testNpmRunScriptFailed(): void
$this->artisan('npm:run', [
'package' => 'theme-npmtest',
'script' => 'testMissingScript',
'--disable-tty' => true
'--disable-tty' => true,
])
->expectsOutputToContain('Script "testMissingScript" is not defined in package "theme-npmtest"')
->assertExitCode(1);
Expand Down
4 changes: 2 additions & 2 deletions modules/system/tests/console/asset/npm/NpmUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public function testNpmUpdate(): void
// Update the contents of package.json to include a package at an old patch
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
$packageJson['dependencies'] = [
'is-odd' => '^3.0.0'
'is-odd' => '^3.0.0',
];
File::put($this->jsonPath, json_encode($packageJson, JSON_PRETTY_PRINT));

// Run npm update
$this->artisan('npm:update', [
'package' => 'theme-npmtest',
'--save' => true,
'--disable-tty' => true
'--disable-tty' => true,
])
->assertExitCode(0);

Expand Down
19 changes: 10 additions & 9 deletions modules/system/tests/console/asset/vite/ViteInstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class ViteInstallTest extends TestCase
{
protected string $fixturePath;
protected string $jsonPath;
protected string $lockPath;
protected string $backupPath;
Expand Down Expand Up @@ -45,7 +46,7 @@ public function testViteInstallMissingPackageJson(): void
$this->artisan('vite:install', [
'assetPackage' => ['theme-assettest'],
'--package-json' => '/some/file',
'--no-install' => true
'--no-install' => true,
])
->expectsOutputToContain('The supplied --package-json path does not exist.')
->assertExitCode(1);
Expand All @@ -57,7 +58,7 @@ public function testViteInstallSinglePackage(): void
$this->artisan('vite:install', [
'assetPackage' => ['theme-assettest'],
'--package-json' => $this->jsonPath,
'--no-install' => true
'--no-install' => true,
])
->expectsQuestion('vite was not found as a dependency in package.json, would you like to add it?', true)
->expectsQuestion('laravel-vite-plugin was not found as a dependency in package.json, would you like to add it?', true)
Expand All @@ -82,7 +83,7 @@ public function testViteInstallMultiplePackages(): void
$this->artisan('vite:install', [
'assetPackage' => ['theme-assettest', 'theme-npmtest'],
'--package-json' => $this->jsonPath,
'--no-install' => true
'--no-install' => true,
])
->expectsQuestion('vite was not found as a dependency in package.json, would you like to add it?', true)
->expectsQuestion('laravel-vite-plugin was not found as a dependency in package.json, would you like to add it?', true)
Expand Down Expand Up @@ -113,7 +114,7 @@ public function testViteInstallMissingPackage(): void
$this->artisan('vite:install', [
'assetPackage' => ['theme-assettest2'],
'--package-json' => $this->jsonPath,
'--no-install' => true
'--no-install' => true,
])
->assertExitCode(1);
});
Expand All @@ -125,7 +126,7 @@ public function testViteInstallRelativePath(): void
$this->artisan('vite:install', [
'assetPackage' => ['theme-assettest'],
'--package-json' => 'modules/system/tests/package.json',
'--no-install' => true
'--no-install' => true,
])
->expectsQuestion('vite was not found as a dependency in package.json, would you like to add it?', true)
->expectsQuestion('laravel-vite-plugin was not found as a dependency in package.json, would you like to add it?', true)
Expand All @@ -140,16 +141,16 @@ public function testViteInstallIgnoredPackage(): void
$packageJson = json_decode(File::get($this->jsonPath), JSON_OBJECT_AS_ARRAY);
$packageJson['workspaces'] = [
'ignoredPackages' => [
'modules/system/tests/fixtures/themes/assettest'
]
'modules/system/tests/fixtures/themes/assettest',
],
];

File::put($this->jsonPath, json_encode($packageJson, JSON_PRETTY_PRINT));

$this->artisan('vite:install', [
'assetPackage' => ['theme-assettest'],
'--package-json' => $this->jsonPath,
'--no-install' => true
'--no-install' => true,
])
->expectsQuestion('vite was not found as a dependency in package.json, would you like to add it?', false)
->expectsQuestion('laravel-vite-plugin was not found as a dependency in package.json, would you like to add it?', false)
Expand All @@ -172,7 +173,7 @@ public function testViteInstallWithNpmInstall(): void
$this->artisan('vite:install', [
'assetPackage' => ['theme-assettest'],
'--package-json' => $this->jsonPath,
'--disable-tty' => true
'--disable-tty' => true,
])
->expectsQuestion('vite was not found as a dependency in package.json, would you like to add it?', true)
->expectsQuestion('laravel-vite-plugin was not found as a dependency in package.json, would you like to add it?', true)
Expand Down
Loading

0 comments on commit 9d1b92f

Please sign in to comment.