@@ -8,34 +8,31 @@ require __DIR__ . '/../vendor/autoload.php';
88use Nette \PhpGenerator \InterfaceType ;
99use Nette \PhpGenerator \PhpNamespace ;
1010use Nette \PhpGenerator \Printer ;
11- use Respect \Validation \Exceptions \ValidationException ;
12- use Respect \Validation \Mixins \KeyChain ;
13- use Respect \Validation \Mixins \LengthChain ;
14- use Respect \Validation \Mixins \MaxChain ;
15- use Respect \Validation \Mixins \MinChain ;
16- use Respect \Validation \Mixins \NotChain ;
17- use Respect \Validation \Mixins \NullOrChain ;
18- use Respect \Validation \Mixins \PropertyChain ;
19- use Respect \Validation \Mixins \UndefOrChain ;
2011use Respect \Validation \Mixins \Chain ;
2112use Respect \Validation \Mixins \KeyBuilder ;
13+ use Respect \Validation \Mixins \KeyChain ;
2214use Respect \Validation \Mixins \LengthBuilder ;
15+ use Respect \Validation \Mixins \LengthChain ;
2316use Respect \Validation \Mixins \MaxBuilder ;
17+ use Respect \Validation \Mixins \MaxChain ;
2418use Respect \Validation \Mixins \MinBuilder ;
19+ use Respect \Validation \Mixins \MinChain ;
2520use Respect \Validation \Mixins \NotBuilder ;
21+ use Respect \Validation \Mixins \NotChain ;
2622use Respect \Validation \Mixins \NullOrBuilder ;
23+ use Respect \Validation \Mixins \NullOrChain ;
2724use Respect \Validation \Mixins \PropertyBuilder ;
25+ use Respect \Validation \Mixins \PropertyChain ;
2826use Respect \Validation \Mixins \UndefOrBuilder ;
29- use Respect \Validation \Rules \Undef ;
30- use Respect \Validation \Rules \NullOr ;
31- use Respect \Validation \Rules \UndefOr ;
27+ use Respect \Validation \Mixins \UndefOrChain ;
3228use Respect \Validation \Rule ;
29+ use Respect \Validation \Validator ;
3330
3431function addMethodToInterface (
3532 string $ originalName ,
3633 InterfaceType $ interfaceType ,
3734 ReflectionClass $ reflection ,
38- ? string $ prefix ,
35+ string | null $ prefix ,
3936 array $ allowList ,
4037 array $ denyList ,
4138): void {
@@ -65,6 +62,7 @@ function addMethodToInterface(
6562 if ($ reflrectionConstructor === null ) {
6663 return ;
6764 }
65+
6866 $ commend = $ reflrectionConstructor ->getDocComment ();
6967 if ($ commend ) {
7068 $ method ->addComment (preg_replace ('@(/\*\* *| +\* +| +\*/)@ ' , '' , $ commend ));
@@ -83,13 +81,15 @@ function addMethodToInterface(
8381 }
8482 } elseif ($ type instanceof ReflectionNamedType) {
8583 $ types [] = $ type ->getName ();
86- if ( str_starts_with ($ type ->getName (), 'Sokil ' )
84+ if (
85+ str_starts_with ($ type ->getName (), 'Sokil ' )
8786 || str_starts_with ($ type ->getName (), 'Egulias ' )
8887 || $ type ->getName () === 'finfo '
8988 ) {
9089 continue ;
9190 }
9291 }
92+
9393 $ parameter = $ method ->addParameter ($ reflectionParameter ->getName ());
9494 $ parameter ->setType (implode ('| ' , $ types ));
9595
@@ -121,7 +121,7 @@ function overwriteFile(string $content, string $basename): void
121121{
122122 file_put_contents (sprintf ('%s/../library/Mixins/%s.php ' , __DIR__ , $ basename ), implode (PHP_EOL . PHP_EOL , [
123123 '<?php ' ,
124- file_get_contents (__DIR__ . '/../.docheader ' ),
124+ file_get_contents (__DIR__ . '/../.docheader ' ),
125125 'declare(strict_types=1); ' ,
126126 preg_replace ('/extends (.+, )+/ ' , 'extends ' . PHP_EOL . '\1 ' , $ content ),
127127 ]));
@@ -172,7 +172,7 @@ function overwriteFile(string $content, string $basename): void
172172 ['Length ' , 'length ' , $ numberRelatedRules , []],
173173 ['Max ' , 'max ' , $ numberRelatedRules , []],
174174 ['Min ' , 'min ' , $ numberRelatedRules , []],
175- ['Not ' , 'not ' , [], ['Not ' , 'NotEmpty ' , 'NotEmoji ' , ' NullOr ' , 'UndefOr ' , 'Attributes ' , 'Templated ' , 'Named ' ]],
175+ ['Not ' , 'not ' , [], ['Not ' , 'NotEmpty ' , 'NullOr ' , 'UndefOr ' , 'Attributes ' , 'Templated ' , 'Named ' ]],
176176 ['NullOr ' , 'nullOr ' , [], ['NullOr ' , 'Blank ' , 'Undef ' , 'UndefOr ' , 'Templated ' , 'Named ' ]],
177177 ['Property ' , 'property ' , [], $ structureRelatedRules ],
178178 ['UndefOr ' , 'undefOr ' , [], ['NullOr ' , 'Blank ' , 'Undef ' , 'UndefOr ' , 'Attributes ' , 'Templated ' , 'Named ' ]],
@@ -190,8 +190,10 @@ function overwriteFile(string $content, string $basename): void
190190 if ($ reflection ->isAbstract ()) {
191191 continue ;
192192 }
193+
193194 $ names [$ reflection ->getShortName ()] = $ reflection ;
194195 }
196+
195197 ksort ($ names );
196198
197199 foreach ($ mixins as [$ name , $ prefix , $ allowList , $ denyList ]) {
@@ -213,7 +215,7 @@ function overwriteFile(string $content, string $basename): void
213215 $ chainedInterface ->addExtend (NullOrChain::class);
214216 $ chainedInterface ->addExtend (PropertyChain::class);
215217 $ chainedInterface ->addExtend (UndefOrChain::class);
216- $ chainedInterface ->addComment ('@mixin \\' . \ Respect \ Validation \ Validator::class);
218+ $ chainedInterface ->addComment ('@mixin \\' . Validator::class);
217219
218220 $ staticInterface ->addExtend (KeyBuilder::class);
219221 $ staticInterface ->addExtend (LengthBuilder::class);
@@ -237,5 +239,5 @@ function overwriteFile(string $content, string $basename): void
237239 overwriteFile ($ printer ->printNamespace ($ chainedNamespace ), $ chainedInterface ->getName ());
238240 }
239241
240- shell_exec (__DIR__ . '/../vendor/bin/phpcbf ' );
242+ shell_exec (__DIR__ . '/../vendor/bin/phpcbf ' . __DIR__ . ' /../library/Mixins ' );
241243})();
0 commit comments