Skip to content

Refactor DocBlocks for clarity #2007

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 74 additions & 74 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,78 +1,78 @@
{
"name": "nwidart/laravel-modules",
"description": "Laravel Module management",
"keywords": [
"modules",
"laravel",
"nwidart",
"module",
"rad"
],
"license": "MIT",
"authors": [
{
"name": "Nicolas Widart",
"email": "[email protected]",
"homepage": "https://nicolaswidart.com",
"role": "Developer"
}
],
"require": {
"php": ">=8.2",
"ext-dom": "*",
"ext-json": "*",
"ext-simplexml": "*",
"wikimedia/composer-merge-plugin": "^2.1"
},
"require-dev": {
"phpunit/phpunit": "^11.0",
"mockery/mockery": "^1.6",
"orchestra/testbench": "^v9.0",
"friendsofphp/php-cs-fixer": "^v3.52",
"laravel/framework": "^v11.33",
"laravel/pint": "^1.16",
"spatie/phpunit-snapshot-assertions": "^5.0",
"phpstan/phpstan": "^1.4"
},
"autoload": {
"psr-4": {
"Nwidart\\Modules\\": "src"
"name": "nwidart/laravel-modules",
"description": "Laravel Module management",
"keywords": [
"modules",
"laravel",
"nwidart",
"module",
"rad"
],
"license": "MIT",
"authors": [
{
"name": "Nicolas Widart",
"email": "[email protected]",
"homepage": "https://nicolaswidart.com",
"role": "Developer"
}
],
"require": {
"php": ">=8.2",
"ext-dom": "*",
"ext-json": "*",
"ext-simplexml": "*",
"wikimedia/composer-merge-plugin": "^2.1"
},
"files": [
"src/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Nwidart\\Modules\\Tests\\": "tests",
"Modules\\Recipe\\": "tests/stubs/valid/Recipe"
}
},
"extra": {
"laravel": {
"providers": [
"Nwidart\\Modules\\LaravelModulesServiceProvider"
],
"aliases": {
"Module": "Nwidart\\Modules\\Facades\\Module"
}
"require-dev": {
"phpunit/phpunit": "^11.0",
"mockery/mockery": "^1.6",
"orchestra/testbench": "^v9.0",
"friendsofphp/php-cs-fixer": "^v3.52",
"laravel/framework": "^v11.33",
"laravel/pint": "^1.16",
"spatie/phpunit-snapshot-assertions": "^5.0",
"phpstan/phpstan": "^1.4"
},
"branch-alias": {
"dev-master": "11.0-dev"
}
},
"config": {
"allow-plugins": {
"wikimedia/composer-merge-plugin": true
}
},
"scripts": {
"update-snapshots": "./phpunit --no-coverage -d --update-snapshots",
"lint": "pint",
"test": "phpunit",
"test-coverage": "phpunit --coverage-html coverage",
"pcf": "vendor/bin/php-cs-fixer fix --verbose"
},
"minimum-stability": "dev",
"prefer-stable": true
"autoload": {
"psr-4": {
"Nwidart\\Modules\\": "src"
},
"files": [
"src/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Nwidart\\Modules\\Tests\\": "tests",
"Modules\\Recipe\\": "tests/stubs/valid/Recipe"
}
},
"extra": {
"laravel": {
"providers": [
"Nwidart\\Modules\\LaravelModulesServiceProvider"
],
"aliases": {
"Module": "Nwidart\\Modules\\Facades\\Module"
}
},
"branch-alias": {
"dev-master": "11.0-dev"
}
},
"config": {
"allow-plugins": {
"wikimedia/composer-merge-plugin": true
}
},
"scripts": {
"update-snapshots": "phpunit --no-coverage -d --update-snapshots",
"lint": "pint",
"test": "phpunit",
"test-coverage": "phpunit --coverage-html coverage",
"pcf": "vendor/bin/php-cs-fixer fix --verbose"
},
"minimum-stability": "dev",
"prefer-stable": true
}
2 changes: 1 addition & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
'vite' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME'],
'json' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME', 'MODULE_NAMESPACE', 'PROVIDER_NAMESPACE'],
'views/index' => ['LOWER_NAME'],
'views/master' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME',],
'views/master' => ['LOWER_NAME', 'STUDLY_NAME', 'KEBAB_NAME'],
'scaffold/config' => ['STUDLY_NAME'],
'composer' => [
'LOWER_NAME',
Expand Down
18 changes: 4 additions & 14 deletions src/Activators/FileActivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,23 @@ class FileActivator implements ActivatorInterface
{
/**
* Laravel Filesystem instance
*
* @var Filesystem
*/
private $files;
private Filesystem $files;

/**
* Laravel config instance
*
* @var Config
*/
private $config;
private Config $config;

/**
* Array of modules activation statuses
*
* @var array
*/
private $modulesStatuses;
private array $modulesStatuses;

/**
* File used to store activation statuses
*
* @var string
*/
private $statusesFile;
private string $statusesFile;

public function __construct(Container $app)
{
Expand Down Expand Up @@ -149,8 +141,6 @@ private function readJson(): array

/**
* Reads a config parameter under the 'activators.file' key
*
* @return mixed
*/
private function config(string $key, $default = null)
{
Expand Down
8 changes: 2 additions & 6 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,16 @@ class Collection extends BaseCollection
{
/**
* Get items collections.
*
* @return array
*/
public function getItems()
public function getItems(): array
{
return $this->items;
}

/**
* Get the collection of items as a plain array.
*
* @return array
*/
public function toArray()
public function toArray(): array
{
return array_map(function ($value) {
if ($value instanceof Module) {
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/Actions/CheckLangCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private function getDirectories($module)

private function checkMissingFiles(Collection $directories)
{
//show missing files
// show missing files
$missingFilesMessage = [];

$uniqeLangFiles = $directories->pluck('files')->flatten()->unique()->values();
Expand Down Expand Up @@ -135,7 +135,7 @@ private function checkMissingFiles(Collection $directories)

private function checkMissingKeys(Collection $directories)
{
//show missing keys
// show missing keys
$uniqeLangFiles = $directories->pluck('files')->flatten()->unique();
$langDirectories = $directories->pluck('name');

Expand Down
4 changes: 2 additions & 2 deletions src/Commands/Database/SeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ public function moduleSeed(Module $module)
}
}
} else {
$class = $this->getSeederName($name); //legacy support
$class = $this->getSeederName($name); // legacy support

$class = implode('\\', array_map('ucwords', explode('\\', $class)));

if (class_exists($class)) {
$seeders[] = $class;
} else {
//look at other namespaces
// look at other namespaces
$classes = $this->getSeederNames($name);
foreach ($classes as $class) {
if (class_exists($class)) {
Expand Down
21 changes: 10 additions & 11 deletions src/Commands/UpdatePhpunitCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,31 @@ class UpdatePhpunitCoverage extends Command

/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
$appFolder = config('modules.paths.app_folder', 'app/');
$appFolder = rtrim($appFolder, '/') . '/';
$appFolder = rtrim($appFolder, '/').'/';
$phpunitXmlPath = base_path('phpunit.xml');
$modulesStatusPath = base_path('modules_statuses.json');

if (!file_exists($phpunitXmlPath)) {
if (! file_exists($phpunitXmlPath)) {
$this->error("phpunit.xml file not found: {$phpunitXmlPath}");

return 100;
}

if (!file_exists($modulesStatusPath)) {
if (! file_exists($modulesStatusPath)) {
$this->error("Modules statuses file not found: {$modulesStatusPath}");

return 99;
}

$enabledModules = json_decode(file_get_contents($modulesStatusPath), true);

if (json_last_error() !== JSON_ERROR_NONE) {
$this->error("Error decoding JSON from {$modulesStatusPath}: " . json_last_error_msg());
$this->error("Error decoding JSON from {$modulesStatusPath}: ".json_last_error_msg());

return 98;
}

Expand All @@ -55,15 +56,13 @@ public function handle(): int

foreach ($enabledModules as $module => $status) {
if ($status) { // Only add enabled modules
$moduleDir = $modulesPath . $module . '/' . $appFolder;
$moduleDir = $modulesPath.$module.'/'.$appFolder;
if (is_dir($moduleDir)) {
$moduleDirs[] = $moduleDir;
}
}
}



$phpunitXml = simplexml_load_file($phpunitXmlPath);

$sourceInclude = $phpunitXml->xpath('//source/include')[0];
Expand All @@ -77,13 +76,13 @@ public function handle(): int
$directory->addAttribute('suffix', '.php');
}

$dom = new DOMDocument();
$dom = new DOMDocument;
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($phpunitXml->asXML());
$dom->save($phpunitXmlPath);

$this->info("phpunit.xml updated with enabled module directories.");
$this->info('phpunit.xml updated with enabled module directories.');

return 0;
}
Expand Down
4 changes: 1 addition & 3 deletions src/Contracts/ConfirmableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

namespace Nwidart\Modules\Contracts;

interface ConfirmableCommand
{
}
interface ConfirmableCommand {}
2 changes: 0 additions & 2 deletions src/Contracts/PublisherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ interface PublisherInterface
{
/**
* Publish something.
*
* @return mixed
*/
public function publish();
}
Loading
Loading