@@ -55,17 +55,17 @@ function processStubFile(string $stubFile, Context $context): ?FileInfo {
55
55
initPhpParser ();
56
56
$ fileInfo = parseStubFile ($ stubCode );
57
57
$ arginfoCode = generateArgInfoCode ($ fileInfo , $ stubHash );
58
- if ($ context ->forceRegeneration || $ stubHash !== $ oldStubHash ) {
59
- $ context -> generatedArginfoFiles [ $ arginfoFile ] = $ arginfoCode ;
58
+ if (( $ context ->forceRegeneration || $ stubHash !== $ oldStubHash) && file_put_contents ( $ arginfoFile , $ arginfoCode ) ) {
59
+ echo " Saved $ arginfoFile \n" ;
60
60
}
61
61
62
62
if ($ fileInfo ->generateLegacyArginfo ) {
63
63
foreach ($ fileInfo ->getAllFuncInfos () as $ funcInfo ) {
64
64
$ funcInfo ->discardInfoForOldPhpVersions ();
65
65
}
66
66
$ arginfoCode = generateArgInfoCode ($ fileInfo , $ stubHash );
67
- if ($ context ->forceRegeneration || $ stubHash !== $ oldStubHash ) {
68
- $ context -> generatedArginfoFiles [ $ legacyFile ] = $ arginfoCode ;
67
+ if (( $ context ->forceRegeneration || $ stubHash !== $ oldStubHash) && file_put_contents ( $ legacyFile , $ arginfoCode ) ) {
68
+ echo " Saved $ legacyFile \n" ;
69
69
}
70
70
}
71
71
@@ -98,8 +98,6 @@ class Context {
98
98
public $ forceParse = false ;
99
99
/** @var bool */
100
100
public $ forceRegeneration = false ;
101
- /** @var array */
102
- public $ generatedArginfoFiles = [];
103
101
}
104
102
105
103
class SimpleType {
@@ -532,12 +530,12 @@ public function isMethod(): bool
532
530
533
531
public function isFinalMethod (): bool
534
532
{
535
- return $ this ->flags & Class_::MODIFIER_FINAL || $ this ->classFlags & Class_::MODIFIER_FINAL ;
533
+ return ( $ this ->flags & Class_::MODIFIER_FINAL ) || ( $ this ->classFlags & Class_::MODIFIER_FINAL ) ;
536
534
}
537
535
538
536
public function isInstanceMethod (): bool
539
537
{
540
- return !($ this ->flags & Class_::MODIFIER_STATIC ) && $ this ->isMethod () && $ this ->name ->isConstructor () === false ;
538
+ return !($ this ->flags & Class_::MODIFIER_STATIC ) && $ this ->isMethod () && ! $ this ->name ->isConstructor ();
541
539
}
542
540
543
541
public function equalsApartFromName (FuncInfo $ other ): bool {
@@ -1347,6 +1345,24 @@ function initPhpParser() {
1347
1345
exit (1 );
1348
1346
}
1349
1347
1348
+ if ($ printParameterStats ) {
1349
+ $ parameterStats = [];
1350
+
1351
+ foreach ($ fileInfos as $ fileInfo ) {
1352
+ foreach ($ fileInfo ->getAllFuncInfos () as $ funcInfo ) {
1353
+ foreach ($ funcInfo ->args as $ argInfo ) {
1354
+ if (!isset ($ context ->parameterStats [$ argInfo ->name ])) {
1355
+ $ parameterStats [$ argInfo ->name ] = 0 ;
1356
+ }
1357
+ $ parameterStats [$ argInfo ->name ]++;
1358
+ }
1359
+ }
1360
+ }
1361
+
1362
+ arsort ($ parameterStats );
1363
+ echo json_encode ($ parameterStats , JSON_PRETTY_PRINT ), "\n" ;
1364
+ }
1365
+
1350
1366
if ($ verify ) {
1351
1367
$ errors = [];
1352
1368
$ funcMap = [];
@@ -1431,29 +1447,3 @@ function(?ArgInfo $aliasArg, ?ArgInfo $aliasedArg) use ($aliasFunc, $aliasedFunc
1431
1447
exit (1 );
1432
1448
}
1433
1449
}
1434
-
1435
- foreach ($ context ->generatedArginfoFiles as $ arginfoFile => $ arginfoCode ) {
1436
- if (file_put_contents ($ arginfoFile , $ arginfoCode )) {
1437
- echo "Saved $ arginfoFile \n" ;
1438
- } else {
1439
- echo "Saving $ arginfoFile was unsuccessful \n" ;
1440
- }
1441
- }
1442
-
1443
- if ($ printParameterStats ) {
1444
- $ parameterStats = [];
1445
-
1446
- foreach ($ fileInfos as $ fileInfo ) {
1447
- foreach ($ fileInfo ->getAllFuncInfos () as $ funcInfo ) {
1448
- foreach ($ funcInfo ->args as $ argInfo ) {
1449
- if (!isset ($ context ->parameterStats [$ argInfo ->name ])) {
1450
- $ parameterStats [$ argInfo ->name ] = 0 ;
1451
- }
1452
- $ parameterStats [$ argInfo ->name ]++;
1453
- }
1454
- }
1455
- }
1456
-
1457
- arsort ($ parameterStats );
1458
- echo json_encode ($ parameterStats , JSON_PRETTY_PRINT ), "\n" ;
1459
- }
0 commit comments