From d035c1eff4b9c03d60672fa0d2a0a8a0280e0a5d Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Wed, 17 Jun 2026 13:44:14 +0200 Subject: [PATCH 1/4] refactor: remove unnecesary line --- src/Command/Controller/ControllerCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Command/Controller/ControllerCommand.php b/src/Command/Controller/ControllerCommand.php index 26cf428..d4b415a 100644 --- a/src/Command/Controller/ControllerCommand.php +++ b/src/Command/Controller/ControllerCommand.php @@ -121,8 +121,7 @@ private function createController(string $name): void $samplePath2 = dirname(__DIR__, 3) . "/samples/View.html.twig.sample"; $sample2 = file_get_contents($samplePath2); - $template2 = str_replace('[[NADA_A_REEMPLAZAR]]', $name, $sample2); - file_put_contents($viewFilename, $template2); + file_put_contents($viewFilename, $sample2); Utils::echo('* ' . $viewFilename . " -> OK.\n"); } } From c21f72a7ebb1b5128ec50ca2e96e2105eb9eb5aa Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Wed, 17 Jun 2026 13:44:35 +0200 Subject: [PATCH 2/4] refactor: check if exists error first --- src/Command/Cron/CronJobCommand.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Command/Cron/CronJobCommand.php b/src/Command/Cron/CronJobCommand.php index bd35d21..84b0585 100644 --- a/src/Command/Cron/CronJobCommand.php +++ b/src/Command/Cron/CronJobCommand.php @@ -94,9 +94,11 @@ private function updateCron(string $name): void $fileStr = substr_replace($fileStr, $newJob, $position, 0); file_put_contents('Cron.php', $fileStr); $usePosition = strpos($fileStr, 'use FacturaScripts\Core\Template\CronClass'); - $usePosition = strpos($fileStr, ';', $usePosition) + 1; - $fileStr = substr_replace($fileStr, "\nuse FacturaScripts\\$nameSpace\CronJob\\$name;", $usePosition, 0); - file_put_contents('Cron.php', $fileStr); + if ($usePosition !== false) { + $usePosition = strpos($fileStr, ';', $usePosition) + 1; + $fileStr = substr_replace($fileStr, "\nuse FacturaScripts\\$nameSpace\CronJob\\$name;", $usePosition, 0); + file_put_contents('Cron.php', $fileStr); + } Utils::echo('* Cron.php actualizado' . " -> OK.\n"); } } From f36748f3f83255f65bf4edfa4e64aecb62295e95 Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Wed, 17 Jun 2026 13:56:07 +0200 Subject: [PATCH 3/4] fix: prevent endLastUse bug --- src/InitEditor.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/InitEditor.php b/src/InitEditor.php index 782b49c..d7f4cc9 100644 --- a/src/InitEditor.php +++ b/src/InitEditor.php @@ -56,10 +56,11 @@ public static function addUse(string $useInstruction): ?string // escoger el Ășltimo de todos los use y donde termina $matches = self::getSentenceMatches($str, 'use'); $lastUse = end($matches); - $endLastUse = strpos($str, "\n", $lastUse) + 1; + $nlPos = strpos($str, "\n", $lastUse); + $endLastUse = $nlPos !== false ? $nlPos + 1 : strlen($str); // colocar el nuevo use - return mb_substr($str, 0, $endLastUse) . $useInstruction . "\n" . mb_substr($str, $endLastUse); + return substr($str, 0, $endLastUse) . $useInstruction . "\n" . substr($str, $endLastUse); } /** From 556d129652c4cf7448fa7d9bbccbbf3cab374fca Mon Sep 17 00:00:00 2001 From: Abderrahim Darghal Belkacemi Date: Wed, 17 Jun 2026 13:57:45 +0200 Subject: [PATCH 4/4] refactor: IA warning --- src/ZipGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZipGenerator.php b/src/ZipGenerator.php index eb13f5d..37a383b 100644 --- a/src/ZipGenerator.php +++ b/src/ZipGenerator.php @@ -76,7 +76,7 @@ public static function generate(): void } // excluimos el propio zip - if ($name === $zipName) { + if ($name === './' . $zipName) { continue; }