-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[VarDumper] add caster for NumberFormatter #28555
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
[VarDumper] add caster for NumberFormatter #28555
Conversation
jschaedl
commented
Sep 22, 2018
•
edited
Loading
edited
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #28554 |
License | MIT |
Doc PR | - |
Thanks for working on this. |
7190720
to
33a3971
Compare
done
I like the idea. The first possible solution which came to my mind was to show all possible values of the attributes, text-attributes and symbol as an array:
WDYT? |
Wow, I didn't expect so many! LGTM yes. |
2d26d30
to
f87589b
Compare
Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(), | ||
Caster::PREFIX_VIRTUAL.'attributes' => new EnumStub( | ||
array( | ||
'PARSE_INT_ONLY' => $c->getSymbol(\NumberFormatter::PARSE_INT_ONLY), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this use getAttribute instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should. It is fixed now.
$a += array( | ||
Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(), | ||
Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(), | ||
Caster::PREFIX_VIRTUAL.'attributes' => new EnumStub( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before adding this key to the array, I'd suggest adding its last , $filter = 0
argument to the method and using it in a block like:
if ($filter & Caster::EXCLUDE_VERBOSE) {
$stub->cut += 3;
return $a;
}
), | ||
); | ||
|
||
if ($errorCode = $c->getErrorCode()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this "if" is going to be repeated for each caster method, let's move it in a dedicated private static method and replace all return $a
by return self::thisNewMethod($a);
b34fe65
to
4cf7feb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome thanks! (just one minor comment remaining)
return self::dumpError($c, $a); | ||
} | ||
|
||
private static function dumpError($c, array $a): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's call it castError?
acf7dce
to
0bd8a0b
Compare
Thank you @jschaedl. |
This PR was squashed before being merged into the 4.2-dev branch (closes #28555). Discussion ---------- [VarDumper] add caster for NumberFormatter | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28554 | License | MIT | Doc PR | - Commits ------- 0bd8a0b [VarDumper] add caster for NumberFormatter