Skip to content

Conversation

@henriquemoody
Copy link
Member

Update conversion to strings on exceptions

Many changes were made on ValidationException::stringify:

  • Add support for instances of Exception;
  • Add support for instances of Traversable;
  • Add support for resources;
  • Improve Array conversion;
  • Improve Object conversion;
  • Improve conversion of all values by using JSON.

Now, all the parameters of the exception classes are just converted to string when replacing parameters on exceptions, so the exception classes now keep the original value of all parameters.

Fix #395


Samples:

""
"foo"
INF
-INF
NaN
123
123.456
{ }
{ false }
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,  ...  }
{ "foo": true, "bar": { "baz": 123, "qux": { 1, 2, 3 } } }
{ "foo": true, "bar": { "baz": 123, "qux": { "norf": ... } } }
{ { }, "foo" }
{ { 1 }, "foo" }
{ 1, { 2, { 3 } } }
{ 1, { 2, { 3, ... } } }
{ 1, { 2, { 3, ... } } }
{ "foo", "bar" }
{ "foo", -1 }
"stringify.phpt"
"1988-09-09T23:59:59+00:00"
`[object] (stdClass: { })`
`[object] (stdClass: { "foo": 1, "bar": false })`
`[object] (stdClass: { "name": [object] (stdClass: ...) })`
`[exception] (Exception: { "message": "My message", "code": 0, "file": "%s:%d" })`
`[traversable] (ArrayIterator: { 1, 2, 3 })`
`[traversable] (ArrayIterator: { "a": 1, "b": 2, "c": 3 })`
`[resource] (stream-context)`
`[resource] (stream)`
`[resource] (xml)`
{ `[object] (stdClass: { "foo": 1, "bar": false })`, { 42, 43 }, true, null, `[resource] (stream)` }

@henriquemoody henriquemoody added this to the 1.0 milestone Sep 2, 2015
@henriquemoody henriquemoody changed the title [WIP] Update conversion to strings on exceptions Update conversion to strings on exceptions Sep 3, 2015
Many changes were made on `ValidationException::stringify`:
- Add support for instances of `Exception`;
- Add support for instances of `Traversable`;
- Add support for resources;
- Improve `Array` conversion;
- Improve `Object` conversion;
- Improve conversion of all values by using JSON.

Now, all the parameters of the exception classes are just converted to
string when replacing parameters on exceptions, so the exception classes
now keep the original value of all parameters.
@henriquemoody henriquemoody merged commit 748b280 into Respect:master Sep 4, 2015
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.

1 participant