diff --git a/config/currency.php b/config/currency.php index 258643fa..14c3a556 100755 --- a/config/currency.php +++ b/config/currency.php @@ -1,5 +1,10 @@ [ 'fixerio' => [ - 'class' => \Igniter\Flame\Currency\Converters\FixerIO::class, + 'class' => FixerIO::class, 'apiKey' => '', ], 'openexchangerates' => [ - 'class' => \Igniter\Flame\Currency\Converters\OpenExchangeRates::class, + 'class' => OpenExchangeRates::class, 'apiKey' => '', ], @@ -56,7 +61,7 @@ | */ - 'model' => \Igniter\System\Models\Currency::class, + 'model' => Currency::class, /* |-------------------------------------------------------------------------- @@ -114,7 +119,7 @@ 'formatters' => [ 'php_intl' => [ - 'class' => \Igniter\Flame\Currency\Formatters\PHPIntl::class, + 'class' => PHPIntl::class, ], ], diff --git a/database/migrations/admin/2022_06_30_010000_drop_foreign_key_constraints_on_all_tables.php b/database/migrations/admin/2022_06_30_010000_drop_foreign_key_constraints_on_all_tables.php index 9ee5bb8e..42f32d96 100644 --- a/database/migrations/admin/2022_06_30_010000_drop_foreign_key_constraints_on_all_tables.php +++ b/database/migrations/admin/2022_06_30_010000_drop_foreign_key_constraints_on_all_tables.php @@ -32,7 +32,7 @@ protected function dropForeignKey($tableName, $options) $table->dropForeignKeyIfExists($foreignKey); $table->dropIndexIfExists(sprintf('%s_%s_foreign', $tableName, $foreignKey)); }); - } catch (\Exception $ex) { + } catch (Exception $ex) { Log::error($ex); } } diff --git a/database/migrations/system/2018_06_12_000300_rename_model_class_names_to_morph_map_custom_names.php b/database/migrations/system/2018_06_12_000300_rename_model_class_names_to_morph_map_custom_names.php index c82b9d96..f3c7044b 100644 --- a/database/migrations/system/2018_06_12_000300_rename_model_class_names_to_morph_map_custom_names.php +++ b/database/migrations/system/2018_06_12_000300_rename_model_class_names_to_morph_map_custom_names.php @@ -1,5 +1,6 @@ morphMap = array_flip($morphMap); $this->updateMorphClassName([ diff --git a/database/migrations/system/2018_10_19_000300_create_media_attachments_table.php b/database/migrations/system/2018_10_19_000300_create_media_attachments_table.php index e0f75a23..cacbefd9 100644 --- a/database/migrations/system/2018_10_19_000300_create_media_attachments_table.php +++ b/database/migrations/system/2018_10_19_000300_create_media_attachments_table.php @@ -82,7 +82,7 @@ protected function createMediaAttachment($path, $tagName, $modelClass) $media->save(); $model->media()->save($media); - } catch (\Exception $ex) { + } catch (Exception $ex) { Log::debug($ex); } } diff --git a/database/migrations/system/2022_06_30_010000_drop_foreign_key_constraints_on_all_tables.php b/database/migrations/system/2022_06_30_010000_drop_foreign_key_constraints_on_all_tables.php index f4750780..d2e77253 100644 --- a/database/migrations/system/2022_06_30_010000_drop_foreign_key_constraints_on_all_tables.php +++ b/database/migrations/system/2022_06_30_010000_drop_foreign_key_constraints_on_all_tables.php @@ -32,7 +32,7 @@ protected function dropForeignKey($tableName, $options) $table->dropForeignKeyIfExists($foreignKey); $table->dropIndexIfExists(sprintf('%s_%s_foreign', $tableName, $foreignKey)); }); - } catch (\Exception $ex) { + } catch (Exception $ex) { Log::error($ex); } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 0300eb82..eecaec16 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -810,6 +810,30 @@ parameters: count: 1 path: src/Flame/Providers/EventServiceProvider.php + - + message: '#^Method Igniter\\Flame\\Scaffold\\Console\\MakeComponent\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''force'', null, 1, ''Overwrite existing…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/Flame/Scaffold/Console/MakeComponent.php + + - + message: '#^Method Igniter\\Flame\\Scaffold\\Console\\MakeController\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''force'', null, 1, ''Overwrite existing…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/Flame/Scaffold/Console/MakeController.php + + - + message: '#^Method Igniter\\Flame\\Scaffold\\Console\\MakeExtension\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''force'', null, 1, ''Overwrite existing…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/Flame/Scaffold/Console/MakeExtension.php + + - + message: '#^Method Igniter\\Flame\\Scaffold\\Console\\MakeModel\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''force'', null, 1, ''Overwrite existing…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/Flame/Scaffold/Console/MakeModel.php + - message: '#^Igniter\\Flame\\Support\\Extendable\:\:extendableCall\(\) calls parent\:\:__call\(\) but Igniter\\Flame\\Support\\Extendable does not extend any class\.$#' identifier: class.noParent @@ -846,6 +870,12 @@ parameters: count: 1 path: src/Flame/Support/Helpers/helpers.php + - + message: '#^Parameter \#1 \$message of static method Illuminate\\Log\\Logger\:\:error\(\) expects array\|Illuminate\\Contracts\\Support\\Arrayable\|Illuminate\\Contracts\\Support\\Jsonable\|Illuminate\\Support\\Stringable\|string, Exception given\.$#' + identifier: argument.type + count: 1 + path: src/Flame/Support/Helpers/helpers.php + - message: '#^Call to an undefined static method Illuminate\\Routing\\Controller\:\:__callStatic\(\)\.$#' identifier: staticMethod.notFound @@ -972,6 +1002,72 @@ parameters: count: 1 path: src/System/Classes/Controller.php + - + message: '#^Method Igniter\\System\\Console\\Commands\\ExtensionRefresh\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''pretend'', null, 1, ''Dump the SQL…''\}, array\{''step'', null, 4, ''The number of…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/ExtensionRefresh.php + + - + message: '#^Method Igniter\\System\\Console\\Commands\\ExtensionRemove\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''force'', null, 1, ''Force remove\.''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/ExtensionRemove.php + + - + message: '#^Method Igniter\\System\\Console\\Commands\\IgniterDown\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''database'', null, 4, ''The database…''\}, array\{''force'', null, 1, ''Force the operation…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/IgniterDown.php + + - + message: '#^Method Igniter\\System\\Console\\Commands\\IgniterInstall\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''force'', null, 1, ''Force the operation…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/IgniterInstall.php + + - + message: '#^Method Igniter\\System\\Console\\Commands\\IgniterPackageDiscover\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''force'', null, 1, ''Force the operation…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/IgniterPackageDiscover.php + + - + message: '#^Method Igniter\\System\\Console\\Commands\\IgniterUp\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''database'', null, 4, ''The database…''\}, array\{''force'', null, 1, ''Force the operation…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/IgniterUp.php + + - + message: '#^Method Igniter\\System\\Console\\Commands\\IgniterUpdate\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''force'', null, 1, ''Force updates\.''\}, array\{''check'', null, 1, ''Run update checks…''\}, array\{''core'', null, 1, ''Update core…''\}, array\{''addons'', null, 12, ''Update specified…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/IgniterUpdate.php + + - + message: '#^Method Igniter\\System\\Console\\Commands\\IgniterUtil\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''admin'', null, 1, ''Compile admin…''\}, array\{''minify'', null, 2, ''Whether to minify…''\}, array\{''carteKey'', null, 2, ''Specify a carteKey…''\}, array\{''theme'', null, 2, ''Specify a theme…''\}, array\{''extensions'', null, 1, ''Set the version…''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/IgniterUtil.php + + - + message: '#^Method Igniter\\System\\Console\\Commands\\ThemePublish\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''existing'', null, 1, ''Publish and…''\}, array\{''force'', null, 1, ''Force publish\.''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/ThemePublish.php + + - + message: '#^Method Igniter\\System\\Console\\Commands\\ThemeRemove\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''force'', null, 1, ''Force remove\.''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/ThemeRemove.php + + - + message: '#^Method Igniter\\System\\Console\\Commands\\ThemeVendorPublish\:\:getOptions\(\) should return array\\|string, 2\?\: int\<0, 31\>, 3\?\: string, 4\?\: mixed, 5\?\: \(Closure\(Symfony\\Component\\Console\\Completion\\CompletionInput, Symfony\\Component\\Console\\Completion\\CompletionSuggestions\)\: list\\)\|list\\}\|Symfony\\Component\\Console\\Input\\InputOption\> but returns array\{array\{''existing'', null, 1, ''Publish and…''\}, array\{''all'', null, 1, ''Publish assets for…''\}, array\{''theme'', null, 10, ''One or many theme…'', array\{\}\}, array\{''force'', null, 1, ''Force publish\.''\}\}\.$#' + identifier: return.type + count: 1 + path: src/System/Console/Commands/ThemeVendorPublish.php + - message: '#^Call to an undefined method Igniter\\Flame\\Database\\Builder\:\:sorted\(\)\.$#' identifier: method.notFound diff --git a/resources/models/system/generalsettings.php b/resources/models/system/generalsettings.php index 50a0ef5d..8f79c1b4 100644 --- a/resources/models/system/generalsettings.php +++ b/resources/models/system/generalsettings.php @@ -1,5 +1,7 @@ [ 'toolbar' => [ @@ -96,7 +98,7 @@ 'tab' => 'lang:igniter::system.settings.text_tab_site', 'type' => 'radiotoggle', 'default' => 'openexchangerates', - 'options' => [\Igniter\System\Models\Currency::class, 'getConverterDropdownOptions'], + 'options' => [Currency::class, 'getConverterDropdownOptions'], ], 'currency_converter[oer][apiKey]' => [ 'label' => 'lang:igniter::system.settings.label_currency_converter_oer_api_key', diff --git a/src/Admin/Classes/AdminController.php b/src/Admin/Classes/AdminController.php index 48c2bb1f..110dfa88 100644 --- a/src/Admin/Classes/AdminController.php +++ b/src/Admin/Classes/AdminController.php @@ -300,15 +300,15 @@ protected function processHandlers(): mixed throw new AjaxException($response); } catch (MassAssignmentException $ex) { - throw new FlashException(lang('igniter::admin.form.mass_assignment_failed', ['attribute' => $ex->getMessage()])); + throw new FlashException(lang('igniter::admin.form.mass_assignment_failed', ['attribute' => $ex->getMessage()]), 'danger', $ex->getCode(), $ex); } } protected function getRequiredPermissionsForAction(string $actionToCheck): array { - return collect((array)$this->requiredPermissions) + return collect((array) $this->requiredPermissions) ->map(fn($permission, $action): ?array => (!is_string($action) || $action === '*' || $action === $actionToCheck) - ? (array)$permission : null) + ? (array) $permission : null) ->filter() ->collapse() ->all(); diff --git a/src/Admin/Classes/BaseWidget.php b/src/Admin/Classes/BaseWidget.php index b24331e5..f4f5ea77 100644 --- a/src/Admin/Classes/BaseWidget.php +++ b/src/Admin/Classes/BaseWidget.php @@ -116,7 +116,7 @@ public function bindToController(): void */ protected function fillFromConfig(?array $properties = null) { - $properties = is_null($properties) ? array_keys((array)$this->config) : $properties; + $properties ??= array_keys((array)$this->config); foreach ($properties as $property) { if (property_exists($this, $property)) { diff --git a/src/Admin/Classes/MainMenuItem.php b/src/Admin/Classes/MainMenuItem.php index 179cea3e..f3f0e548 100644 --- a/src/Admin/Classes/MainMenuItem.php +++ b/src/Admin/Classes/MainMenuItem.php @@ -152,7 +152,7 @@ public function options($value = null) */ public function displayAs($type, array $config = []): static { - $this->type = !is_null($type) ? $type : $this->type; + $this->type = $type ?? $this->type; $this->config = $this->evalConfig($config); return $this; diff --git a/src/Admin/Classes/Navigation.php b/src/Admin/Classes/Navigation.php index 6f8f5b39..40fee8c2 100644 --- a/src/Admin/Classes/Navigation.php +++ b/src/Admin/Classes/Navigation.php @@ -43,7 +43,7 @@ class Navigation public function setContext(string $itemCode, ?string $parentCode = null): void { $this->navContextItemCode = $itemCode; - $this->navContextParentCode = is_null($parentCode) ? $itemCode : $parentCode; + $this->navContextParentCode = $parentCode ?? $itemCode; } public function getNavItems(): array diff --git a/src/Admin/Facades/AdminMenu.php b/src/Admin/Facades/AdminMenu.php index d708f02b..886034a5 100644 --- a/src/Admin/Facades/AdminMenu.php +++ b/src/Admin/Facades/AdminMenu.php @@ -5,6 +5,7 @@ namespace Igniter\Admin\Facades; use Igniter\Admin\Classes\Navigation; +use Igniter\User\Auth\UserGuard; use Illuminate\Support\Facades\Facade; use Override; @@ -42,14 +43,14 @@ * @method static string compileFileContent(string $filePath) * @method static string makeViewContent(string $view, array $data = []) * - * @see \Igniter\Admin\Classes\Navigation + * @see Navigation */ class AdminMenu extends Facade { /** * Get the registered name of the component. * - * @see \Igniter\User\Auth\UserGuard + * @see UserGuard */ #[Override] protected static function getFacadeAccessor(): string diff --git a/src/Admin/Helpers/AdminHelper.php b/src/Admin/Helpers/AdminHelper.php index 64f08954..e1a19734 100644 --- a/src/Admin/Helpers/AdminHelper.php +++ b/src/Admin/Helpers/AdminHelper.php @@ -14,7 +14,7 @@ /** * Admin Helper - * @see \Igniter\Admin\Helpers\AdminHelper + * @see AdminHelper */ class AdminHelper { diff --git a/src/Admin/Http/Actions/FormController.php b/src/Admin/Http/Actions/FormController.php index 75522b7d..a27c21c2 100644 --- a/src/Admin/Http/Actions/FormController.php +++ b/src/Admin/Http/Actions/FormController.php @@ -385,7 +385,7 @@ protected function getRedirectUrl(?string $context = null): string { $redirectContext = explode('-', (string)$context, 2)[0]; $redirectAction = explode('-', (string)$context, 2)[1] ?? ''; - $redirectSource = in_array($redirectAction, ['new', 'close']) + $redirectSource = in_array($redirectAction, ['new', 'close'], true) ? 'redirect'.studly_case($redirectAction) : 'redirect'; diff --git a/src/Admin/ServiceProvider.php b/src/Admin/ServiceProvider.php index be45d016..6c19164f 100644 --- a/src/Admin/ServiceProvider.php +++ b/src/Admin/ServiceProvider.php @@ -91,7 +91,7 @@ protected function registerFacadeAliases() foreach ([ 'AdminMenu' => AdminMenu::class, - 'Template' => \Igniter\Admin\Facades\Template::class, + 'Template' => Facades\Template::class, ] as $alias => $class) { $loader->alias($alias, $class); } diff --git a/src/Admin/Traits/ControllerUtils.php b/src/Admin/Traits/ControllerUtils.php index 86de2134..29790be7 100644 --- a/src/Admin/Traits/ControllerUtils.php +++ b/src/Admin/Traits/ControllerUtils.php @@ -46,7 +46,7 @@ public function checkAction(string $action): bool return false; } - throw_if(in_array(strtolower($action), array_map('strtolower', $this->hiddenActions)), + throw_if(in_array(strtolower($action), array_map('strtolower', $this->hiddenActions), true), new FlashException(sprintf('Method [%s] is not allowed in the controller [%s]', $action, $this::class)), ); diff --git a/src/Admin/Widgets/Lists.php b/src/Admin/Widgets/Lists.php index 5e98dd0b..917c16b6 100644 --- a/src/Admin/Widgets/Lists.php +++ b/src/Admin/Widgets/Lists.php @@ -303,15 +303,15 @@ protected function prepareModel(): Builder // Manipulate a count query for the sub query $countQuery = $relationObj->getRelationExistenceCountQuery($relationObj->getRelated()->newQueryWithoutScopes(), $query); - $joinSql = Db::raw($this->isColumnRelated($column, true) ? 'group_concat('.$sqlSelect." separator ', ')" : $sqlSelect); + $joinSql = DB::raw($this->isColumnRelated($column, true) ? 'group_concat('.$sqlSelect." separator ', ')" : $sqlSelect); $joinSql = $countQuery->select($joinSql)->toRawSql(); - $selects[] = Db::raw('('.$joinSql.') as '.$alias); + $selects[] = DB::raw('('.$joinSql.') as '.$alias); } // Primary column else { $sqlSelect = $this->parseTableName($column->sqlSelect, $primaryTable); - $selects[] = Db::raw($sqlSelect.' as '.$alias); + $selects[] = DB::raw($sqlSelect.' as '.$alias); } } @@ -1026,7 +1026,7 @@ protected function getSetupListColumns(): array protected function getSetupPerPageOptions(): array { $perPageOptions = [20, 40, 80, 100, 120]; - if (!in_array($this->pageLimit, $perPageOptions)) { + if (!in_array($this->pageLimit, $perPageOptions, true)) { $perPageOptions[] = $this->pageLimit; } @@ -1188,7 +1188,8 @@ protected function isColumnRelated(ListColumn $column, bool $multi = false): boo 'morphMany', 'attachMany', 'hasManyThrough', - ]); + ], + true); } /** diff --git a/src/Flame/Composer/Manager.php b/src/Flame/Composer/Manager.php index 381aea6b..79acca13 100644 --- a/src/Flame/Composer/Manager.php +++ b/src/Flame/Composer/Manager.php @@ -269,6 +269,12 @@ protected function restoreComposerFiles(): void protected function getProcess(array $command, array $env = []): Process { + // Ensure COMPOSER_HOME is set to ensure composer runs correctly in environments + // where the global composer installation is not available or configured properly. + if (!isset($env['COMPOSER_HOME']) && !getenv('COMPOSER_HOME')) { + $env['COMPOSER_HOME'] = $this->storagePath; + } + return (new Process($command, $this->workingPath, $env))->setTimeout(null); } diff --git a/src/Flame/Database/Attach/Manipulator.php b/src/Flame/Database/Attach/Manipulator.php index 4a5e06aa..7cf321be 100644 --- a/src/Flame/Database/Attach/Manipulator.php +++ b/src/Flame/Database/Attach/Manipulator.php @@ -42,7 +42,7 @@ public function useFile(string $file): self public function useDriver(string $driver): self { - if (!in_array($driver, ['gd', 'imagick'])) { + if (!in_array($driver, ['gd', 'imagick'], true)) { throw new LogicException(sprintf("Driver must be 'gd' or 'imagick'. '%s' provided.", $driver)); } @@ -110,7 +110,7 @@ public function isSupported(): bool } if ($this->driver === 'gd') { - return in_array($extension, $gdExtensions); + return in_array($extension, $gdExtensions, true); } return in_array($extension, $imagickExtensions); diff --git a/src/Flame/Database/Attach/MediaAdder.php b/src/Flame/Database/Attach/MediaAdder.php index 678f32e2..fb37adaa 100644 --- a/src/Flame/Database/Attach/MediaAdder.php +++ b/src/Flame/Database/Attach/MediaAdder.php @@ -71,7 +71,7 @@ public function fromFile(UploadedFile|SymfonyFile $file): Media $media->name = $media->getUniqueName(); $media->disk = $this->diskName ?? $media->getDiskName(); - $media->tag = $this->tag ?? $this->performedOn->getDefaultTagName(); + $media->tag = $this->performedOn->getDefaultTagName() ?? $this->tag; $media->custom_properties = $this->customProperties; $this->attachMedia($media); diff --git a/src/Flame/Database/Concerns/ExtendsEloquentBuilder.php b/src/Flame/Database/Concerns/ExtendsEloquentBuilder.php index 04a7bcf4..1e06831c 100644 --- a/src/Flame/Database/Concerns/ExtendsEloquentBuilder.php +++ b/src/Flame/Database/Concerns/ExtendsEloquentBuilder.php @@ -38,7 +38,7 @@ public function lists($column, $key = null) */ public function dropdown($column, $key = null) { - $key = !is_null($key) ? $key : $this->model->getKeyName(); + $key ??= $this->model->getKeyName(); return $this->lists($column, $key); } diff --git a/src/Flame/Database/Model.php b/src/Flame/Database/Model.php index b1a697fe..28fe3217 100644 --- a/src/Flame/Database/Model.php +++ b/src/Flame/Database/Model.php @@ -74,7 +74,7 @@ public function __construct(array $attributes = []) * * @param array $attributes * - * @return \Illuminate\Database\Eloquent\Model|static + * @return EloquentModel|static */ public static function make($attributes = []) { @@ -83,7 +83,7 @@ public static function make($attributes = []) /** * Reloads the model attributes from the database. - * @return \Illuminate\Database\Eloquent\Model|static + * @return EloquentModel|static */ public function reload() { @@ -179,7 +179,7 @@ public static function flushEventListeners(): void * * @param array $attributes * - * @return \Illuminate\Database\Eloquent\Model|static + * @return EloquentModel|static */ #[Override] public function newFromBuilder($attributes = [], $connection = null) diff --git a/src/Flame/Database/Pivot.php b/src/Flame/Database/Pivot.php index 8e1045c4..4b877000 100644 --- a/src/Flame/Database/Pivot.php +++ b/src/Flame/Database/Pivot.php @@ -15,7 +15,7 @@ * @method static Builder|Pivot newModelQuery() * @method static Builder|Pivot newQuery() * @method static Builder|Pivot query() - * @mixin \Illuminate\Database\Eloquent\Model + * @mixin ModelBase */ class Pivot extends Model { diff --git a/src/Flame/Flash/Facades/Flash.php b/src/Flame/Flash/Facades/Flash.php index bcd32b42..9e2e1913 100644 --- a/src/Flame/Flash/Facades/Flash.php +++ b/src/Flame/Flash/Facades/Flash.php @@ -28,14 +28,14 @@ * @method static FlashBag important() * @method static FlashBag clear() * - * @see \Igniter\Flame\Flash\FlashBag + * @see FlashBag */ class Flash extends IlluminateFacade { /** * Get the registered name of the component. * - * @see \Igniter\Flame\Flash\FlashBag + * @see FlashBag */ #[Override] protected static function getFacadeAccessor(): string diff --git a/src/Flame/Geolite/Contracts/AbstractProvider.php b/src/Flame/Geolite/Contracts/AbstractProvider.php index 604c696d..e7863252 100644 --- a/src/Flame/Geolite/Contracts/AbstractProvider.php +++ b/src/Flame/Geolite/Contracts/AbstractProvider.php @@ -87,7 +87,7 @@ public function getCacheLifetime(): ?int { $lifetime = config('igniter-geocoder.cache.duration'); - return !is_null($this->cacheLifetime) ? $this->cacheLifetime : $lifetime; + return $this->cacheLifetime ?? $lifetime; } protected function cacheCallback(string $cacheKey, Closure $closure): mixed diff --git a/src/Flame/Geolite/Polygon.php b/src/Flame/Geolite/Polygon.php index 843d071c..ae98b5fa 100644 --- a/src/Flame/Geolite/Polygon.php +++ b/src/Flame/Geolite/Polygon.php @@ -31,7 +31,7 @@ class Polygon implements ArrayAccess, Countable, IteratorAggregate, JsonSerializ protected ?int $precision = 8; /** - * @param null|array|Model\CoordinatesCollection $coordinates + * @param null|array|CoordinatesCollection $coordinates */ public function __construct($coordinates = null) { diff --git a/src/Flame/Html/FormFacade.php b/src/Flame/Html/FormFacade.php index 4a4ffa41..b8cbbf4e 100644 --- a/src/Flame/Html/FormFacade.php +++ b/src/Flame/Html/FormFacade.php @@ -26,7 +26,7 @@ * @method static bool hasMacro(string $name) * @method static void flushMacros() * - * @see \Igniter\Flame\Html\FormBuilder + * @see FormBuilder */ class FormFacade extends Facade { diff --git a/src/Flame/Html/HtmlFacade.php b/src/Flame/Html/HtmlFacade.php index 762c3e96..731b0ab1 100644 --- a/src/Flame/Html/HtmlFacade.php +++ b/src/Flame/Html/HtmlFacade.php @@ -10,7 +10,7 @@ /** * @method static string attributes(array $attributes) * - * @see \Igniter\Flame\Html\HtmlBuilder + * @see HtmlBuilder */ class HtmlFacade extends Facade { diff --git a/src/Flame/Pagic/Concerns/HasAttributes.php b/src/Flame/Pagic/Concerns/HasAttributes.php index 5ef8dcda..9f17ac36 100644 --- a/src/Flame/Pagic/Concerns/HasAttributes.php +++ b/src/Flame/Pagic/Concerns/HasAttributes.php @@ -413,7 +413,7 @@ public function isSettingsAttribute(string $attribute): bool 'mTime', 'code', 'settings', - ]); + ], true); } /** diff --git a/src/Flame/Pagic/Finder.php b/src/Flame/Pagic/Finder.php index addf23d0..d1d49b2d 100644 --- a/src/Flame/Pagic/Finder.php +++ b/src/Flame/Pagic/Finder.php @@ -277,7 +277,7 @@ public function lastModified(): int */ public function getFresh(array $columns = ['*']): ?array { - $this->columns ??= $columns; + $this->columns = $columns; $processCmd = $this->select ? 'processSelect' : 'processSelectAll'; @@ -460,7 +460,7 @@ public function cacheDriver(string $cacheDriver): static */ public function getCached(array $columns = ['*']): array { - $this->columns ??= $columns; + $this->columns = $columns; $key = $this->getCacheKey(); diff --git a/src/Flame/Support/Facades/File.php b/src/Flame/Support/Facades/File.php index bea1c380..3ddfcabc 100644 --- a/src/Flame/Support/Facades/File.php +++ b/src/Flame/Support/Facades/File.php @@ -81,14 +81,14 @@ * @method static bool hasMacro(string $name) * @method static void flushMacros() * - * @see \Igniter\Flame\Filesystem\Filesystem + * @see Filesystem */ class File extends IlluminateFacade { /** * Get the registered name of the component. * - * @see \Igniter\Flame\Filesystem\Filesystem + * @see Filesystem */ #[Override] protected static function getFacadeAccessor(): string diff --git a/src/Flame/Support/Facades/Igniter.php b/src/Flame/Support/Facades/Igniter.php index f7dd6deb..9b089866 100644 --- a/src/Flame/Support/Facades/Igniter.php +++ b/src/Flame/Support/Facades/Igniter.php @@ -4,6 +4,7 @@ namespace Igniter\Flame\Support\Facades; +use Igniter\Flame\Filesystem\Filesystem; use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Support\Facades\Facade; use Override; @@ -48,7 +49,7 @@ class Igniter extends Facade /** * Get the registered name of the component. * - * @see \Igniter\Flame\Filesystem\Filesystem + * @see Filesystem */ #[Override] protected static function getFacadeAccessor(): string diff --git a/src/Main/Classes/Theme.php b/src/Main/Classes/Theme.php index b7c44170..0c84f136 100644 --- a/src/Main/Classes/Theme.php +++ b/src/Main/Classes/Theme.php @@ -106,7 +106,7 @@ public function getSourcePath(): string public function getMetaPath(): string { if (is_null($this->metaPath)) { - foreach (['/_meta', '/meta'] as $metaPath) { + foreach (['/_meta', '/meta', $this->sourcePath.'/_meta', $this->sourcePath.'/meta'] as $metaPath) { if (File::isDirectory($this->path.$metaPath)) { $this->metaPath = $metaPath; } diff --git a/src/System/Actions/SettingsModel.php b/src/System/Actions/SettingsModel.php index ab5e4de1..0e45657d 100644 --- a/src/System/Actions/SettingsModel.php +++ b/src/System/Actions/SettingsModel.php @@ -209,7 +209,7 @@ public function afterModelSave(): void */ protected function isKeyAllowed(string $key): bool { - return in_array($key, ['id', 'item', 'data']) || $this->model->hasRelation($key); + return in_array($key, ['id', 'item', 'data'], true) || $this->model->hasRelation($key); } /** diff --git a/src/System/Classes/BaseComponent.php b/src/System/Classes/BaseComponent.php index 13bb7be2..17f88a6a 100644 --- a/src/System/Classes/BaseComponent.php +++ b/src/System/Classes/BaseComponent.php @@ -96,7 +96,7 @@ public function onRender() {} /** * Renders a requested partial in context of this component, - * @see \Igniter\Main\Classes\MainController::renderPartial for usage. + * @see MainController::renderPartial for usage. */ public function renderPartial(): mixed { @@ -167,7 +167,7 @@ public function param(string $name, mixed $default = null): mixed $segment = input($name); } - return is_null($segment) ? $default : $segment; + return $segment ?? $default; } // diff --git a/src/System/Classes/BaseController.php b/src/System/Classes/BaseController.php index 048a15f7..2f544a34 100644 --- a/src/System/Classes/BaseController.php +++ b/src/System/Classes/BaseController.php @@ -86,7 +86,7 @@ public function checkAction($action) return false; } - if (in_array(strtolower((string)$action), array_map('strtolower', $this->hiddenActions))) { + if (in_array(strtolower((string)$action), array_map('strtolower', $this->hiddenActions), true)) { return false; } diff --git a/src/System/Classes/ComponentManager.php b/src/System/Classes/ComponentManager.php index bc3cfae8..64257dab 100644 --- a/src/System/Classes/ComponentManager.php +++ b/src/System/Classes/ComponentManager.php @@ -311,7 +311,7 @@ public function getComponentPropertyConfig( // Translate human values $translate = ['label', 'description', 'options', 'group', 'validationMessage']; foreach ($property as $propertyName => $propertyValue) { - if (!in_array($propertyName, $translate)) { + if (!in_array($propertyName, $translate, true)) { continue; } @@ -364,6 +364,6 @@ public function getComponentPropertyRules(BaseComponent|LivewireComponent|BladeC protected function checkComponentPropertyType(string $type): bool { - return in_array($type, self::ALLOWED_PROPERTY_TYPES); + return in_array($type, self::ALLOWED_PROPERTY_TYPES, true); } } diff --git a/src/System/Classes/Controller.php b/src/System/Classes/Controller.php index c70175dc..f9e2ec66 100644 --- a/src/System/Classes/Controller.php +++ b/src/System/Classes/Controller.php @@ -27,7 +27,7 @@ * /admin/(any) `admin`, `location` or `system` app directory * /admin/acme/cod/(any) `Acme.Cod` extension * /(any) `main` app directory - * @see \Igniter\Admin\Classes\AdminController|\Igniter\Main\Classes\MainController controller class + * @see AdminController|MainController controller class * @deprecated No longer used, will be removed in v5.0.0 * @codeCoverageIgnore */ diff --git a/src/System/Facades/Assets.php b/src/System/Facades/Assets.php index 9dc87c21..dd7931b4 100644 --- a/src/System/Facades/Assets.php +++ b/src/System/Facades/Assets.php @@ -6,6 +6,7 @@ use Igniter\Flame\Assetic\Filter\FilterInterface; use Igniter\Main\Classes\Theme; +use Igniter\System\Libraries\Template; use Illuminate\Http\Response; use Illuminate\Support\Facades\Facade; use Override; @@ -48,7 +49,7 @@ class Assets extends Facade { /** * Get the registered name of the component. - * @see \Igniter\System\Libraries\Template + * @see Template */ #[Override] protected static function getFacadeAccessor(): string diff --git a/src/System/Helpers/ValidationHelper.php b/src/System/Helpers/ValidationHelper.php index c64a586f..b40f78dc 100644 --- a/src/System/Helpers/ValidationHelper.php +++ b/src/System/Helpers/ValidationHelper.php @@ -15,7 +15,7 @@ public static function prepareRules(array $rules): array $result = []; if (!isset($rules[0])) { - return $result; + return $rules; } foreach ($rules as $name => $value) { diff --git a/src/System/Libraries/Assets.php b/src/System/Libraries/Assets.php index 5da08f68..7fc7b271 100644 --- a/src/System/Libraries/Assets.php +++ b/src/System/Libraries/Assets.php @@ -382,7 +382,7 @@ protected function transformJsVar(mixed $value): false|string protected function transformJsObjectVar(mixed $value): false|string { - if ($value instanceof JsonSerializable || $value instanceof StdClass) { + if ($value instanceof JsonSerializable || $value instanceof stdClass) { return json_encode($value); } diff --git a/src/System/Libraries/Country.php b/src/System/Libraries/Country.php index 61d0efad..ac8e689e 100644 --- a/src/System/Libraries/Country.php +++ b/src/System/Libraries/Country.php @@ -62,7 +62,7 @@ public function getCountryNameById(null|int|string $id = null): ?string { $this->loadCountries(); - /** @var \Igniter\System\Models\Country $countryModel */ + /** @var CountryModel $countryModel */ if (!$countryModel = $this->countriesCollection->get($id)) { return null; } @@ -74,7 +74,7 @@ public function getCountryCodeById(null|int|string $id = null, ?int $codeType = { $this->loadCountries(); - /** @var \Igniter\System\Models\Country $countryModel */ + /** @var CountryModel $countryModel */ if (!$countryModel = $this->countriesCollection->get($id)) { return null; } @@ -87,7 +87,7 @@ public function getCountryNameByCode(string $isoCodeTwo): ?string { $this->loadCountries(); - /** @var \Igniter\System\Models\Country $countryModel */ + /** @var CountryModel $countryModel */ if (!$countryModel = $this->countriesCollection->firstWhere('iso_code_2', $isoCodeTwo)) { return null; } @@ -137,7 +137,7 @@ protected function processCountryValue(int|string|array $country, array &$result } elseif (is_numeric($country)) { $this->loadCountries(); - /** @var \Igniter\System\Models\Country $countryModel */ + /** @var CountryModel $countryModel */ if ($countryModel = $this->countriesCollection->get($country)) { $result['country'] = $countryModel->country_name; $result['format'] = $countryModel->format; diff --git a/src/System/Models/RequestLog.php b/src/System/Models/RequestLog.php index eba717e8..3cbfc56c 100644 --- a/src/System/Models/RequestLog.php +++ b/src/System/Models/RequestLog.php @@ -66,7 +66,7 @@ public static function createLog($statusCode = 404) ]); if ($referrer) { - $referrers = (array)$record->referrer ?: []; + $referrers = (array)$record->referrer; $referrers[] = $referrer; $record->referrer = $referrers; } diff --git a/src/System/ServiceProvider.php b/src/System/ServiceProvider.php index e72411a5..87dff3a6 100644 --- a/src/System/ServiceProvider.php +++ b/src/System/ServiceProvider.php @@ -145,7 +145,7 @@ protected function registerFacadeAliases() foreach ([ 'Assets' => Assets::class, - 'Country' => \Igniter\System\Facades\Country::class, + 'Country' => Facades\Country::class, ] as $alias => $class) { $loader->alias($alias, $class); } diff --git a/tests/src/Flame/Composer/ManagerTest.php b/tests/src/Flame/Composer/ManagerTest.php index 82a9393a..6965b45e 100644 --- a/tests/src/Flame/Composer/ManagerTest.php +++ b/tests/src/Flame/Composer/ManagerTest.php @@ -8,8 +8,10 @@ use Exception; use Igniter\Flame\Composer\Manager; use Igniter\Flame\Support\Facades\File; +use ReflectionMethod; use RuntimeException; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Process\Process; it('loads package version correctly', function() { $version = resolve(Manager::class)->getPackageVersion('some-package'); @@ -267,3 +269,56 @@ $manager = new Manager(__DIR__, '/storage'); expect(fn() => $manager->assertSchema())->toThrow(RuntimeException::class); }); + +it('injects COMPOSER_HOME when the parent process has neither set', function() { + $originalComposerHome = getenv('COMPOSER_HOME'); + putenv('COMPOSER_HOME'); + + try { + $manager = new Manager('/root', '/storage'); + $method = new ReflectionMethod(Manager::class, 'getProcess'); + + /** @var Process $process */ + $process = $method->invoke($manager, ['composer', 'install'], ['COMPOSER_MEMORY_LIMIT' => '-1']); + + expect($process)->toBeInstanceOf(Process::class) + ->and($process->getEnv())->toMatchArray([ + 'COMPOSER_HOME' => '/storage', + 'COMPOSER_MEMORY_LIMIT' => '-1', + ]); + } finally { + $originalComposerHome === false ? putenv('COMPOSER_HOME') : putenv('COMPOSER_HOME='.$originalComposerHome); + } +}); + +it('does not override COMPOSER_HOME inherited from the parent process', function() { + $originalComposerHome = getenv('COMPOSER_HOME'); + putenv('COMPOSER_HOME=/parent/composer'); + + try { + $manager = new Manager('/root', '/storage'); + $method = new ReflectionMethod(Manager::class, 'getProcess'); + + /** @var Process $process */ + $process = $method->invoke($manager, ['composer', 'install']); + + expect($process->getEnv()) + ->and($process->getEnv())->not->toHaveKey('COMPOSER_HOME'); + } finally { + $originalComposerHome === false ? putenv('COMPOSER_HOME') : putenv('COMPOSER_HOME='.$originalComposerHome); + } +}); + +it('allows callers to override COMPOSER_HOME on the spawned composer process', function() { + $manager = new Manager('/root', '/storage'); + $method = new ReflectionMethod(Manager::class, 'getProcess'); + + /** @var Process $process */ + $process = $method->invoke($manager, ['composer', 'install'], [ + 'COMPOSER_HOME' => '/custom/composer', + ]); + + expect($process->getEnv())->toMatchArray([ + 'COMPOSER_HOME' => '/custom/composer', + ]); +});