9
9
use Safe \Generator \FileCreator ;
10
10
use Safe \Generator \ComposerJsonEditor ;
11
11
12
+ use Symfony \Component \Finder \Finder ;
12
13
use Symfony \Component \Console \Command \Command ;
13
14
use Symfony \Component \Console \Input \InputInterface ;
14
15
use Symfony \Component \Console \Output \OutputInterface ;
@@ -30,6 +31,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
30
31
$ this ->rmGenerated ();
31
32
32
33
// Let's build the DTD necessary to load the XML files.
34
+ $ this ->checkout (DocPage::findReferenceDir (), "master " );
33
35
DocPage::buildEntities ();
34
36
35
37
// PHP documentation is a living document, which broadly reflects
@@ -64,7 +66,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
64
66
$ this ->checkout (DocPage::findReferenceDir (), $ commit );
65
67
$ scanner = new Scanner (DocPage::findReferenceDir ());
66
68
$ res = $ scanner ->getMethods ($ scanner ->getFunctionsPaths (), $ output );
67
- $ output ->writeln ('These functions have been ignored and must be dealt with manually: ' .\implode (', ' , $ res ->overloadedFunctions ));
69
+ $ output ->writeln (
70
+ 'Functions have been ignored and must be dealt with manually: ' .
71
+ ($ output ->isVerbose () ?
72
+ implode (', ' , $ res ->overloadedFunctions ) :
73
+ count ($ res ->overloadedFunctions ) . ' functions '
74
+ )
75
+ );
68
76
69
77
$ currentFunctionsByName = [];
70
78
foreach ($ res ->methods as $ function ) {
@@ -83,8 +91,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
83
91
$ missingMethods [] = $ oldFunction ;
84
92
}
85
93
}
86
- $ output ->writeln ('Methods no longer need safe wrappers in ' . $ version . ': ' .
87
- \implode (', ' , \array_map (fn ($ m ) => $ m ->getFunctionName (), $ missingMethods )));
94
+ $ output ->writeln (
95
+ 'Functions no longer need safe wrappers in ' . $ version . ': ' .
96
+ ($ output ->isVerbose () ?
97
+ \implode (', ' , \array_map (fn ($ m ) => $ m ->getFunctionName (), $ missingMethods )) :
98
+ count ($ missingMethods ) . ' functions '
99
+ )
100
+ );
88
101
89
102
$ genDir = FileCreator::getSafeRootDir () . "/generated/ $ version " ;
90
103
$ fileCreator = new FileCreator ();
@@ -111,32 +124,29 @@ protected function execute(InputInterface $input, OutputInterface $output): int
111
124
112
125
private function checkout (string $ dir , string $ commit ): void
113
126
{
127
+ $ process = new Process (['git ' , 'clean ' , '-fdx ' ], $ dir );
128
+ $ process ->setTimeout (10 );
129
+ $ code = $ process ->run ();
130
+ if ($ code !== 0 ) {
131
+ throw new \RuntimeException ("Failed to git-clean in $ dir (exit $ code): \n{$ process ->getErrorOutput ()}" );
132
+ }
133
+
114
134
$ process = new Process (['git ' , 'checkout ' , $ commit ], $ dir );
115
135
$ process ->setTimeout (10 );
116
136
$ code = $ process ->run ();
117
137
if ($ code !== 0 ) {
118
- throw new \RuntimeException ("Failed to checkout $ commit in $ dir " );
138
+ throw new \RuntimeException ("Failed to checkout $ commit in $ dir (exit $ code ): \n{ $ process -> getErrorOutput ()} " );
119
139
}
120
140
}
121
141
122
142
private function rmGenerated (): void
123
143
{
124
- $ exceptions = \glob (FileCreator::getSafeRootDir () . '/generated/Exceptions/*.php ' );
125
- if ($ exceptions === false ) {
126
- throw new \RuntimeException ('Failed to require the generated exception files ' );
127
- }
128
-
129
- foreach ($ exceptions as $ exception ) {
130
- \unlink ($ exception );
131
- }
132
-
133
- $ files = \glob (FileCreator::getSafeRootDir () . '/generated/*.php ' );
134
- if ($ files === false ) {
135
- throw new \RuntimeException ('Failed to require the generated files ' );
136
- }
137
-
138
- foreach ($ files as $ file ) {
139
- \unlink ($ file );
144
+ $ finder = new Finder ();
145
+ $ finder ->in (FileCreator::getSafeRootDir () . "/generated " );
146
+ foreach ($ finder as $ file ) {
147
+ if ($ file ->isFile ()) {
148
+ \unlink ($ file ->getPathname ());
149
+ }
140
150
}
141
151
142
152
if (\file_exists (DocPage::findDocDir () . '/entities/generated.ent ' )) {
0 commit comments