Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[VarDumper] Fix CliDumper coloration on light arrays#36230

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@l-vo
Copy link
Contributor

QA
Branch?3.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets
LicenseMIT
Doc PR

WhenAbstractDumper::DUMP_LIGHT_ARRAY is used with theCliDumper, the first line (opening bracket) is not colored. When an empty array is dumped (with or withoutAbstractDumper::DUMP_LIGHT_ARRAY) the array is not colored too. This PR aims to fix that.

}else {
$prefix =$class && !(self::DUMP_LIGHT_ARRAY &$this->flags) ?$this->style('note','array:'.$class).' [' :'[';
$unstyledPrefix =$class && !(self::DUMP_LIGHT_ARRAY &$this->flags) ?'array:'.$class :'';
$prefix =$this->style('note',$unstyledPrefix).($unstyledPrefix ?' [' :'[');

Choose a reason for hiding this comment

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

I'm not sure I get the logic - why styling the empty string?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Because if I don't trigger a coloration (even on an empty string), coloration is not enabled and the open bracket stay uncolored.

Copy link
Member

Choose a reason for hiding this comment

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

the issue in#37674 is precisely complaining about that.

@nicolas-grekas
Copy link
Member

Can you provide a simple script to reproduce the issue? I failed at it.

@l-vo
Copy link
ContributorAuthor

Of course 🙂

useSymfony\Component\VarDumper\Cloner\VarCloner;useSymfony\Component\VarDumper\Dumper\AbstractDumper;useSymfony\Component\VarDumper\Dumper\CliDumper;require__DIR__.'/vendor/autoload.php';$cliDumper =newCliDumper(null,null, AbstractDumper::DUMP_LIGHT_ARRAY);$cliDumper->dump((newVarCloner())->cloneVar([]));$var = ['foo' =>'bar'];$cliDumper->dump((newVarCloner())->cloneVar(['foo' =>'bar']));

Capture d’écran 2020-06-14 à 15 27 32

[] and first opening bracket of ["foo" => "bar"] aren't colored.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

Great thanks.

@nicolas-grekas
Copy link
Member

Can you check the failures on Windows? Maybe you'd like to skip the test case there btw.

@l-vol-voforce-pushed thefix_clidumper_coloration_light_array branch 14 times, most recently from4645e0a to4881712CompareJune 15, 2020 06:40
@l-vo
Copy link
ContributorAuthor

I didn't notice that the tests failed on windows; It's fixed, the test is now skipped on this environment.

@l-vol-voforce-pushed thefix_clidumper_coloration_light_array branch 2 times, most recently fromd52165f to48116afCompareJune 15, 2020 07:26
@l-vol-voforce-pushed thefix_clidumper_coloration_light_array branch from48116af to8ad26a8CompareJune 15, 2020 07:27
When using AbstractDumper::DUMP_LIGHT_ARRAY
@l-vol-voforce-pushed thefix_clidumper_coloration_light_array branch from8ad26a8 to7af3469CompareJune 15, 2020 07:49
@nicolas-grekas
Copy link
Member

Thank you@l-vo.

@nicolas-grekasnicolas-grekas merged commit907ffa0 intosymfony:3.4Jun 18, 2020
This was referencedJul 24, 2020
fabpot added a commit that referenced this pull requestJul 31, 2020
… (l-vo)This PR was merged into the 3.4 branch.Discussion----------[VarDumper] Improve previous fix on light array coloration| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#37674| License       | MIT| Doc PR        |Improve#36230 tofix#37674 (revert previous fix and use a solution that looks better).Commits-------cef16f5 [VarDumper] Improve previous fix on light array coloration
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

4 participants

@l-vo@nicolas-grekas@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp