Skip to content

Shortening code sample #15434

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

Merged
merged 1 commit into from
Jun 16, 2021
Merged

Shortening code sample #15434

merged 1 commit into from
Jun 16, 2021

Conversation

ThomasLandauer
Copy link
Contributor

It's strange that the "easy" way (below) looks twice as long as the "hard" way (above). So I'm removing two unnecessary lines, at least ,-)

It's strange that the "easy" way (below) looks twice as long as the "hard" way (above). So I'm removing two unnecessary lines, at least ,-)
@javiereguiluz
Copy link
Member

Thanks Thomas. I'm going to merge this, but let's be completely honest: the easy way only takes 1 line:

$this->logger->debug('Some info');

While the hard way takes 3 lines:

if ($output->isDebug()) {
    $output->writeln('Some info');
}

The overall setup needed for the easy way is not that important ... because real commands are long (and maybe they already use a constructor) so injecting another dependency is negligible.

@javiereguiluz javiereguiluz merged commit 94ac986 into symfony:4.4 Jun 16, 2021
@ThomasLandauer ThomasLandauer deleted the patch-18 branch June 16, 2021 12:07
@ThomasLandauer
Copy link
Contributor Author

Yeah, sure, that's why I said it looks (not is) twice as long ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants