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

[WIP] Improved PHPDoc comments #1

Open
wants to merge 2 commits into
base: phpdoc
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
39 changes: 29 additions & 10 deletions src/JsonSchema/Constraints/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,35 @@ abstract class Constraint extends BaseConstraint implements ConstraintInterface
{
protected $inlineSchemaProperty = '$schema';

const CHECK_MODE_NONE = 0x00000000;
const CHECK_MODE_NORMAL = 0x00000001;
const CHECK_MODE_TYPE_CAST = 0x00000002;
const CHECK_MODE_COERCE_TYPES = 0x00000004;
const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
const CHECK_MODE_EXCEPTIONS = 0x00000010;
const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
const CHECK_MODE_EARLY_COERCE = 0x00000040;
const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
/** Bitwise value used to specify no constraint validation options */
const CHECK_MODE_NONE = 0x00000000;

/** Bitwise value used to specify normal constraint validation options */
const CHECK_MODE_NORMAL = 0x00000001;

/** Bitwise value used to specify the value typecasting constraint validation option */
const CHECK_MODE_TYPE_CAST = 0x00000002;

/** Bitwise value used to specify the value type coercion constraint validation option */
const CHECK_MODE_COERCE_TYPES = 0x00000004;

/** Bitwise value used to specify the default value constraint validation option */
const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;

/** Bitwise value used to specify the exception handling constraint validation option */
const CHECK_MODE_EXCEPTIONS = 0x00000010;

/** Bitwise value used to specify the disable format constraint validation option */
const CHECK_MODE_DISABLE_FORMAT = 0x00000020;

/** Bitwise value used to specify the early value type coercion constraint validation option */
const CHECK_MODE_EARLY_COERCE = 0x00000040;

/** Bitwise value used to specify the default value only for required properties constraint validation option */
const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;

/** Bitwise value used to specify the schema validation constraint validation option */
const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;

/**
* Bubble down the path
Expand Down
1 change: 0 additions & 1 deletion src/JsonSchema/Constraints/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use JsonSchema\Constraints\Constraint;
use JsonSchema\Exception\InvalidArgumentException;
use JsonSchema\Exception\InvalidConfigException;
use JsonSchema\SchemaStorage;
use JsonSchema\SchemaStorageInterface;
use JsonSchema\Uri\UriRetriever;
Expand Down
14 changes: 14 additions & 0 deletions src/JsonSchema/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
<?php

/*
* This file is part of the JsonSchema package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace JsonSchema\Exception;

/**
* General Interface for JSON Schema Exceptions
*
* @package justinrainbow\json-schema
*
* @license MIT
*/
interface ExceptionInterface
{
}
6 changes: 5 additions & 1 deletion src/JsonSchema/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
namespace JsonSchema\Exception;

/**
* Wrapper for the InvalidArgumentException
* Invalid arguments found in constraint configuration
*
* @package justinrainbow\json-schema
*
* @license MIT
*/
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
{
Expand Down
17 changes: 0 additions & 17 deletions src/JsonSchema/Exception/InvalidConfigException.php

This file was deleted.

6 changes: 5 additions & 1 deletion src/JsonSchema/Exception/InvalidSchemaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
namespace JsonSchema\Exception;

/**
* Wrapper for the InvalidSchemaMediaType
* Invalid JSON schema provided
*
* @package justinrainbow\json-schema
*
* @license MIT
*/
class InvalidSchemaException extends RuntimeException
{
Expand Down
6 changes: 5 additions & 1 deletion src/JsonSchema/Exception/InvalidSchemaMediaTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
namespace JsonSchema\Exception;

/**
* Wrapper for the InvalidSchemaMediaType
* Invalid JSON schema media type provided
*
* @package justinrainbow\json-schema
*
* @license MIT
*/
class InvalidSchemaMediaTypeException extends RuntimeException
{
Expand Down
17 changes: 0 additions & 17 deletions src/JsonSchema/Exception/InvalidSourceUriException.php

This file was deleted.

6 changes: 5 additions & 1 deletion src/JsonSchema/Exception/JsonDecodingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
namespace JsonSchema\Exception;

/**
* Wrapper for the JsonDecodingException
* Wrapper for JSON decoding constants to improve user messaging
*
* @package justinrainbow\json-schema
*
* @license MIT
*/
class JsonDecodingException extends RuntimeException
{
Expand Down
6 changes: 5 additions & 1 deletion src/JsonSchema/Exception/ResourceNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
namespace JsonSchema\Exception;

/**
* Wrapper for the ResourceNotFoundException
* Wrapper for JSON decoding constants to improve user messaging
*
* @package justinrainbow\json-schema
*
* @license MIT
*/
class ResourceNotFoundException extends RuntimeException
{
Expand Down
6 changes: 5 additions & 1 deletion src/JsonSchema/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
namespace JsonSchema\Exception;

/**
* Wrapper for the RuntimeException
* Wrapper for RuntimeException
*
* @package justinrainbow\json-schema
*
* @license MIT
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
{
Expand Down
6 changes: 4 additions & 2 deletions src/JsonSchema/Exception/UnresolvableJsonPointerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
namespace JsonSchema\Exception;

/**
* @package JsonSchema\Exception
* A pointer provided in the JSON schema is unresolvable
*
* @author Joost Nijhuis <[email protected]>
* @package justinrainbow\json-schema
*
* @license MIT
*/
class UnresolvableJsonPointerException extends InvalidArgumentException
{
Expand Down
6 changes: 5 additions & 1 deletion src/JsonSchema/Exception/UriResolverException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
namespace JsonSchema\Exception;

/**
* Wrapper for the UriResolverException
* A URI provided in the JSON schema is unresolvable
*
* @package justinrainbow\json-schema
*
* @license MIT
*/
class UriResolverException extends RuntimeException
{
Expand Down
7 changes: 7 additions & 0 deletions src/JsonSchema/Exception/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

namespace JsonSchema\Exception;

/**
* A JSON schema validation error detailing pointer and constraint information
*
* @package justinrainbow\json-schema
*
* @license MIT
*/
class ValidationException extends RuntimeException
{
}
17 changes: 12 additions & 5 deletions src/JsonSchema/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

use JsonSchema\Constraints\BaseConstraint;
use JsonSchema\Constraints\Constraint;
use JsonSchema\Exception\InvalidConfigException;
use JsonSchema\SchemaStorage;

/**
Expand All @@ -25,12 +24,20 @@
*/
class Validator extends BaseConstraint
{
/** Media type for JSON Schema */
const SCHEMA_MEDIA_TYPE = 'application/schema+json';

const ERROR_NONE = 0x00000000;
const ERROR_ALL = 0xFFFFFFFF;
const ERROR_DOCUMENT_VALIDATION = 0x00000001;
const ERROR_SCHEMA_VALIDATION = 0x00000002;
/** Bitwise value used to specify no error context */
const ERROR_NONE = 0x00000000;

/** Bitwise value used to specify all error contexts */
const ERROR_ALL = 0xFFFFFFFF;

/** Bitwise value used to specify JSON document validation error context */
const ERROR_DOCUMENT_VALIDATION = 0x00000001;

/** Bitwise value used to specify JSON schema validation error context */
const ERROR_SCHEMA_VALIDATION = 0x00000002;

/**
* Validates the given data against the schema and returns an object containing the results.
Expand Down