From d8a09fbf40892d15e7ea5574e987d1af5a558b10 Mon Sep 17 00:00:00 2001 From: Sleon4 Date: Mon, 18 Nov 2024 16:45:52 -0500 Subject: [PATCH] feat: Lion-Files v7.1.0 is integrated --- composer.json | 2 +- composer.lock | 19 ++++++++------- src/LionBundle/Commands/CommandHandler.php | 4 ++-- .../Commands/Lion/DB/DBSeedCommand.php | 4 ++-- .../Migrations/FreshMigrationsCommand.php | 4 ++-- .../Lion/Schedule/ListScheduleCommand.php | 4 ++-- .../Lion/Schedule/UpScheduleCommand.php | 4 ++-- .../Lion/Sockets/ServerSocketCommand.php | 4 ++-- src/LionBundle/Helpers/Bundle/helpers.php | 24 ------------------- 9 files changed, 23 insertions(+), 46 deletions(-) diff --git a/composer.json b/composer.json index 685a337d..b3ecd350 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "lion/database": "^10.3", "lion/dependency-injection": "^3.0", "lion/exceptions": "^1.3", - "lion/files": "^7.0", + "lion/files": "^7.1", "lion/helpers": "^4.0", "lion/mailer": "^6.3", "lion/request": "^6.9", diff --git a/composer.lock b/composer.lock index 95e15986..e98b9c3e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8e0a21e8a82d539178bd955811164239", + "content-hash": "0dc5f3d987ef9a0486ca7651dc0e8815", "packages": [ { "name": "carbonphp/carbon-doctrine-types", @@ -919,24 +919,25 @@ }, { "name": "lion/files", - "version": "V7.0.0", + "version": "v7.1.0", "source": { "type": "git", "url": "https://github.com/lion-packages/files.git", - "reference": "3a498dd4b486195aebb7dd5184c4d0bde8265aec" + "reference": "9f8ba435ac85dc1872ca51f8704285a3d00f7b4f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lion-packages/files/zipball/3a498dd4b486195aebb7dd5184c4d0bde8265aec", - "reference": "3a498dd4b486195aebb7dd5184c4d0bde8265aec", + "url": "https://api.github.com/repos/lion-packages/files/zipball/9f8ba435ac85dc1872ca51f8704285a3d00f7b4f", + "reference": "9f8ba435ac85dc1872ca51f8704285a3d00f7b4f", "shasum": "" }, "require": { + "ext-mbstring": "*", "php": ">=8.3" }, "require-dev": { - "lion/test": "^2.0", - "phpunit/phpunit": "^11.2" + "lion/test": "^2.1", + "phpunit/phpunit": "^11.4" }, "type": "library", "autoload": { @@ -951,9 +952,9 @@ "description": "Library created with the function of working internal system files", "support": { "issues": "https://github.com/lion-packages/files/issues", - "source": "https://github.com/lion-packages/files/tree/V7.0.0" + "source": "https://github.com/lion-packages/files/tree/v7.1.0" }, - "time": "2024-06-29T22:32:18+00:00" + "time": "2024-11-18T21:29:03+00:00" }, { "name": "lion/helpers", diff --git a/src/LionBundle/Commands/CommandHandler.php b/src/LionBundle/Commands/CommandHandler.php index 52e23ed6..a43a910d 100644 --- a/src/LionBundle/Commands/CommandHandler.php +++ b/src/LionBundle/Commands/CommandHandler.php @@ -84,9 +84,9 @@ private function getCommands(string $pathCommands, string $namespace, string $pa /** @var array $commands */ $commands = []; - foreach ($this->store->view($pathCommands) as $file) { + foreach ($this->store->getFiles($pathCommands) as $file) { if (isSuccess($this->store->validate([$file], ['php']))) { - $class = getNamespaceFromFile($file, $namespace, $pathSplit); + $class = $this->store->getNamespaceFromFile($file, $namespace, $pathSplit); $commands[] = $this->container->resolve($class); } diff --git a/src/LionBundle/Commands/Lion/DB/DBSeedCommand.php b/src/LionBundle/Commands/Lion/DB/DBSeedCommand.php index 9b043183..d0135838 100644 --- a/src/LionBundle/Commands/Lion/DB/DBSeedCommand.php +++ b/src/LionBundle/Commands/Lion/DB/DBSeedCommand.php @@ -80,9 +80,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var array $files */ $files = []; - foreach ($this->store->view('./database/Seed/') as $seed) { + foreach ($this->store->getFiles('./database/Seed/') as $seed) { if (isSuccess($this->store->validate([$seed], ['php']))) { - $class = getNamespaceFromFile($seed, 'Database\\Seed\\', 'Seed/'); + $class = $this->store->getNamespaceFromFile($seed, 'Database\\Seed\\', 'Seed/'); /** @var SeedInterface $seedInterface */ $seedInterface = new $class(); diff --git a/src/LionBundle/Commands/Lion/Migrations/FreshMigrationsCommand.php b/src/LionBundle/Commands/Lion/Migrations/FreshMigrationsCommand.php index 290a77ab..4ba5fb48 100644 --- a/src/LionBundle/Commands/Lion/Migrations/FreshMigrationsCommand.php +++ b/src/LionBundle/Commands/Lion/Migrations/FreshMigrationsCommand.php @@ -146,9 +146,9 @@ private function getMigrations(): array StoreProcedureInterface::class => [], ]; - foreach ($this->store->view('./database/Migrations/') as $migration) { + foreach ($this->store->getFiles('./database/Migrations/') as $migration) { if (isSuccess($this->store->validate([$migration], ['php']))) { - $namespace = getNamespaceFromFile($migration, 'Database\\Migrations\\', 'Migrations/'); + $namespace = $this->store->getNamespaceFromFile($migration, 'Database\\Migrations\\', 'Migrations/'); $tableMigration = include_once($migration); diff --git a/src/LionBundle/Commands/Lion/Schedule/ListScheduleCommand.php b/src/LionBundle/Commands/Lion/Schedule/ListScheduleCommand.php index acea3e2d..9318ca40 100644 --- a/src/LionBundle/Commands/Lion/Schedule/ListScheduleCommand.php +++ b/src/LionBundle/Commands/Lion/Schedule/ListScheduleCommand.php @@ -98,9 +98,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $size = 0; - foreach ($this->store->view('app/Console/Cron/') as $file) { + foreach ($this->store->getFiles('app/Console/Cron/') as $file) { if (isSuccess($this->store->validate([$file], ['php']))) { - $namespace = getNamespaceFromFile( + $namespace = $this->store->getNamespaceFromFile( (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? str_replace('\\', '/', $file) : $file), 'App\\Console\\Cron\\', $this->store->normalizePath('Cron/') diff --git a/src/LionBundle/Commands/Lion/Schedule/UpScheduleCommand.php b/src/LionBundle/Commands/Lion/Schedule/UpScheduleCommand.php index e7d4f456..98732626 100644 --- a/src/LionBundle/Commands/Lion/Schedule/UpScheduleCommand.php +++ b/src/LionBundle/Commands/Lion/Schedule/UpScheduleCommand.php @@ -115,9 +115,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** @var array $files */ $files = []; - foreach ($this->store->view('app/Console/Cron/') as $file) { + foreach ($this->store->getFiles('app/Console/Cron/') as $file) { if (isSuccess($this->store->validate([$file], ['php']))) { - $namespace = getNamespaceFromFile( + $namespace = $this->store->getNamespaceFromFile( $this->store->normalizePath($file), 'App\\Console\\Cron\\', $this->store->normalizePath('Cron/') diff --git a/src/LionBundle/Commands/Lion/Sockets/ServerSocketCommand.php b/src/LionBundle/Commands/Lion/Sockets/ServerSocketCommand.php index 740a03bf..2a2214bf 100644 --- a/src/LionBundle/Commands/Lion/Sockets/ServerSocketCommand.php +++ b/src/LionBundle/Commands/Lion/Sockets/ServerSocketCommand.php @@ -134,9 +134,9 @@ private function selectSocket(InputInterface $input, OutputInterface $output): s { $classList = []; - foreach ($this->store->view('./app/Sockets/') as $file) { + foreach ($this->store->getFiles('./app/Sockets/') as $file) { if (isSuccess($this->store->validate([$file], [ClassFactory::PHP_EXTENSION]))) { - $classList[] = getNamespaceFromFile($file, 'App\\Sockets\\', 'Sockets/'); + $classList[] = $this->store->getNamespaceFromFile($file, 'App\\Sockets\\', 'Sockets/'); } } diff --git a/src/LionBundle/Helpers/Bundle/helpers.php b/src/LionBundle/Helpers/Bundle/helpers.php index da1d77f6..ddfcff17 100644 --- a/src/LionBundle/Helpers/Bundle/helpers.php +++ b/src/LionBundle/Helpers/Bundle/helpers.php @@ -355,27 +355,3 @@ function env(string $key, mixed $default = null): mixed return Env::get($key, $default); } } - -if (!function_exists('getNamespaceFromFile')) { - /** - * Gets the namespace of a class through a defined path - * - * @param string $file [File path] - * @param string $namespace [Namespace for the file] - * @param string $split [Separator to obtain the namespace] - * - * @return string - * - * @internal - */ - function getNamespaceFromFile(string $file, string $namespace, string $split = '/'): string - { - $splitFile = explode($split, $file); - - $namespace = str_replace("/", "\\", "{$namespace}{$splitFile[1]}"); - - $namespace = str_replace('.php', '', $namespace); - - return trim($namespace); - } -}