nette / schema

📐 Validating data structures against a given Schema.
https://doc.nette.org/schema
Other
905 stars 26 forks source link

Feature request: Unmark Context as internal #29

Closed jakubboucek closed 3 years ago

jakubboucek commented 4 years ago

Class \Nette\Schema\Context is marked as @internal.

https://github.com/nette/schema/blob/febf71fb4052c824046f5a33f4f769a6e7fa0cb4/src/Schema/Context.php#L15-L18

It causes that I cannot make custom validator object because the ->normalize() method requires Context instance in argument declared by \Nette\Schema\Schema interface.

PhpStorm is here firing inspection warning:

Class 'Context' is marked as @internal  
Inspection info: Reports the usages of the entities that are marked as @internal.
In most cases, such usages should be removed or replaced with other constructs.

In addition Context is not fully internal, because custom validators need it for for collecting validation errors. I didn't found possibility to do it with more clean way.

Example of use: https://github.com/redbitcz/subreg-api-php/blob/60f377ac68f3c1871b926eca336f5eb8d3368455/src/Schema/DateTime.php#L44-L64

Suggest to feature

Unmark \Nette\Schema\Context as internal.

I understand the Context class has currently too open public interface which is potentially sensitive. Maybe move collecting errors to more specifics object which will not be @internal marked.