@@ -47,15 +47,15 @@ function processStubFile(string $stubFile, Context $context): ?FileInfo {
47
47
$ stubCode = file_get_contents ($ stubFile );
48
48
$ stubHash = computeStubHash ($ stubCode );
49
49
$ oldStubHash = extractStubHash ($ arginfoFile );
50
- if ($ stubHash === $ oldStubHash && $ context ->forceRegeneration === false ) {
50
+ if ($ stubHash === $ oldStubHash && ! $ context ->forceParse ) {
51
51
/* Stub file did not change, do not regenerate. */
52
52
return null ;
53
53
}
54
54
55
55
initPhpParser ();
56
56
$ fileInfo = parseStubFile ($ stubCode );
57
57
$ arginfoCode = generateArgInfoCode ($ fileInfo , $ stubHash );
58
- if ($ context ->forceRegeneration === true && file_put_contents ($ arginfoFile , $ arginfoCode )) {
58
+ if ($ context ->forceRegeneration && file_put_contents ($ arginfoFile , $ arginfoCode )) {
59
59
echo "Saved $ arginfoFile \n" ;
60
60
}
61
61
@@ -94,7 +94,9 @@ function extractStubHash(string $arginfoFile): ?string {
94
94
}
95
95
96
96
class Context {
97
- /** @var bool|null */
97
+ /** @var bool */
98
+ public $ forceParse = false ;
99
+ /** @var bool */
98
100
public $ forceRegeneration = false ;
99
101
}
100
102
@@ -1267,8 +1269,8 @@ function initPhpParser() {
1267
1269
$ context = new Context ;
1268
1270
$ printParameterStats = isset ($ options ["parameter-stats " ]);
1269
1271
$ verify = isset ($ options ["verify " ]);
1270
- $ context ->forceRegeneration =
1271
- isset ( $ options [ " f " ]) || isset ( $ options [ " force-regeneration " ]) ? true : ( $ printParameterStats || $ verify ? null : false ) ;
1272
+ $ context ->forceRegeneration = isset ( $ options [ " f " ]) || isset ( $ options [ " force-regeneration " ]);
1273
+ $ context -> forceParse = $ context -> forceRegeneration || $ printParameterStats || $ verify ;
1272
1274
1273
1275
if (isset ($ options ["h " ]) || isset ($ options ["help " ])) {
1274
1276
die ("\nusage: gen-stub.php [ -f | --force-regeneration ] [ --parameter-stats ] [ --verify ] [ -h | --help ] [ name.stub.php | directory ] \n\n" );
0 commit comments