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

Added inheritance of exceptions for the ability to catch errors #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions JsonRpc2/Validator/ValidateVar.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,23 @@ private function bringValueToType($parent, $type, $value)
);
Copy link
Owner

Choose a reason for hiding this comment

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

Please review carefully http://www.jsonrpc.org/specification, array-type does not allow.

Copy link
Owner

Choose a reason for hiding this comment

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

and why you'he commited this in not your topic?
now i cannot merge all changes.

return new $type($value);
} else {
if (is_array($value) || $value instanceof \stdClass) {
$value = 0;
}
switch ($type) {
case "string":
return (string)$value;
case "int":
return (int)$value;
case "float":
case "double":
return (float)$value;
case "double":
return (double)$value;
case "mixed":
case "array":
throw new Exception(
\Yii::t('yii', 'Parameter type \'array\' is deprecated. Use square brackets with simply types or DTO based classes instead.'),
Exception::INTERNAL_ERROR
);
return (array)$value;
case "bool":
return (bool)$value;
}
}

return $value;
}
}
}