Rework Exceptions
Backward incompatible changes
Fixed immutable classes default value (issue #7)
The default value for immutable was documented as true but was set to false. Now the default value is true. If you rely on setters being generated but haven't explicitly set the option on your GeneratorConfiguration
you can simply set the option for immutable classes to false:
new Generator(
(new GeneratorConfiguration())
->setImmutable(false)
);
Dropped setExceptionClass
option
As errors are thrown as specific exceptions now the option to set a custom exception class for the early-return mode has been removed. A custom ErrorRegistryException for collecting validation errors can still be added
Changed ErrorRegistryExceptionInterface
As the internal errors which are collected in an ErrorRegistryException
are now passed as ValidationExceptions
and not as strings the interface for ErrorRegistryExceptions has been updated. If you provide a custom ErrorRegistryException
you must update your implementation to follow the interface.
The method getErrors
now returns an array of validation errors instead of a string array providing access to the collected errors.
The result of ErrorRegistryException->getMessage()
hasn't been changed
Changed signature of toJSON
and toArray
If you use the $options
or $depth
parameter of the toJSON
or toArray
method you must add the $except
parameter which is now the first parameter of both functions (docs)
Features
Reworked exceptions
Instead of strings the internal errors are now specific exceptions implemented in the wol-soft/php-json-schema-model-generator-production
repository. Each validation violation now has a dedicated exception implementation with additional data instead of a simple string (compare the docs for more details on which exceptions provide which data).
All exceptions, including the ErrorRegistryException
now provide a toJSON
and a toArray
method for serialization and implement the PHP builtin interface JsonSerializable
which allows the exceptions to be passed directly into json_encode
.
Except for serialization methods
The serialization methods now provide an $except
parameter to define properties which must'nt be serialized (eg. a password property for an user) (docs)
Bugfixes
- Skip filters after a failing transforming filter to avoid irrelevant additional errors due to type incompatibilities (PR #9)