8000 [VarDumper] Add filters to casters by nicolas-grekas · Pull Request #14058 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[VarDumper] Add filters to casters #14058

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

Merged
merged 1 commit into from
Mar 30, 2015
Merged

Conversation

nicolas-grekas
Copy link
Member
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

break;
case isset($k[1]) && "\0" === $k[0]:
switch ($k[1]) {
case '~': $type = self::EXCLUDE_VIRTUAL; break;
Copy link
Contributor

Choose a reason for hiding this comment

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

This violates PSR-2.

Copy link
Contributor

Choose a reason for hiding this comment

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

You have multiple statements on one line.

Copy link
Member Author
10000

Choose a reason for hiding this comment

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

It's way more readable this way to me...

Copy link
Member

Choose a reason for hiding this comment

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

I would make this multiline to make it more readable (seeing easily that we have some logic in the case, not only a condition falling through to the next case).
currently, the code here is very similar to the code on lines 52 and 53 at first look, while the structure of the code is actually totally different

*
* @return array The filtered array
*/
public static function filter(array $a, $filter, array $listedProperties = array())
Copy link
Member

Choose a reason for hiding this comment

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

is this method actually used anywhere ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not in Symfony but I hope to use it in PsySH bobthecow/psysh#184

@nicolas-grekas nicolas-grekas force-pushed the caster-filter branch 3 times, most recently from 7ac8cc4 to 73291bd Compare March 27, 2015 18:22
*
* @param array $a The array containing the properties to filter.
* @param int $filter A bit field of Caster::EXCLUDE_* constants specifying which properties to filter out.
* @param array $listedProperties List of properties to exclude when Caster::EXCLUDE_VERBOSE is set, and to preserve when Caster::EXCLUDE_NOT_IMPORTANT is set.
Copy link
Member

Choose a reason for hiding this comment

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

this means we cannot set EXCLUDE_VERBOSE and EXCLUDE_NOT_IMPORTANT at the same time without doing weird stuff, right ? If so, it should trigger an InvalidArgumentException in this case.

and the type should be string[]

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a test case with both enabled. The result is excluding everything. I agree that it's not usefull, but since this is a consistent behavior, I'd prefer not adding an exception.

@nicolas-grekas
Copy link
Member Author

Any objection to merge this @symfony/deciders? Tests are OK for what is concerned by this PR.

@fabpot
Copy link
Member
fabpot commented Mar 30, 2015

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 84a80d1 into symfony:2.7 Mar 30, 2015
fabpot added a commit that referenced this pull request Mar 30, 2015
This PR was merged into the 2.7 branch.

Discussion
----------

[VarDumper] Add filters to casters

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

Commits
-------

84a80d1 [VarDumper] Add filters to casters
@nicolas-grekas nicolas-grekas deleted the caster-filter branch March 30, 2015 15:44
nicolas-grekas added a commit that referenced this pull request Mar 31, 2015
…as-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[VarDumper] Add and use Caster::PREFIX_* consts

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

Will need a rebase on top of #14058 once it is merged

Commits
-------

86cf8de [VarDumper] Make use of Caster::PREFIX_* consts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0