-
-
Notifications
You must be signed in to change notification settings - Fork 10
fix: render single trailing newline in .env #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: render single trailing newline in .env #9
Conversation
|
Hi there! I'm using your package and really love it—thank you for your work) Thanks again! |
|
If there are any other changes needed, I’ll be happy to fix them right away. 🙂 |
|
@artengin sorry for the delay in response, your change LGTM. Could you also add this as an additional test: public function testEnvComplexWithEmptyLine()
{
$env = new EnvFile('');
$env->addEmptyLine();
$env->addEmptyLine();
$env->set('VAR_ONE', '1');
$env->addEmptyLine();
$env->addEmptyLine();
$env->set('VAR_TWO', '2');
$env->addEmptyLine();
$env->addEmptyLine();
$this->assertEquals("\n\nVAR_ONE=1\n\n\nVAR_TWO=2\n", $env->render());
}Just to prove multiple new lines still work at the top / in the middle of the the file and are only stripped at the bottom :) |
WalkthroughEnvPrinter's render now returns the trimmed output with a single trailing newline (rtrim(...).PHP_EOL). Two tests were added to exercise empty-line insertion and rendering normalization, including a case that preserves multiple empty lines around variables. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Test
participant EnvFile
participant EnvPrinter
Test->>EnvFile: addEmptyLine() / set variables
Test->>EnvPrinter: render(EnvFile)
EnvPrinter->>EnvPrinter: accumulate output lines
Note over EnvPrinter: rtrim(output) then append PHP_EOL
EnvPrinter-->>Test: normalized_output_with_single_newline
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks so much! 😊 |
Normalize
.envrendering with a single trailing newlineWhen using
addEmptyLine()on an EnvFile where no new variables are addedbut existing ones are modified, multiple empty lines could accumulate at the end.
This change ensures that
.envfiles always end with exactly one newline,keeping the file clean and consistent.
Summary by CodeRabbit
Bug Fixes
Tests