8000 [Routing] PhpDumper should follow coding standards by c960657 · Pull Request #20082 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Routing] PhpDumper should follow coding standards #20082

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

Closed
wants to merge 1 commit into from

Conversation

c960657
Copy link
Contributor
@c960657 c960657 commented Sep 28, 2016
Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

While working on #19562 I noticed that Fabbot does not like the PHP code generated by the PhpGeneratorDumper and PhpMatcherDumper.

This patch makes the generated code comply with Symfony's conding standards.

@ro0NL
Copy link
Contributor
ro0NL commented Sep 28, 2016

Im not sure this is a real issue... imo. codestyle doesnt really apply to generated code anyway.

@c960657 c960657 force-pushed the dumper-cs branch 2 times, most recently from 2d9a0e6 to 7cf4772 Compare September 28, 2016 21:26
@javiereguiluz
Copy link
Member

I'm 👍

I know that these generated files are critical and we shouldn't mess with them; these files are generated for computers, not humans; etc. But the proposed changes look safe and Symfony is a project that should strive for top quality in everything it does, like generating these files.

@linaori
Copy link
Contributor
linaori commented Sep 29, 2016

We'll always be 1 step behind of the codestyle of those files. If it's really important to have them properly formatted, it should be using an up-to-date code formatter (php-cs-fixer?). Imo if readability of generated files is really an issue, I'd rather see them being formated on 1 line and use your IDE or a custom cs fixer on demand when required.


return $routes;
}

protected function exportArray($array)
{
return preg_replace(array('/array \(/', '/,\n *\)/', '/,\n */', '/\n */'), array('array(', ')', ', ', ''), var_export($array, true));
Copy link
Member

Choose a reason for hiding this comment

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

there is a risk of collision with the content of a string here, CS is not worth it imho

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. I thought I had this covered, but I must have missed something (I wrote this code a while back, so I don't remember my reasoning).

I cannot think of an easy way to fix this, so I think I'll just close this PR.

BTW the existing code simply strips newlines – this is also not completely kosher, but it might be enough for the specific arrays in question.

@@ -371,6 +376,11 @@ private function groupRoutesByHostRegex(RouteCollection $routes)
return $groups;
}

protected function exportArray($array)
{
return preg_replace(array('/array \(/', '/,\n *\)/', '/,\n */', '/\n */'), array('array(', ')', ', ', ''), var_export($array, true));
Copy link
Member

Choose a reason for hiding this comment

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

collision risk again?

@c960657 c960657 closed this Sep 29, 2016
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.

6 participants
0