Loading .idea/sonarlint/issuestore/a/d/ad8b439416d1e02614f47c5b471c7c4e587dca82 +2 −0 Original line number Diff line number Diff line vphp:S121"0Add curly braces around the nested statement(s).(8Ƌ1J$562771d0-0b91-4f4c-beaf-90c25c2ac224 No newline at end of file src/Controller/HomeController.php +7 −7 Original line number Diff line number Diff line Loading @@ -12,26 +12,26 @@ use Symfony\Component\Routing\Attribute\Route; class HomeController extends AbstractController { private function readLogFile(string $fileName): string { private function readFileLineByLine(string $fileName): iterable { $filePath = $this->getParameter('kernel.project_dir') . "/public/files/" . $fileName; if (file_exists($filePath)) { $text = ""; $file = fopen($filePath, "r"); while(!feof($file)) { $line = fgets($file); $text .= $line; yield fgets($file); } fclose($file); return $text; } return "Такого файла не существует."; else yield "Такого файла не существует."; } #[Route('/{fileName}', name: 'home')] public function home(string $fileName): Response // text.txt { $text = $this->readLogFile($fileName); $text = ""; foreach($this->readFileLineByLine($fileName) as $line) { $text .= $line; } return $this->render('home.html.twig', ['text' => $text]); } } Loading
.idea/sonarlint/issuestore/a/d/ad8b439416d1e02614f47c5b471c7c4e587dca82 +2 −0 Original line number Diff line number Diff line vphp:S121"0Add curly braces around the nested statement(s).(8Ƌ1J$562771d0-0b91-4f4c-beaf-90c25c2ac224 No newline at end of file
src/Controller/HomeController.php +7 −7 Original line number Diff line number Diff line Loading @@ -12,26 +12,26 @@ use Symfony\Component\Routing\Attribute\Route; class HomeController extends AbstractController { private function readLogFile(string $fileName): string { private function readFileLineByLine(string $fileName): iterable { $filePath = $this->getParameter('kernel.project_dir') . "/public/files/" . $fileName; if (file_exists($filePath)) { $text = ""; $file = fopen($filePath, "r"); while(!feof($file)) { $line = fgets($file); $text .= $line; yield fgets($file); } fclose($file); return $text; } return "Такого файла не существует."; else yield "Такого файла не существует."; } #[Route('/{fileName}', name: 'home')] public function home(string $fileName): Response // text.txt { $text = $this->readLogFile($fileName); $text = ""; foreach($this->readFileLineByLine($fileName) as $line) { $text .= $line; } return $this->render('home.html.twig', ['text' => $text]); } }