-
Notifications
You must be signed in to change notification settings - Fork 357
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
Fix: Mark check() and coerce() as deprecated #476
Conversation
@@ -217,7 +217,7 @@ if (isset($arOptions['--dump-schema'])) { | |||
|
|||
try { | |||
$validator = new JsonSchema\Validator(); | |||
$validator->check($data, $schema); | |||
$validator->validate($data, $schema); |
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.
Probably makes sense to use Validator::validate()
here.
8cf5b90
to
e5efe21
Compare
@@ -6,7 +6,7 @@ | |||
|
|||
// Validate | |||
$validator = new JsonSchema\Validator(); | |||
$validator->check($data, (object) array('$ref' => 'file://' . realpath('schema.json'))); | |||
$validator->validate($data, (object) array('$ref' => 'file://' . realpath('schema.json'))); |
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.
Probably makes sense to use Validator::validate()
here, too.
d54234b
to
3b34779
Compare
@@ -71,6 +71,6 @@ public function testInvalidArgumentException() | |||
{ | |||
$v = new Validator(); | |||
$this->setExpectedException('\JsonSchema\Exception\InvalidArgumentException'); | |||
$v->check(json_decode('{}'), json_decode('')); | |||
$v->validate(json_decode('{}'), json_decode('')); |
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.
You cannot use validate()
in this situation, as the first argument is a reference. If you want to change this, you'll need to decode the document into an intermediate variable first, and then pass the variable.
tests/ValidatorTest.php
Outdated
@@ -36,7 +36,7 @@ public function testBadAssocSchemaInput() | |||
$validator->validate($data, $schema); | |||
} | |||
|
|||
public function testCheck() | |||
public function testDeprecatedCheckStillValidates() |
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.
Method name needs clarification - validation in this test is supposed to fail, but the new name falsely implies that success is the intended outcome.
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.
How about I rename both to test.*DelegatesToValidate()
?
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.
That works :-). I'm not particularly fussed what they are named, as long as they're not ambiguous and give a reasonable idea of the intended purpose.
3b34779
to
179c06d
Compare
179c06d
to
284f3e5
Compare
Updated! |
Thank you, @bighappyface and @erayd! |
This PR
Validator::check()
andValidator::coerce()
as deprecated