Skip to content
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

Merged
merged 4 commits into from
Dec 16, 2016
Merged

Drop old versions #221

merged 4 commits into from
Dec 16, 2016

Conversation

greg0ire
Copy link
Contributor

@greg0ire greg0ire commented Nov 26, 2016

I am targetting this branch, because bumping minor version of some deps is considered major.

Changelog

### Removed
- support for PHP 5.3 through 5.5 was dropped
- support for Symfony 2.3 through 2.7 was dropped

Todo

Subject

This prepares the next major release

@greg0ire greg0ire added the major label Nov 26, 2016
@greg0ire greg0ire changed the base branch from 3.x to master November 26, 2016 16:04
@greg0ire
Copy link
Contributor Author

@sagikazarmark can you please give this a review? I followed your TODO instructions.

@greg0ire
Copy link
Contributor Author

greg0ire commented Dec 2, 2016

ping @sonata-project/contributors

*/
public function __construct(LoggerInterface $logger = null, $defaultFormatter = null)
public function __construct($defaultFormatter, LoggerInterface $logger = null)
Copy link
Member

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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)

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@sagikazarmark
Copy link
Contributor

@greg0ire Sure, but I lost the context: what TODO instructions? 😄

@sagikazarmark
Copy link
Contributor

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(
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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)
Copy link
Contributor

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)
Copy link
Contributor

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.

{
$this->logger = $logger;

// TODO: This should become a required first parameter when the major version is changed
Copy link
Contributor Author

@greg0ire greg0ire Dec 3, 2016

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

@greg0ire greg0ire force-pushed the drop_old_versions branch 2 times, most recently from f4fb543 to b25f76a Compare December 3, 2016 14:33
@sagikazarmark
Copy link
Contributor

I guess this needs to be rebased once 3.x is merged into master, right?

@greg0ire
Copy link
Contributor Author

Yes exactly. And reworked a bit also (because of the changes with the logger)

@SonataCI
Copy link
Collaborator

Could you please rebase your PR and fix merge conflicts?

@greg0ire
Copy link
Contributor Author

@sagikazarmark it's ready, please review !

Copy link
Contributor

@sagikazarmark sagikazarmark left a 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',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, spaces before colons?

Copy link
Contributor Author

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.

@greg0ire
Copy link
Contributor Author

Pure beauty

😊 thanks!

@greg0ire
Copy link
Contributor Author

@sonata-project/contributors , you already approved, but I changed many things, so maybe a final review before the merge?

@sagikazarmark
Copy link
Contributor

TBH I don't understand why approval is not automatically reset when more changes are added to the repo.

@greg0ire
Copy link
Contributor Author

TBH I don't understand why approval is not automatically reset when more changes are added to the repo.

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 UPGRADE-4.0.md that I deleted by mistake, I don't think it warrants a reset.

@sagikazarmark
Copy link
Contributor

think it would be hard to get right, because you'd have to separate pedantic changes from significant ones.

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.

@greg0ire
Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Contributor Author

@greg0ire greg0ire Dec 14, 2016

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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

@core23 core23 merged commit 87d8ee1 into sonata-project:master Dec 16, 2016
@core23
Copy link
Member

core23 commented Dec 16, 2016

Thanks @greg0ire

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

Successfully merging this pull request may close these issues.

5 participants