-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Drop old versions #221
Drop old versions #221
Conversation
87a7cc4
to
4d29bea
Compare
@sagikazarmark can you please give this a review? I followed your |
ping @sonata-project/contributors |
*/ | ||
public function __construct(LoggerInterface $logger = null, $defaultFormatter = null) | ||
public function __construct($defaultFormatter, LoggerInterface $logger = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an upgrade note for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also mention that passing null will no longer automatically make the first formatter the default one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually null should be an invalid value in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually null should be an invalid value in the first place.
That's right. I think I'll have to make another PR on 3.x to fix that, and maybe also add deprecation notices for each of the TODOs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null is valid on the 3.x branch IMO, since it's optional. When it is null, the first one is automatically selected, this is necessary for BC. Otherwise I agree, deprecation warnings should be added. (Actually I am not sure why I didn't add any)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I am not sure why I didn't add any
Probably because this was quite old ;)
I'll remove the null in the signature then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait I got confused and removed null from the logger signature. My bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually null should be an invalid value in the first place.
@sagikazarmark : called cannotBeEmpty
to take care of that.
@greg0ire Sure, but I lost the context: what TODO instructions? 😄 |
Ah, ok, found it |
if (!array_key_exists($config['default_formatter'], $config['formatters'])) { | ||
throw new \InvalidArgumentException(sprintf('SonataFormatterBundle - Invalid default formatter : %s, available : %s', $config['default_formatter'], json_encode(array_keys($config['formatters'])))); | ||
throw new \InvalidArgumentException(sprintf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you are against it, and I am not trying to start a flame war here again, but AFAIK the Symfony CS says exceptions should not be split into multiple lines. Am I wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fabien said it to me, but I am not sure they put it in their CS rules though (and I think the arguments he gave are not good enough, but can understand that he does not want to have to touch 10000 files over this). And anyway, there is a sprintf
here, and we usually split sprintf
calls, don't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said, I saw quite a few rounds of debates about this and I am not up to date with the latest decisions on this front, I just wanted to point a possible discrepancy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, in this case I'll go as far as to prefer discrepancy, so as long as someone does not point me at some docs showing this is part of the sf coding standard, which I think is full of very questionable decisions like Yoda conditions or non-multiline-signatures that are 500 chars long (not kidding, there are things like this in sf), then I'll keep using and asking for linebroken exceptions. It gives better diffs, and people can actually read the exception messages that way.
I don't know why people are so afraid of hitting the carriage return key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but can understand that he does not want to have to touch 10000 files over this
That's the why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes I wonder if consistency is that important: if you do something wrong and hard to fix many times, you just give up and carve in your standards : "do it the wrong way"
*/ | ||
public function __construct(LoggerInterface $logger = null, $defaultFormatter = null) | ||
public function __construct($defaultFormatter, LoggerInterface $logger = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also mention that passing null will no longer automatically make the first formatter the default one?
*/ | ||
public function __construct(LoggerInterface $logger = null, $defaultFormatter = null) | ||
public function __construct($defaultFormatter, LoggerInterface $logger = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually null should be an invalid value in the first place.
4fdd829
to
9de44ff
Compare
{ | ||
$this->logger = $logger; | ||
|
||
// TODO: This should become a required first parameter when the major version is changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sagikazarmark I think there is no point anymore to switch the arguments if the logger can't be null, am I right? nevermind that
f4fb543
to
b25f76a
Compare
I guess this needs to be rebased once 3.x is merged into master, right? |
Yes exactly. And reworked a bit also (because of the changes with the logger) |
Could you please rebase your PR and fix merge conflicts? |
b25f76a
to
dd26878
Compare
dd26878
to
314f2b4
Compare
314f2b4
to
caf69ed
Compare
@sagikazarmark it's ready, please review ! |
caf69ed
to
feec793
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pure beauty
if (!array_key_exists($config['default_formatter'], $config['formatters'])) { | ||
throw new \InvalidArgumentException(sprintf('SonataFormatterBundle - Invalid default formatter : %s, available : %s', $config['default_formatter'], json_encode(array_keys($config['formatters'])))); | ||
throw new \InvalidArgumentException(sprintf( | ||
'SonataFormatterBundle - Invalid default formatter : %s, available : %s', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, spaces before colons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dropped them, it looks weird indeed.
😊 thanks! |
@sonata-project/contributors , you already approved, but I changed many things, so maybe a final review before the merge? |
TBH I don't understand why approval is not automatically reset when more changes are added to the repo. |
86f4b7a
to
a42885b
Compare
I think it would be hard to get right, because you'd have to separate pedantic changes from significant ones. For instance I just restored |
Well, I would rather make sure all the time. The same applies to business: you don't deploy ANYTHING, not even a char change to production without approval. I agree that it could actually be quite uncomfortable in some cases, but that's the only way to keep the formalities. |
I think it depends on the human resources you have on your team. Maybe Github will make this configurable someday? |
@@ -12,14 +12,16 @@ | |||
namespace Sonata\FormatterBundle\Formatter; | |||
|
|||
use Psr\Log\LoggerAwareInterface; | |||
use Psr\Log\LoggerInterface; | |||
use Psr\Log\LoggerAwareTrait; | |||
use Psr\Log\NullLogger; | |||
use Twig_Environment; | |||
use Twig_Error_Syntax; | |||
use Twig_Sandbox_SecurityError; | |||
|
|||
class Pool implements LoggerAwareInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need the interface when using the trait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We inject the logger ourselves, so I'd say no… but if we want the class to benefit from some automatic logger injection we're not aware of in some framework, this might be necessary. Doesn't hurt IMO. @sagikazarmark , what do you think?
The Psr\Log\LoggerAwareInterface only contains a setLogger(LoggerInterface $logger) method and can be used by frameworks to auto-wire arbitrary instances with a logger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LoggerAware can be used as a marker that it requires a log, so I would say keep it. Doesn't hurt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@core23 @OskarStark please merge this if that's ok with you
Thanks @greg0ire |
I am targetting this branch, because bumping minor version of some deps is considered major.
Changelog
Todo
Subject
This prepares the next major release