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"); } } 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"); } } 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); } /** 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; }