36
36
PHP_85_VERSION_ID ,
37
37
];
38
38
39
+ // file_put_contents() but with a success message printed after saving
40
+ function reportFilePutContents (string $ filename , string $ content ): void {
41
+ if (file_put_contents ($ filename , $ content )) {
42
+ echo "Saved $ filename \n" ;
43
+ }
44
+ }
45
+
39
46
/**
40
47
* @return FileInfo[]
41
48
*/
@@ -121,8 +128,8 @@ function processStubFile(string $stubFile, Context $context, bool $includeOnly =
121
128
$ context ->allConstInfos ,
122
129
$ stubHash
123
130
);
124
- if (( $ context ->forceRegeneration || $ stubHash !== $ oldStubHash) && file_put_contents ( $ arginfoFile , $ arginfoCode ) ) {
125
- echo " Saved $ arginfoFile\n" ;
131
+ if ($ context ->forceRegeneration || $ stubHash !== $ oldStubHash ) {
132
+ reportFilePutContents ( $ arginfoFile, $ arginfoCode ) ;
126
133
}
127
134
128
135
if ($ fileInfo ->shouldGenerateLegacyArginfo ()) {
@@ -146,8 +153,8 @@ function processStubFile(string $stubFile, Context $context, bool $includeOnly =
146
153
$ context ->allConstInfos ,
147
154
$ stubHash
148
155
);
149
- if (( $ context ->forceRegeneration || $ stubHash !== $ oldStubHash) && file_put_contents ( $ legacyFile , $ arginfoCode ) ) {
150
- echo " Saved $ legacyFile\n" ;
156
+ if ($ context ->forceRegeneration || $ stubHash !== $ oldStubHash ) {
157
+ reportFilePutContents ( $ legacyFile, $ arginfoCode ) ;
151
158
}
152
159
}
153
160
@@ -6290,9 +6297,7 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
6290
6297
6291
6298
if ($replacePredefinedConstants) {
6292
6299
foreach ($predefinedConstants as $filename => $content) {
6293
- if (file_put_contents($filename, $content)) {
6294
- echo "Saved $filename\n";
6295
- }
6300
+ reportFilePutContents($filename, $content);
6296
6301
}
6297
6302
}
6298
6303
}
@@ -6307,9 +6312,7 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
6307
6312
}
6308
6313
6309
6314
foreach ($classSynopses as $filename => $content) {
6310
- if (file_put_contents("$classSynopsesDirectory/$filename", $content)) {
6311
- echo "Saved $filename\n";
6312
- }
6315
+ reportFilePutContents("$classSynopsesDirectory/$filename", $content);
6313
6316
}
6314
6317
}
6315
6318
}
@@ -6319,9 +6322,7 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
6319
6322
6320
6323
if ($replaceClassSynopses) {
6321
6324
foreach ($classSynopses as $filename => $content) {
6322
- if (file_put_contents($filename, $content)) {
6323
- echo "Saved $filename\n";
6324
- }
6325
+ reportFilePutContents($filename, $content);
6325
6326
}
6326
6327
}
6327
6328
}
@@ -6340,9 +6341,7 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
6340
6341
mkdir(dirname($path));
6341
6342
}
6342
6343
6343
- if (file_put_contents($path, $content)) {
6344
- echo "Saved $filename\n";
6345
- }
6344
+ reportFilePutContents($path, $content);
6346
6345
}
6347
6346
}
6348
6347
}
@@ -6352,9 +6351,7 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
6352
6351
6353
6352
if ($replaceMethodSynopses) {
6354
6353
foreach ($methodSynopses as $filename => $content) {
6355
- if (file_put_contents($filename, $content)) {
6356
- echo "Saved $filename\n";
6357
- }
6354
+ reportFilePutContents($filename, $content);
6358
6355
}
6359
6356
}
6360
6357
}
@@ -6363,9 +6360,7 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
6363
6360
$filename = dirname(__FILE__, 2) . "/Zend/Optimizer/zend_func_infos.h";
6364
6361
$optimizerInfo = generateOptimizerInfo($funcMap);
6365
6362
6366
- if (file_put_contents($filename, $optimizerInfo)) {
6367
- echo "Saved $filename\n";
6368
- }
6363
+ reportFilePutContents($filename, $optimizerInfo);
6369
6364
}
6370
6365
6371
6366
if ($verifyManual) {
0 commit comments