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

[FrameworkBundle] avoid tables to have apparently long blank line breaks and be too far appart for long nested array params #9720

Conversation

cordoval
Copy link
Contributor

@cordoval cordoval commented Dec 6, 2013

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets no
License MIT
Doc PR na

This PR fixes the uncomfortable long parameter array dumps on the tables, if one needs to see the details of a parameter they can do so by inspecting the specific parameter rather than having all the info in the table and render it out of whack.

@fabpot
Copy link
Member

fabpot commented Dec 7, 2013

Can you paste before/after screenshots?

@cordoval
Copy link
Contributor Author

cordoval commented Dec 7, 2013

php app/console container:debug --parameters

screenshot 2013-12-07 07 40 17

screenshot 2013-12-07 07 41 38

@cordoval
Copy link
Contributor Author

cordoval commented Dec 7, 2013

@fabpot ^^

@@ -198,7 +198,8 @@ protected function formatValue($value)
protected function formatParameter($value)
{
if (is_bool($value) || is_array($value) || (null === $value)) {
return json_encode($value);
$ellipsis = strlen(json_encode($value)) > 60;
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldnt encode twice here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean encode twice? I don't get it

Copy link
Contributor

Choose a reason for hiding this comment

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

Line below json_encode($value) is called again.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 json_encode should be done only once

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nevermind i see it 👶

@cordoval
Copy link
Contributor Author

done @fabpot , would be good if you are around working on symfony/symfony today to meet 👶 I am 5 minutes from the Westin 👶

return json_encode($value);
$jsonString = json_encode($value);

return substr($jsonString, 0, 60).(strlen($jsonString) > 60 ? ' ...' : '' );
Copy link
Contributor

Choose a reason for hiding this comment

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

i'd suggest

return strlen($jsonString) <= 60 ? $jsonString : substr_replace($jsonString, "...", 57)

to really limit the string to 60 chars (including the dots, that is)

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 will lookup how twig does it

@cordoval
Copy link
Contributor Author

@Burgov this proposal is inspired by twig's way of doing things so this should be better

return json_encode($value);
$jsonString = json_encode($value);

if (mb_strlen($jsonString) > 60) {
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC you can't depend on mbstring extension as this adds hard dependency on it, and it's not always available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fabpot any suggestions? true @stloyd

Copy link
Contributor

Choose a reason for hiding this comment

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

We usually check for existence and use a regular function if mb_* is not there. Like here: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Application.php#L674

@fabpot
Copy link
Member

fabpot commented Dec 16, 2013

ping @cordoval

@cordoval
Copy link
Contributor Author

@fabpot i am still on transit in Heathrow London now, i will tackle things as soon as I reach a safe heaven

@cordoval
Copy link
Contributor Author

ok finally taking this 👶

@cordoval
Copy link
Contributor Author

done @fabpot ^^ 👶

}

return (string) $value;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably safer to keep the cast to string.

@fabpot
Copy link
Member

fabpot commented Dec 23, 2013

@cordoval Can you take some time to finish this one, it's quite easy but should be done se that everything works in the same way with and without mbstring, which is not the case in the PR.

@cordoval
Copy link
Contributor Author

@fabpot yeah i will finish this one for sure, just that niece and daughter are playing around on and off.

👶 👧 👧

@cordoval
Copy link
Contributor Author

done @stloyd @jakzal

fabpot added a commit that referenced this pull request Dec 27, 2013
…k line breaks and be too far appart for long nested array params (cordoval)

This PR was submitted for the 2.4-dev branch but it was merged into the 2.4 branch instead (closes #9720).

Discussion
----------

[FrameworkBundle] avoid tables to have apparently long blank line breaks and be too far appart for long nested array params

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | no
| License       | MIT
| Doc PR        | na

This PR fixes the uncomfortable long parameter array dumps on the tables, if one needs to see the details of a parameter they can do so by inspecting the specific parameter rather than having all the info in the table and render it out of whack.

Commits
-------

a588ece avoid tables to have apparently long blank line breaks and be too far appart for long nested array params
@fabpot fabpot closed this Dec 27, 2013
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.

7 participants