-
Notifications
You must be signed in to change notification settings - Fork 5
Improve error message #16
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
6d967d3
86b2b3b
6a992da
8a0014e
22f03a9
eca24f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ public function addMappings(array $mappings) | |
| */ | ||
| public function formatDate($format, \DateTime $date = null) | ||
| { | ||
| if ($date === null) { | ||
| if (null === $date) { | ||
| return null; | ||
| } | ||
|
|
||
|
|
@@ -87,7 +87,7 @@ public function resolve(&$mapping, &$obj, &$context) | |
| foreach ($mapping as $key => $value) { | ||
| $resolved = $this->resolve($value, $obj, $context); | ||
|
|
||
| if ($resolved !== null) { | ||
| if (null !== $resolved) { | ||
| $res[$key] = $resolved; | ||
| } | ||
| } | ||
|
|
@@ -146,6 +146,10 @@ public function mapAll($elements, $mappingName, $context = []) | |
| */ | ||
| public function keyExists(array $obj, $key) | ||
| { | ||
| if (!is_string($key) and !is_integer($key)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BertrandF23 we should add/update the tests for this change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests are done for keyExists, testing true or false result, but also exceptions due to wrong type of parameters. |
||
| throw new \RuntimeException('keyExists expected either a string or an integer, \''.print_r($key, true).'\' was given.'); | ||
| } | ||
|
|
||
| return array_key_exists($key, $obj); | ||
| } | ||
|
|
||
|
|
@@ -302,11 +306,11 @@ public function serializeWithGroup($data, $format, $group) | |
| } | ||
|
|
||
| /** | ||
| * Return the n-th section of the given string splitted by piece of the given length | ||
| * Return the n-th section of the given string splitted by piece of the given length. | ||
| * | ||
| * @param string $string | ||
| * @param int $length | ||
| * @param int $section | ||
| * @param int $length | ||
| * @param int $section | ||
| * | ||
| * @return string | ||
| */ | ||
|
|
@@ -320,6 +324,7 @@ public function wordWrap($string, $length, $section) | |
| if (isset($lines[$section])) { | ||
| $result = $lines[$section]; | ||
| } | ||
|
|
||
| return $result; | ||
| } | ||
|
|
||
|
|
||
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.
Hi @BertrandF23 ,
This is potentially a breaking change on the framework for other user of the bundle.
I would recommend not to do it as part of this pull request.
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.
Ok, was split and put in another pull request :-).