Skip to content
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

Correctly typed values for "empty()" values [0 | "" | false | null | ...] #77

Merged
merged 9 commits into from
Sep 5, 2018
Merged

Conversation

SerethiX
Copy link
Contributor

@SerethiX SerethiX commented Sep 4, 2018

Fixes #76

Proposed Changes

  • add the correct types to the json when the value seems empty to php. Now you can safely set false as your active flag and can use PHP 7.1 scalar type hints on the receiving side
  • extended tests to cover the new type conversions
    • SqlQueryTest
    • ValueTest
  • fixed a small issue where the update statement and insert statement would have different types. trim order changed
  • Fixed extends of TestCases to work with the default installation via make. Got ClassNotFound Exceptions during testing

*/
public static function getStringRepresentation($param)
{
if (is_int($param) || is_float($param))
Copy link
Member

Choose a reason for hiding this comment

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

if (is_int($param) || is_float($param)) return $param;
if (is_numeric($param))                 return (float) $param;
if (is_string($param))                  return '\'' . $param . '\'';
if ($param === true)                    return 'true';
if ($param === false)                   return 'false';
if ($param === null)                    return 'null';

throw new \Circle\DoctrineRestDriver\Validation\Exceptions\InvalidTypeException('string | int | float | bool | null', '$param', $param);

Types/Value.php Show resolved Hide resolved
@TobiasHauck
Copy link
Member

Hi Nils, thank you for your tremendous work! You fixed a lot of really ugly stuff in a very clear and structured way!

May you be so kind and fix these 2 coding style issues I reported via code review? Afterwards this PR is ready to merge. Thanks once again ;)

@SerethiX
Copy link
Contributor Author

SerethiX commented Sep 4, 2018

Sure, I added another commit.

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.

None yet

2 participants