Skip to content
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
3 changes: 1 addition & 2 deletions src/Command/Controller/ControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/Command/Cron/CronJobCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/InitEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ZipGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function generate(): void
}

// excluimos el propio zip
if ($name === $zipName) {
if ($name === './' . $zipName) {
continue;
}

Expand Down